mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
Merge branch 'master' of https://github.com/abouolia/Ratteb
This commit is contained in:
@@ -20,14 +20,14 @@ import { ERROR } from 'common/errors';
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
import { compose, orderingLinesIndexes, safeSumBy } from 'utils';
|
||||
import { defaultBill, transformToEditForm } from './utils';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
|
||||
/**
|
||||
* Bill form.
|
||||
*/
|
||||
function BillForm({
|
||||
// #withSettings
|
||||
baseCurrency,
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
@@ -41,14 +41,14 @@ function BillForm({
|
||||
...(!isEmpty(bill)
|
||||
? {
|
||||
...transformToEditForm(bill),
|
||||
currency_code: baseCurrency,
|
||||
currency_code: base_currency,
|
||||
}
|
||||
: {
|
||||
...defaultBill,
|
||||
currency_code: baseCurrency,
|
||||
currency_code: base_currency,
|
||||
}),
|
||||
}),
|
||||
[bill, baseCurrency],
|
||||
[bill, base_currency],
|
||||
);
|
||||
|
||||
// Transform response error to fields.
|
||||
@@ -142,8 +142,4 @@ function BillForm({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillForm);
|
||||
export default compose(withCurrentOrganization())(BillForm);
|
||||
|
||||
@@ -8,22 +8,24 @@ import { CLASSES } from 'common/classes';
|
||||
|
||||
import BillFormHeaderFields from './BillFormHeaderFields';
|
||||
import { PageFormBigNumber } from 'components';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
|
||||
import { compose } from 'redux';
|
||||
|
||||
/**
|
||||
* Fill form header.
|
||||
*/
|
||||
function BillFormHeader({
|
||||
// #withSettings
|
||||
baseCurrency,
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
}) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of bill entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'amount'), [
|
||||
values.entries,
|
||||
]);
|
||||
const totalDueAmount = useMemo(
|
||||
() => sumBy(values.entries, 'amount'),
|
||||
[values.entries],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
@@ -31,13 +33,9 @@ function BillFormHeader({
|
||||
<PageFormBigNumber
|
||||
label={intl.get('due_amount')}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={baseCurrency}
|
||||
currencyCode={base_currency}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillFormHeader);
|
||||
export default compose(withCurrentOrganization())(BillFormHeader);
|
||||
|
||||
@@ -12,7 +12,6 @@ import BillsEmptyStatus from './BillsEmptyStatus';
|
||||
|
||||
import withBills from './withBills';
|
||||
import withBillActions from './withBillsActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
@@ -34,7 +33,7 @@ function BillsDataTable({
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
@@ -88,6 +87,11 @@ function BillsDataTable({
|
||||
openDrawer('bill-drawer', { billId: id });
|
||||
};
|
||||
|
||||
// Handle cell click.
|
||||
const handleCellClick = (cell, event) => {
|
||||
openDrawer('bill-drawer', { billId: cell.row.original.id });
|
||||
};
|
||||
|
||||
if (isEmptyStatus) {
|
||||
return <BillsEmptyStatus />;
|
||||
}
|
||||
@@ -111,6 +115,7 @@ function BillsDataTable({
|
||||
TableLoadingRenderer={TableSkeletonRows}
|
||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||
ContextMenu={ActionsMenu}
|
||||
onCellClick={handleCellClick}
|
||||
payload={{
|
||||
onDelete: handleDeleteBill,
|
||||
onEdit: handleEditBill,
|
||||
@@ -130,7 +135,4 @@ export default compose(
|
||||
withAlertsActions,
|
||||
withDrawerActions,
|
||||
withDialogActions,
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillsDataTable);
|
||||
|
||||
@@ -159,6 +159,7 @@ export function useBillsTableColumns() {
|
||||
accessor: (r) => moment(r.bill_date).format('YYYY MMM DD'),
|
||||
width: 110,
|
||||
className: 'bill_date',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'vendor',
|
||||
@@ -166,6 +167,7 @@ export function useBillsTableColumns() {
|
||||
accessor: 'vendor.display_name',
|
||||
width: 180,
|
||||
className: 'vendor',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'bill_number',
|
||||
@@ -173,6 +175,7 @@ export function useBillsTableColumns() {
|
||||
accessor: (row) => (row.bill_number ? `#${row.bill_number}` : null),
|
||||
width: 100,
|
||||
className: 'bill_number',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'amount',
|
||||
@@ -180,6 +183,7 @@ export function useBillsTableColumns() {
|
||||
accessor: AmountAccessor,
|
||||
width: 120,
|
||||
className: 'amount',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
@@ -187,6 +191,7 @@ export function useBillsTableColumns() {
|
||||
accessor: StatusAccessor,
|
||||
width: 160,
|
||||
className: 'status',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'due_date',
|
||||
@@ -194,6 +199,7 @@ export function useBillsTableColumns() {
|
||||
accessor: (r) => moment(r.due_date).format('YYYY MMM DD'),
|
||||
width: 110,
|
||||
className: 'due_date',
|
||||
clickable: true,
|
||||
},
|
||||
{
|
||||
id: 'reference_no',
|
||||
@@ -201,6 +207,7 @@ export function useBillsTableColumns() {
|
||||
accessor: 'reference_no',
|
||||
width: 90,
|
||||
className: 'reference_no',
|
||||
clickable: true,
|
||||
},
|
||||
],
|
||||
[],
|
||||
|
||||
Reference in New Issue
Block a user