fix: (*): fix currency code.

This commit is contained in:
elforjani3
2021-03-30 18:57:10 +02:00
parent 628d483813
commit 86a36f4044
32 changed files with 203 additions and 110 deletions

View File

@@ -28,6 +28,7 @@ function ItemsEntriesTable({
errors,
onUpdateData,
linesNumber,
currencyCode,
itemType, // sellable or purchasable
}) {
const [rows, setRows] = React.useState(initialEntries);
@@ -35,13 +36,14 @@ function ItemsEntriesTable({
const [cellsLoading, setCellsLoading] = React.useState(null);
// Fetches the item details.
const { data: item, isFetching: isItemFetching, isSuccess: isItemSuccess } = useItem(
rowItem && rowItem.itemId,
{
enabled: !!(rowItem && rowItem.itemId),
},
);
const {
data: item,
isFetching: isItemFetching,
isSuccess: isItemSuccess,
} = useItem(rowItem && rowItem.itemId, {
enabled: !!(rowItem && rowItem.itemId),
});
// Once the item start loading give the table cells loading state.
useEffect(() => {
if (rowItem && isItemFetching) {
@@ -141,6 +143,7 @@ function ItemsEntriesTable({
updateData: handleUpdateData,
removeRow: handleRemoveRow,
autoFocus: ['item_id', 0],
currencyCode,
}}
/>
);

View File

@@ -8,7 +8,7 @@ import {
MoneyFieldCell,
ItemsListCell,
PercentFieldCell,
NumericInputCell
NumericInputCell,
} from 'components/DataTableCells';
/**
@@ -62,27 +62,27 @@ export function ActionsCellRenderer({
*/
export function QuantityTotalFooterCell({ rows }) {
const quantity = safeSumBy(rows, 'original.quantity');
return <span>{ quantity }</span>;
return <span>{quantity}</span>;
}
/**
* Total footer cell.
*/
export function TotalFooterCell({ rows }) {
export function TotalFooterCell({ payload: { currencyCode }, rows }) {
const total = safeSumBy(rows, 'original.total');
return <span>{ formattedAmount(total, 'USD') }</span>;
return <span>{formattedAmount(total, currencyCode)}</span>;
}
/**
* Total accessor.
*/
export function TotalCell({ value }) {
return <span>{ formattedAmount(value, 'USD', { noZero: true }) }</span>;
export function TotalCell({ payload: { currencyCode }, value }) {
return <span>{formattedAmount(value, currencyCode, { noZero: true })}</span>;
}
// Index table cell.
export function IndexTableCell({ row: { index } }){
return (<span>{index + 1}</span>);
export function IndexTableCell({ row: { index } }) {
return <span>{index + 1}</span>;
}
/**
@@ -167,4 +167,3 @@ export function useEditableItemsEntriesColumns() {
[formatMessage],
);
}