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

@@ -37,6 +37,7 @@ function PaymentReceiveForm({
paymentReceiveNextNumber,
paymentReceiveNumberPrefix,
paymentReceiveAutoIncrement,
baseCurrency,
}) {
const history = useHistory();
const { formatMessage } = useIntl();
@@ -68,6 +69,7 @@ function PaymentReceiveForm({
payment_receive_no: nextPaymentNumber,
deposit_account_id: defaultTo(preferredDepositAccount, ''),
}),
currency_code: baseCurrency,
}),
}),
[
@@ -198,11 +200,12 @@ function PaymentReceiveForm({
}
export default compose(
withSettings(({ paymentReceiveSettings }) => ({
withSettings(({ paymentReceiveSettings, organizationSettings }) => ({
paymentReceiveSettings,
paymentReceiveNextNumber: paymentReceiveSettings?.nextNumber,
paymentReceiveNumberPrefix: paymentReceiveSettings?.numberPrefix,
paymentReceiveAutoIncrement: paymentReceiveSettings?.autoIncrement,
preferredDepositAccount: paymentReceiveSettings?.depositAccount,
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentReceiveForm);

View File

@@ -11,12 +11,13 @@ export default function PaymentReceiveFormBody() {
return (
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
<FastField name={'entries'}>
{({ form, field: { value } }) => (
{({ form: { values, setFieldValue }, field: { value } }) => (
<PaymentReceiveItemsTable
entries={value}
onUpdateData={(newEntries) => {
form.setFieldValue('entries', newEntries);
setFieldValue('entries', newEntries);
}}
currencyCode={values.currency_code}
/>
)}
</FastField>

View File

@@ -15,6 +15,7 @@ import { compose, updateTableRow } from 'utils';
export default function PaymentReceiveItemsTable({
entries,
onUpdateData,
currencyCode
}) {
// Payment receive form context.
const {
@@ -52,6 +53,7 @@ export default function PaymentReceiveItemsTable({
payload={{
errors: [],
updateData: handleUpdateData,
currencyCode
}}
noResults={noResultsMessage}
footer={true}

View File

@@ -9,14 +9,14 @@ import { safeSumBy, formattedAmount } from 'utils';
* Invoice date cell.
*/
function InvoiceDateCell({ value }) {
return <span>{ moment(value).format('YYYY MMM DD') }</span>
return <span>{moment(value).format('YYYY MMM DD')}</span>;
}
/**
* Index table cell.
*/
function IndexCell({ row: { index } }) {
return (<span>{index + 1}</span>);
return <span>{index + 1}</span>;
}
/**
@@ -29,33 +29,32 @@ function InvNumberCellAccessor(row) {
/**
* Balance footer cell.
*/
function BalanceFooterCell({ rows }) {
function BalanceFooterCell({ payload: { currencyCode }, rows }) {
const total = safeSumBy(rows, 'original.amount');
return <span>{ formattedAmount(total, 'USD') }</span>;
return <span>{formattedAmount(total, currencyCode)}</span>;
}
/**
* Due amount footer cell.
*/
function DueAmountFooterCell({ rows }) {
function DueAmountFooterCell({ payload: { currencyCode }, rows }) {
const totalDueAmount = safeSumBy(rows, 'original.due_amount');
return <span>{ formattedAmount(totalDueAmount, 'USD') }</span>;
return <span>{formattedAmount(totalDueAmount, currencyCode)}</span>;
}
/**
* Payment amount footer cell.
*/
function PaymentAmountFooterCell({ rows }) {
function PaymentAmountFooterCell({ payload: { currencyCode }, rows }) {
const totalPaymentAmount = safeSumBy(rows, 'original.payment_amount');
return <span>{ formattedAmount(totalPaymentAmount, 'USD') }</span>;
return <span>{formattedAmount(totalPaymentAmount, currencyCode)}</span>;
}
/**
* Mobey table cell.
*/
function MoneyTableCell({ value }) {
return <Money amount={value} currency={"USD"} />
function MoneyTableCell({ row: { original }, value }) {
return <Money amount={value} currency={original.currency_code} />;
}
function DateFooterCell() {
@@ -77,7 +76,7 @@ export const usePaymentReceiveEntriesColumns = () => {
width: 40,
disableResizing: true,
disableSortBy: true,
className: 'index'
className: 'index',
},
{
Header: formatMessage({ id: 'Date' }),
@@ -88,7 +87,7 @@ export const usePaymentReceiveEntriesColumns = () => {
disableSortBy: true,
disableResizing: true,
width: 250,
className: 'date'
className: 'date',
},
{
Header: formatMessage({ id: 'invocie_number' }),
@@ -125,5 +124,5 @@ export const usePaymentReceiveEntriesColumns = () => {
},
],
[formatMessage],
)
}
);
};

View File

@@ -50,6 +50,7 @@ export const transformInvoicesNewPageEntries = (invoices) => [
due_amount: invoice.due_amount,
date: invoice.invoice_date,
amount: invoice.balance,
currency_code:invoice.currency_code,
payment_amount: '',
invoice_no: invoice.invoice_no,
total_payment_amount: invoice.payment_amount,