mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: items entries total calculation.
This commit is contained in:
@@ -75,7 +75,7 @@ export function QuantityTotalFooterCell({ rows }) {
|
||||
* Total footer cell.
|
||||
*/
|
||||
export function TotalFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const total = safeSumBy(rows, 'original.total');
|
||||
const total = safeSumBy(rows, 'original.amount');
|
||||
return <span>{formattedAmount(total, currencyCode)}</span>;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ export function useEditableItemsEntriesColumns({ landedCost }) {
|
||||
{
|
||||
Header: intl.get('total'),
|
||||
Footer: TotalFooterCell,
|
||||
accessor: 'total',
|
||||
accessor: 'amount',
|
||||
Cell: TotalCell,
|
||||
disableSortBy: true,
|
||||
width: 100,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { sumBy } from 'lodash';
|
||||
import { toSafeNumber } from 'utils';
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ export const calcItemEntryTotal = (discount, quantity, rate) => {
|
||||
export function updateItemsEntriesTotal(rows) {
|
||||
return rows.map((row) => ({
|
||||
...row,
|
||||
total: calcItemEntryTotal(row.discount, row.quantity, row.rate),
|
||||
amount: calcItemEntryTotal(row.discount, row.quantity, row.rate),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -29,3 +30,10 @@ export const ITEM_TYPE = {
|
||||
SELLABLE: 'SELLABLE',
|
||||
PURCHASABLE: 'PURCHASABLE',
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve total of the given items entries.
|
||||
*/
|
||||
export function getEntriesTotal(entries) {
|
||||
return sumBy(entries, 'amount');
|
||||
}
|
||||
Reference in New Issue
Block a user