update billing
This commit is contained in:
@@ -169,10 +169,10 @@ function List({ items, search }) {
|
||||
}, [search, fuse, items])
|
||||
|
||||
const charges = filtered
|
||||
?.filter((item) => 'course' in item && item?.unit_price > 0)
|
||||
?.filter((item) => item?.unit_price > 0)
|
||||
?.sort(sortBy('enrolled_at'))
|
||||
const credits = filtered
|
||||
?.filter((item) => 'course' in item && item?.unit_price < 0)
|
||||
?.filter((item) => item?.unit_price < 0)
|
||||
?.sort(sortBy('created_at'))
|
||||
|
||||
if (items.length === 0) {
|
||||
@@ -207,6 +207,16 @@ function List({ items, search }) {
|
||||
)
|
||||
}
|
||||
|
||||
const subtotal = filtered
|
||||
?.filter(({ unit_price }) => unit_price > 0)
|
||||
?.reduce((acc, { unit_price }) => acc + unit_price, 0)
|
||||
|
||||
const discounts = filtered
|
||||
?.filter(({ unit_price }) => unit_price < 0)
|
||||
?.reduce((acc, { unit_price }) => acc + unit_price, 0)
|
||||
|
||||
const total = filtered?.reduce((acc, { unit_price }) => acc + unit_price, 0)
|
||||
|
||||
return (
|
||||
<Table className="table-auto w-full">
|
||||
{charges.length ? (
|
||||
@@ -288,16 +298,28 @@ function List({ items, search }) {
|
||||
) : null}
|
||||
|
||||
<TableFooter>
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-right pointer-events-none">
|
||||
Subtotal
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Currency>{subtotal}</Currency>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-right pointer-events-none">
|
||||
Descontos
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Currency>{discounts}</Currency>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-right pointer-events-none">
|
||||
Total
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Currency>
|
||||
{filtered
|
||||
?.filter((x) => 'course' in x)
|
||||
?.reduce((acc, { unit_price }) => acc + unit_price, 0)}
|
||||
</Currency>
|
||||
<Currency>{total}</Currency>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableFooter>
|
||||
|
||||
Reference in New Issue
Block a user