Skip to content

Commit

Permalink
fix(costcenter): fix unit & invoice amount
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou committed Oct 27, 2023
1 parent 3bc6c3c commit 176b85c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions frontend/providers/costcenter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --port 3001",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down Expand Up @@ -53,4 +53,4 @@
"prettier": "^2.8.8",
"sass": "^1.68.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function InvoiceTable({
</Flex>
</Td>
<Td>{format(item.createdTime, 'MM-dd HH:mm')}</Td>
<Td color={'#219BF4'}>{item.amount}</Td>
<Td color={'#219BF4'}>{item.payment?.amount || item.amount}</Td>
</Tr>
))}
</Tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ function Invoice() {
data={[...tableResult]}
onSelect={(checked, item) => {
if (checked) {
setInvoiceAmount(invoiceAmount + item.amount);
setInvoiceAmount(invoiceAmount + (item.payment?.amount || item.amount));
setInvoiceCount(invoiceCount + 1);
selectBillings.current.push({ ...item });
} else {
setInvoiceAmount(invoiceAmount - item.amount);
setInvoiceAmount(invoiceAmount - (item.payment?.amount || item.amount));
setInvoiceCount(invoiceCount - 1);
const idx = selectBillings.current.findIndex(
(billing) => billing.order_id === item.order_id
Expand Down
10 changes: 5 additions & 5 deletions frontend/providers/costcenter/src/pages/valuation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ function Valuation() {
return [
{
title: x.resourceType,
price: [1, 24, 168, 720, 8760].map((v) => (v * x.price * (props.scale || 1)) / 1000000),
price: [1, 24, 168, 720, 8760].map(
(v) => Math.floor(v * x.price * (props.scale || 1)) / 1000000
),
unit: props.unit,
bg: props.bg,
idx: props.idx,
Expand Down Expand Up @@ -219,10 +221,8 @@ function Valuation() {
{t(x.title)}
</Text>
</Td>
<Td>
{x.unit}/{t(CYCLE[cycleIdx])}
</Td>
<Td>{x.price[cycleIdx]}</Td>
<Td>{x.unit + (x.title !== 'network' ? `/${t(CYCLE[cycleIdx])}` : '')}</Td>
<Td>{x.title === 'network' ? x.price[0] : x.price[cycleIdx]}</Td>
</Tr>
))}
</Tbody>
Expand Down
3 changes: 3 additions & 0 deletions frontend/providers/costcenter/src/types/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export type ReqGenInvoice = {
order_id: string;
amount: number;
// timeStamp
payment?: {
amount: number;
};
createdTime: number;
}[];
};
Expand Down

0 comments on commit 176b85c

Please sign in to comment.