This commit is contained in:
a.bouhuolia
2021-03-08 14:53:18 +02:00
17 changed files with 39 additions and 24 deletions

View File

@@ -18,7 +18,7 @@ import { useIntl } from 'react-intl';
*/ */
export function ActionsMenu({ export function ActionsMenu({
row: { original }, row: { original },
payload: { onEdit, onDelete ,onDuplicate }, payload: { onEdit, onDelete, onDuplicate },
}) { }) {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
@@ -86,7 +86,7 @@ export function PhoneNumberAccessor(row) {
* Balance accessor. * Balance accessor.
*/ */
export function BalanceAccessor(row) { export function BalanceAccessor(row) {
return <Money amount={row.closing_balance} currency={'USD'} />; return <Money amount={row.closing_balance} currency={row.currency_code} />;
} }
/** /**

View File

@@ -35,7 +35,10 @@ function PaperTemplate({ labels: propLabels, paperData, entries }) {
defaultLabels={labels} defaultLabels={labels}
headerData={defaultValues} headerData={defaultValues}
/> />
<PaperTemplateTable tableData={updateItemsEntriesTotal(entries)} /> <PaperTemplateTable
tableData={updateItemsEntriesTotal(entries)}
currencyCode={paperData.currency_code}
/>
<PaperTemplateFooter footerData={defaultValues} /> <PaperTemplateFooter footerData={defaultValues} />
</div> </div>
</div> </div>

View File

@@ -3,7 +3,7 @@ import { TemplateHeader, TemplateContent } from '../components';
export default function PaperTemplateHeader({ export default function PaperTemplateHeader({
defaultLabels, defaultLabels,
headerData: { referenceNo, amount, dueDate, date, billedTo }, headerData: { referenceNo, amount, dueDate, date, billedTo, currency_code },
}) { }) {
return ( return (
<> <>
@@ -16,6 +16,7 @@ export default function PaperTemplateHeader({
amount={amount} amount={amount}
billedFrom={''} billedFrom={''}
dueDate={dueDate} dueDate={dueDate}
currencyCode={currency_code}
/> />
</> </>
); );

View File

@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
import { formatMessage } from 'services/intl'; import { formatMessage } from 'services/intl';
import { DataTable, Money } from 'components'; import { DataTable, Money } from 'components';
export default function DrawerTemplateTable({ tableData }) { export default function DrawerTemplateTable({ tableData, currencyCode }) {
const columns = useMemo( const columns = useMemo(
() => [ () => [
{ {
@@ -14,7 +14,7 @@ export default function DrawerTemplateTable({ tableData }) {
{ {
Header: formatMessage({ id: 'rate' }), Header: formatMessage({ id: 'rate' }),
accessor: 'rate', accessor: 'rate',
accessor: ({ rate }) => <Money amount={rate} currency={'USD'} />, accessor: ({ rate }) => <Money amount={rate} currency={currencyCode} />,
disableSortBy: true, disableSortBy: true,
width: 50, width: 50,
}, },
@@ -26,7 +26,9 @@ export default function DrawerTemplateTable({ tableData }) {
}, },
{ {
Header: formatMessage({ id: 'Total' }), Header: formatMessage({ id: 'Total' }),
accessor: ({ total }) => <Money amount={total} currency={'USD'} />, accessor: ({ total }) => (
<Money amount={total} currency={currencyCode} />
),
disableSortBy: true, disableSortBy: true,
width: 50, width: 50,
}, },

View File

@@ -36,7 +36,10 @@ export default function PaymentPaperTemplate({
defaultLabels={labels} defaultLabels={labels}
headerData={defaultValues} headerData={defaultValues}
/> />
<PaymentPaperTemplateTable tableData={entries} /> <PaymentPaperTemplateTable
tableData={entries}
currencyCode={paperData.currency_code}
/>
</div> </div>
))} ))}
</div> </div>

View File

@@ -3,7 +3,7 @@ import { TemplateHeader, TemplateContent } from '../components';
export default function PaymentPaperTemplateHeader({ export default function PaymentPaperTemplateHeader({
defaultLabels, defaultLabels,
headerData: { referenceNo, amount, date, billedTo }, headerData: { referenceNo, amount, date, billedTo, currency_code },
}) { }) {
return ( return (
<> <>
@@ -15,6 +15,7 @@ export default function PaymentPaperTemplateHeader({
referenceNo={referenceNo} referenceNo={referenceNo}
amount={amount} amount={amount}
billedFrom={''} billedFrom={''}
currency={currency_code}
/> />
</> </>
); );

View File

@@ -3,7 +3,7 @@ import moment from 'moment';
import { formatMessage } from 'services/intl'; import { formatMessage } from 'services/intl';
import { DataTable, Money } from 'components'; import { DataTable, Money } from 'components';
export default function PaymentPaperTemplateTable({ tableData }) { export default function PaymentPaperTemplateTable({ tableData, currencyCode }) {
const columns = React.useMemo( const columns = React.useMemo(
() => [ () => [
{ {
@@ -20,14 +20,14 @@ export default function PaymentPaperTemplateTable({ tableData }) {
{ {
Header: formatMessage({ id: 'invoice_amount' }), Header: formatMessage({ id: 'invoice_amount' }),
accessor: ({ invoice }) => ( accessor: ({ invoice }) => (
<Money amount={invoice.balance} currency={'USD'} /> <Money amount={invoice.balance} currency={currencyCode} />
), ),
disableSortBy: true, disableSortBy: true,
}, },
{ {
Header: formatMessage({ id: 'payment_amount' }), Header: formatMessage({ id: 'payment_amount' }),
accessor: ({ payment_amount }) => ( accessor: ({ payment_amount }) => (
<Money amount={payment_amount} currency={'USD'} /> <Money amount={payment_amount} currency={currencyCode} />
), ),
disableSortBy: true, disableSortBy: true,
}, },

View File

@@ -20,6 +20,7 @@ export const TemplateContent = ({
amount, amount,
billedFrom, billedFrom,
dueDate, dueDate,
currencyCode,
}) => ( }) => (
<div className="template__content"> <div className="template__content">
<div className="template__content__info"> <div className="template__content__info">
@@ -37,7 +38,7 @@ export const TemplateContent = ({
<div className="template__content__info"> <div className="template__content__info">
<span> {defaultLabels.amount} </span> <span> {defaultLabels.amount} </span>
<p className={'info-paragraph-amount'}> <p className={'info-paragraph-amount'}>
{<Money amount={amount} currency={'USD'} />} {<Money amount={amount} currency={currencyCode} />}
</p> </p>
</div> </div>
<div className="template__content__info"> <div className="template__content__info">

View File

@@ -89,7 +89,7 @@ export function ActionsCell(props) {
* Total amount accessor. * Total amount accessor.
*/ */
export function TotalAmountAccessor(row) { export function TotalAmountAccessor(row) {
return <Money amount={row.total_amount} currency={'USD'} />; return <Money amount={row.total_amount} currency={row.currency_code} />;
} }
/** /**

View File

@@ -58,7 +58,7 @@ export function ActionsMenu({
*/ */
export function AmountAccessor(bill) { export function AmountAccessor(bill) {
return !isBlank(bill.amount) ? ( return !isBlank(bill.amount) ? (
<Money amount={bill.amount} currency={'USD'} /> <Money amount={bill.amount} currency={bill.currency_code} />
) : ( ) : (
'' ''
); );

View File

@@ -18,7 +18,7 @@ export function DateCell({ value }) {
} }
export function AmountAccessor(row) { export function AmountAccessor(row) {
return <Money amount={row.amount} currency={'USD'} /> return <Money amount={row.amount} currency={row.currency_code} />;
} }
/** /**

View File

@@ -132,8 +132,8 @@ function DateCell({ value }) {
return moment(value).format('YYYY MMM DD'); return moment(value).format('YYYY MMM DD');
} }
function AmountAccessor(row) { function AmountAccessor({ amount, currency_code }) {
return <Money amount={row.amount} currency={'USD'} />; return <Money amount={amount} currency={currency_code} />;
} }
function ActionsCell(props) { function ActionsCell(props) {

View File

@@ -180,7 +180,7 @@ export function useInvoicesTableColumns() {
{ {
id: 'balance', id: 'balance',
Header: formatMessage({ id: 'balance' }), Header: formatMessage({ id: 'balance' }),
accessor: (r) => <Money amount={r.balance} currency={'USD'} />, accessor: (r) => <Money amount={r.balance} currency={r.currency_code} />,
width: 110, width: 110,
className: 'balance', className: 'balance',
}, },

View File

@@ -53,7 +53,7 @@ export function ActionsMenu({
* Amount accessor. * Amount accessor.
*/ */
export function AmountAccessor(row) { export function AmountAccessor(row) {
return <Money amount={row.amount} currency={'USD'} />; return <Money amount={row.amount} currency={row.currency_code} />;
} }
/** /**

View File

@@ -11,6 +11,7 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl'; import { FormattedMessage as T } from 'react-intl';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import { useHistory } from 'react-router-dom';
import classNames from 'classnames'; import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { If, Icon } from 'components'; import { If, Icon } from 'components';
@@ -20,6 +21,9 @@ import { useReceiptFormContext } from './ReceiptFormProvider';
* Receipt floating actions bar. * Receipt floating actions bar.
*/ */
export default function ReceiptFormFloatingActions() { export default function ReceiptFormFloatingActions() {
// History context.
const history = useHistory();
// Formik context. // Formik context.
const { resetForm, submitForm, isSubmitting } = useFormikContext(); const { resetForm, submitForm, isSubmitting } = useFormikContext();
@@ -63,7 +67,7 @@ export default function ReceiptFormFloatingActions() {
// Handle cancel button click. // Handle cancel button click.
const handleCancelBtnClick = (event) => { const handleCancelBtnClick = (event) => {
history.goBack();
}; };
const handleClearBtnClick = (event) => { const handleClearBtnClick = (event) => {

View File

@@ -128,7 +128,7 @@ export function useReceiptsTableColumns() {
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: formatMessage({ id: 'amount' }),
accessor: (r) => <Money amount={r.amount} currency={'USD'} />, accessor: (r) => <Money amount={r.amount} currency={r.currency_code} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
}, },

View File

@@ -84,8 +84,8 @@ export function PhoneNumberAccessor(row) {
/** /**
* Balance accessor. * Balance accessor.
*/ */
export function BalanceAccessor(row) { export function BalanceAccessor({ closing_balance, currency_code }) {
return <Money amount={row.closing_balance} currency={'USD'} />; return <Money amount={closing_balance} currency={currency_code} />;
} }
/** /**