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({
row: { original },
payload: { onEdit, onDelete ,onDuplicate },
payload: { onEdit, onDelete, onDuplicate },
}) {
const { formatMessage } = useIntl();
@@ -86,7 +86,7 @@ export function PhoneNumberAccessor(row) {
* Balance accessor.
*/
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}
headerData={defaultValues}
/>
<PaperTemplateTable tableData={updateItemsEntriesTotal(entries)} />
<PaperTemplateTable
tableData={updateItemsEntriesTotal(entries)}
currencyCode={paperData.currency_code}
/>
<PaperTemplateFooter footerData={defaultValues} />
</div>
</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -180,7 +180,7 @@ export function useInvoicesTableColumns() {
{
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,
className: 'balance',
},

View File

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

View File

@@ -128,7 +128,7 @@ export function useReceiptsTableColumns() {
{
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,
className: 'amount',
},

View File

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