feat(webapp): wip printing financial reports

This commit is contained in:
Ahmed Bouhuolia
2024-02-12 19:07:57 +02:00
parent eb4491f44a
commit d229378957
80 changed files with 1424 additions and 25 deletions

View File

@@ -57,5 +57,17 @@ export enum DialogsName {
TrialBalanceSheetPdfPreview = 'TrialBalanceSheetPdfPreview', TrialBalanceSheetPdfPreview = 'TrialBalanceSheetPdfPreview',
CashflowSheetPdfPreview = 'CashflowSheetPdfPreview', CashflowSheetPdfPreview = 'CashflowSheetPdfPreview',
ProfitLossSheetPdfPreview = 'ProfitLossSheetPdfPreview', ProfitLossSheetPdfPreview = 'ProfitLossSheetPdfPreview',
InventoryValuationPdfPreview = 'InventoryValuationPdfPreview',
APAgingSummaryPdfPreview = 'APAgingSummaryPdfPreview',
ARAgingSummaryPdfPreview = 'ARAgingSummaryPdfPreview',
JournalPdfPreview = 'JournalPdfPreview',
SalesByItemsPdfPreview = 'SalesByItemsPdfPreview',
PurchasesByItemsPdfPreview = 'PurchasesByItemsPdfPreview',
VendorBalancePdfPreview = 'VendorBalancePdfPreview',
InventoryItemDetailsPdfPreview = 'InventoryItemDetailsPdfPreview',
CustomerBalanceSummaryPdfPreview = 'CustomerBalanceSummaryPdfPreview',
CustomerTransactionsPdfPreview = 'CustomerTransactionsPdfPreview',
VendorTransactionsPdfPreview = 'VendorTransactionsPdfPreview',
GeneralLedgerPdfPreview = 'GeneralLedgerPdfPreview',
SalesTaxLiabilitySummaryPdfPreview = 'SalesTaxLiabilitySummaryPdfPreview'
} }

View File

@@ -15,6 +15,8 @@ import { APAgingSummarySheetLoadingBar } from './components';
import withAPAgingSummaryActions from './withAPAgingSummaryActions'; import withAPAgingSummaryActions from './withAPAgingSummaryActions';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { APAgingSummaryPdfDialog } from './dialogs/APAgingSummaryPdfDialog';
import { DialogsName } from '@/constants/dialogs';
/** /**
* A/P aging summary report. * A/P aging summary report.
@@ -68,6 +70,10 @@ function APAgingSummary({
<APAgingSummaryBody organizationName={organizationName} /> <APAgingSummaryBody organizationName={organizationName} />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<APAgingSummaryPdfDialog
dialogName={DialogsName.APAgingSummaryPdfPreview}
/>
</APAgingSummaryProvider> </APAgingSummaryProvider>
); );
} }

View File

@@ -21,6 +21,8 @@ import withAPAgingSummary from './withAPAgingSummary';
import withAPAgingSummaryActions from './withAPAgingSummaryActions'; import withAPAgingSummaryActions from './withAPAgingSummaryActions';
import { saveInvoke, compose } from '@/utils'; import { saveInvoke, compose } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
/** /**
* AP Aging summary sheet - Actions bar. * AP Aging summary sheet - Actions bar.
@@ -32,6 +34,9 @@ function APAgingSummaryActionsBar({
// #withARAgingSummaryActions // #withARAgingSummaryActions
toggleAPAgingSummaryFilterDrawer: toggleFilterDrawerDisplay, toggleAPAgingSummaryFilterDrawer: toggleFilterDrawerDisplay,
// #withDialogActions
openDialog,
//#ownProps //#ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
@@ -52,6 +57,11 @@ function APAgingSummaryActionsBar({
saveInvoke(onNumberFormatSubmit, numberFormat); saveInvoke(onNumberFormatSubmit, numberFormat);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.APAgingSummaryPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -106,6 +116,7 @@ function APAgingSummaryActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<APAgingSummaryExportMenu />} content={<APAgingSummaryExportMenu />}
@@ -129,4 +140,5 @@ export default compose(
withAPAgingSummary(({ APAgingSummaryFilterDrawer }) => ({ withAPAgingSummary(({ APAgingSummaryFilterDrawer }) => ({
isFilterDrawerOpen: APAgingSummaryFilterDrawer, isFilterDrawerOpen: APAgingSummaryFilterDrawer,
})), })),
withDialogActions
)(APAgingSummaryActionsBar); )(APAgingSummaryActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { APAgingSummaryPdfDialog } from './dialogs/APAgingSummaryPdfDialog';
export function APAgingSummaryDialogs() {
return (
<>
<APAgingSummaryPdfDialog
dialogName={DialogsName.APAgingSummaryPdfPreview}
/>
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const APAgingSummaryPdfDialogContent = lazy(
() => import('./APAgingSummaryPdfDialogContent'),
);
/**
* A/P aging summary pdf preview dialog.
* @returns {React.ReactNode}
*/
function APAgingSummaryPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'A/P Aging Summary Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<APAgingSummaryPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const APAgingSummaryPdfDialog = compose(withDialogRedux())(
APAgingSummaryPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useAPAgingSummaryPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function APAgingSummaryPdfDialogContent() {
const { isLoading, pdfUrl } = useAPAgingSummaryPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'AP_aging_summary.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './APAgingSummaryPdfDialog';

View File

@@ -14,6 +14,8 @@ import withARAgingSummaryActions from './withARAgingSummaryActions';
import { useARAgingSummaryQuery } from './common'; import { useARAgingSummaryQuery } from './common';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { ARAgingSummaryPdfDialog } from './dialogs/ARAgingSummaryPdfDialog';
import { DialogsName } from '@/constants/dialogs';
/** /**
* A/R aging summary report. * A/R aging summary report.
@@ -25,13 +27,16 @@ function ReceivableAgingSummarySheet({
const { query, setLocationQuery } = useARAgingSummaryQuery(); const { query, setLocationQuery } = useARAgingSummaryQuery();
// Handle filter submit. // Handle filter submit.
const handleFilterSubmit = useCallback((filter) => { const handleFilterSubmit = useCallback(
const _filter = { (filter) => {
...filter, const _filter = {
asDate: moment(filter.asDate).format('YYYY-MM-DD'), ...filter,
}; asDate: moment(filter.asDate).format('YYYY-MM-DD'),
setLocationQuery(_filter); };
}, [setLocationQuery]); setLocationQuery(_filter);
},
[setLocationQuery],
);
// Handle number format submit. // Handle number format submit.
const handleNumberFormatSubmit = (numberFormat) => { const handleNumberFormatSubmit = (numberFormat) => {
@@ -60,6 +65,10 @@ function ReceivableAgingSummarySheet({
<ARAgingSummaryBody /> <ARAgingSummaryBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<ARAgingSummaryPdfDialog
dialogName={DialogsName.ARAgingSummaryPdfPreview}
/>
</ARAgingSummaryProvider> </ARAgingSummaryProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import withARAgingSummary from './withARAgingSummary';
import { compose, safeInvoke } from '@/utils'; import { compose, safeInvoke } from '@/utils';
import { ARAgingSummaryExportMenu } from './components'; import { ARAgingSummaryExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* A/R Aging summary sheet - Actions bar. * A/R Aging summary sheet - Actions bar.
@@ -31,6 +33,9 @@ function ARAgingSummaryActionsBar({
// #withReceivableAgingActions // #withReceivableAgingActions
toggleARAgingSummaryFilterDrawer: toggleDisplayFilterDrawer, toggleARAgingSummaryFilterDrawer: toggleDisplayFilterDrawer,
// #withDialogActions
openDialog,
// #ownProps // #ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
@@ -51,6 +56,11 @@ function ARAgingSummaryActionsBar({
safeInvoke(onNumberFormatSubmit, numberFormat); safeInvoke(onNumberFormatSubmit, numberFormat);
}; };
// Handles the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.ARAgingSummaryPdfPreview)
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -107,6 +117,7 @@ function ARAgingSummaryActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<ARAgingSummaryExportMenu />} content={<ARAgingSummaryExportMenu />}
@@ -130,4 +141,5 @@ export default compose(
withARAgingSummary(({ ARAgingSummaryFilterDrawer }) => ({ withARAgingSummary(({ ARAgingSummaryFilterDrawer }) => ({
isFilterDrawerOpen: ARAgingSummaryFilterDrawer, isFilterDrawerOpen: ARAgingSummaryFilterDrawer,
})), })),
withDialogActions,
)(ARAgingSummaryActionsBar); )(ARAgingSummaryActionsBar);

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const ARAgingSummaryPdfDialogContent = lazy(
() => import('./ARAgingSummaryPdfDialogContent'),
);
/**
* Balance sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function ARAgingSummaryPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'AR Aging Summary Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<ARAgingSummaryPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const ARAgingSummaryPdfDialog = compose(withDialogRedux())(
ARAgingSummaryPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useARAgingSummaryPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function ARAgingSummaryPdfDialogContent() {
const { isLoading, pdfUrl } = useARAgingSummaryPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'AR_aging_summary.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './ARAgingSummaryPdfDialog';

View File

@@ -55,6 +55,7 @@ function BalanceSheetActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handles the pdf print button click.
const handlePdfPrintBtnSubmit = () => { const handlePdfPrintBtnSubmit = () => {
openDialog(DialogsName.BalanceSheetPdfPreview) openDialog(DialogsName.BalanceSheetPdfPreview)
} }

View File

@@ -22,7 +22,7 @@ function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
return ( return (
<Dialog <Dialog
name={dialogName} name={dialogName}
title={'Trial Balance Sheet Print Preview'} title={'Cashflow Sheet Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)} className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true} autoFocus={true}
canEscapeKeyClose={true} canEscapeKeyClose={true}
@@ -30,10 +30,7 @@ function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
style={{ width: '1000px' }} style={{ width: '1000px' }}
> >
<DialogSuspense> <DialogSuspense>
<CashflowSheetPdfDialogContent <CashflowSheetPdfDialogContent />
dialogName={dialogName}
subscriptionForm={payload}
/>
</DialogSuspense> </DialogSuspense>
</Dialog> </Dialog>
); );

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const CustomerBalanceSummaryPdfDialogContent = lazy(
() => import('./CustomerBalanceSummaryPdfDialogContent'),
);
/**
* Cashflow sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Customer Balance Summary Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<CustomerBalanceSummaryPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const CustomerBalanceSummaryPdfDialog = compose(withDialogRedux())(
CashflowSheetPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { AnchorButton } from '@blueprintjs/core';
import { useCustomerBalanceSummaryPdf } from '@/hooks/query';
export default function CustomerBalanceSummaryPdfDialogContent() {
const { isLoading, pdfUrl } = useCustomerBalanceSummaryPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './CustomerBalanceSummaryPdfDialog';

View File

@@ -13,6 +13,8 @@ import { CustomersBalanceSummaryProvider } from './CustomersBalanceSummaryProvid
import { useCustomerBalanceSummaryQuery } from './utils'; import { useCustomerBalanceSummaryQuery } from './utils';
import { CustomersBalanceLoadingBar } from './components'; import { CustomersBalanceLoadingBar } from './components';
import withCustomersBalanceSummaryActions from './withCustomersBalanceSummaryActions'; import withCustomersBalanceSummaryActions from './withCustomersBalanceSummaryActions';
import { CustomerBalanceSummaryPdfDialog } from './CustomerBalancePdfDialog';
import { DialogsName } from '@/constants/dialogs';
/** /**
* Customers Balance summary. * Customers Balance summary.
@@ -61,6 +63,10 @@ function CustomersBalanceSummary({
<CustomerBalanceSummaryBody /> <CustomerBalanceSummaryBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<CustomerBalanceSummaryPdfDialog
dialogName={DialogsName.CustomerBalanceSummaryPdfPreview}
/>
</CustomersBalanceSummaryProvider> </CustomersBalanceSummaryProvider>
); );
} }

View File

@@ -18,6 +18,8 @@ import withCustomersBalanceSummaryActions from './withCustomersBalanceSummaryAct
import { useCustomersBalanceSummaryContext } from './CustomersBalanceSummaryProvider'; import { useCustomersBalanceSummaryContext } from './CustomersBalanceSummaryProvider';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { CustomerBalanceSummaryExportMenu } from './components'; import { CustomerBalanceSummaryExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* customer balance summary action bar. * customer balance summary action bar.
@@ -32,6 +34,9 @@ function CustomersBalanceSummaryActionsBar({
//#withCustomersBalanceSummaryActions //#withCustomersBalanceSummaryActions
toggleCustomerBalanceFilterDrawer, toggleCustomerBalanceFilterDrawer,
// #withDialogActions
openDialog
}) { }) {
const { refetch, isCustomersBalanceLoading } = const { refetch, isCustomersBalanceLoading } =
useCustomersBalanceSummaryContext(); useCustomersBalanceSummaryContext();
@@ -51,6 +56,11 @@ function CustomersBalanceSummaryActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.CustomerBalanceSummaryPdfPreview);
}
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -112,6 +122,7 @@ function CustomersBalanceSummaryActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<CustomerBalanceSummaryExportMenu />} content={<CustomerBalanceSummaryExportMenu />}
@@ -134,4 +145,5 @@ export default compose(
isFilterDrawerOpen: customersBalanceDrawerFilter, isFilterDrawerOpen: customersBalanceDrawerFilter,
})), })),
withCustomersBalanceSummaryActions, withCustomersBalanceSummaryActions,
withDialogActions
)(CustomersBalanceSummaryActionsBar); )(CustomersBalanceSummaryActionsBar);

View File

@@ -14,6 +14,7 @@ import { CustomersTransactionsProvider } from './CustomersTransactionsProvider';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { useCustomersTransactionsQuery } from './_utils'; import { useCustomersTransactionsQuery } from './_utils';
import { CustomersTransactionsDialogs } from './CustomersTransactionsDialogs';
/** /**
* Customers transactions. * Customers transactions.
@@ -65,6 +66,8 @@ function CustomersTransactions({
<CustomersTransactionsBody /> <CustomersTransactionsBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<CustomersTransactionsDialogs />
</CustomersTransactionsProvider> </CustomersTransactionsProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import withCustomersTransactions from './withCustomersTransactions';
import withCustomersTransactionsActions from './withCustomersTransactionsActions'; import withCustomersTransactionsActions from './withCustomersTransactionsActions';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* Customers transactions actions bar. * Customers transactions actions bar.
@@ -34,6 +36,9 @@ function CustomersTransactionsActionsBar({
//#withCustomersTransactionsActions //#withCustomersTransactionsActions
toggleCustomersTransactionsFilterDrawer, toggleCustomersTransactionsFilterDrawer,
// #withDialogActions
openDialog
}) { }) {
const { isCustomersTransactionsLoading, CustomersTransactionsRefetch } = const { isCustomersTransactionsLoading, CustomersTransactionsRefetch } =
useCustomersTransactionsContext(); useCustomersTransactionsContext();
@@ -53,6 +58,11 @@ function CustomersTransactionsActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.CustomerTransactionsPdfPreview)
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -114,6 +124,7 @@ function CustomersTransactionsActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<CustomersTransactionsExportMenu />} content={<CustomersTransactionsExportMenu />}
@@ -137,4 +148,5 @@ export default compose(
isFilterDrawerOpen: customersTransactionsDrawerFilter, isFilterDrawerOpen: customersTransactionsDrawerFilter,
})), })),
withCustomersTransactionsActions, withCustomersTransactionsActions,
withDialogActions
)(CustomersTransactionsActionsBar); )(CustomersTransactionsActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { CustomerTransactionsPdfDialog } from './dialogs/CustomerTransactionsPdfDialog';
export function CustomersTransactionsDialogs() {
return (
<>
<CustomerTransactionsPdfDialog
dialogName={DialogsName.CustomerTransactionsPdfPreview}
/>
</>
);
}

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const CustomerTransactionsPdfDialogContent = lazy(
() => import('./CustomerTransactionsPdfDialogContent'),
);
/**
* Cashflow sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Customer Tranasctions PDF Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<CustomerTransactionsPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const CustomerTransactionsPdfDialog = compose(withDialogRedux())(
CashflowSheetPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { AnchorButton } from '@blueprintjs/core';
import { useCustomersTransactionsPdfExport } from '@/hooks/query';
export default function CashflowSheetPdfDialogContent() {
const { isLoading, pdfUrl } = useCustomersTransactionsPdfExport();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './CustomerTransactionsPdfDialog';

View File

@@ -16,6 +16,8 @@ import {
import withGeneralLedgerActions from './withGeneralLedgerActions'; import withGeneralLedgerActions from './withGeneralLedgerActions';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { GeneralLedgerPdfDialog } from './dialogs/GeneralLedgerPdfDialog';
import { DialogsName } from '@/constants/dialogs';
/** /**
* General Ledger (GL) sheet. * General Ledger (GL) sheet.
@@ -61,6 +63,10 @@ function GeneralLedger({
<GeneralLedgerBody /> <GeneralLedgerBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<GeneralLedgerPdfDialog
dialogName={DialogsName.GeneralLedgerPdfPreview}
/>
</GeneralLedgerProvider> </GeneralLedgerProvider>
); );
} }

View File

@@ -18,6 +18,8 @@ import { compose } from '@/utils';
import withGeneralLedger from './withGeneralLedger'; import withGeneralLedger from './withGeneralLedger';
import withGeneralLedgerActions from './withGeneralLedgerActions'; import withGeneralLedgerActions from './withGeneralLedgerActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* General ledger - Actions bar. * General ledger - Actions bar.
@@ -28,6 +30,9 @@ function GeneralLedgerActionsBar({
// #withGeneralLedgerActions // #withGeneralLedgerActions
toggleGeneralLedgerFilterDrawer: toggleDisplayFilterDrawer, toggleGeneralLedgerFilterDrawer: toggleDisplayFilterDrawer,
// #withDialogActions
openDialog,
}) { }) {
const { sheetRefresh } = useGeneralLedgerContext(); const { sheetRefresh } = useGeneralLedgerContext();
@@ -41,6 +46,11 @@ function GeneralLedgerActionsBar({
sheetRefresh(); sheetRefresh();
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.GeneralLedgerPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -84,6 +94,7 @@ function GeneralLedgerActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<GeneralLedgerSheetExportMenu />} content={<GeneralLedgerSheetExportMenu />}
@@ -107,4 +118,5 @@ export default compose(
isFilterDrawerOpen: generalLedgerFilterDrawer, isFilterDrawerOpen: generalLedgerFilterDrawer,
})), })),
withGeneralLedgerActions, withGeneralLedgerActions,
withDialogActions,
)(GeneralLedgerActionsBar); )(GeneralLedgerActionsBar);

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const GeneralLedgerPdfDialogContent = lazy(
() => import('./GeneralLedgerPdfDialogContent'),
);
/**
* General ledger pdf preview dialog.
* @returns {React.ReactNode}
*/
function GeneralLedgerPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'General Ledger PDF Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<GeneralLedgerPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const GeneralLedgerPdfDialog = compose(withDialogRedux())(
GeneralLedgerPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { AnchorButton } from '@blueprintjs/core';
import { useGeneralLedgerPdf } from '@/hooks/query';
export default function GeneralLedgerPdfDialogContent() {
const { isLoading, pdfUrl } = useGeneralLedgerPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './GeneralLedgerPdfDialog';

View File

@@ -15,6 +15,7 @@ import {
} from './components'; } from './components';
import { InventoryItemDetailsBody } from './InventoryItemDetailsBody'; import { InventoryItemDetailsBody } from './InventoryItemDetailsBody';
import { InventoryItemDetailsDialogs } from './InventoryItemDetailsDialogs';
import { useInventoryValuationQuery } from './utils2'; import { useInventoryValuationQuery } from './utils2';
import { compose } from '@/utils'; import { compose } from '@/utils';
@@ -64,6 +65,8 @@ function InventoryItemDetails({
<InventoryItemDetailsBody /> <InventoryItemDetailsBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<InventoryItemDetailsDialogs />
</InventoryItemDetailsProvider> </InventoryItemDetailsProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import withInventoryItemDetails from './withInventoryItemDetails';
import withInventoryItemDetailsActions from './withInventoryItemDetailsActions'; import withInventoryItemDetailsActions from './withInventoryItemDetailsActions';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
/** /**
* Inventory item details actions bar. * Inventory item details actions bar.
@@ -32,6 +34,9 @@ function InventoryItemDetailsActionsBar({
//#withInventoryItemDetails //#withInventoryItemDetails
isFilterDrawerOpen, isFilterDrawerOpen,
// #withDialogActions
openDialog,
//#withInventoryItemDetailsActions //#withInventoryItemDetailsActions
toggleInventoryItemDetailsFilterDrawer: toggleFilterDrawer, toggleInventoryItemDetailsFilterDrawer: toggleFilterDrawer,
}) { }) {
@@ -50,7 +55,10 @@ function InventoryItemDetailsActionsBar({
const handleNumberFormatSubmit = (values) => { const handleNumberFormatSubmit = (values) => {
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.InventoryItemDetailsPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -112,6 +120,7 @@ function InventoryItemDetailsActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<InventoryItemDetailsExportMenu />} content={<InventoryItemDetailsExportMenu />}
@@ -135,4 +144,5 @@ export default compose(
isFilterDrawerOpen: inventoryItemDetailDrawerFilter, isFilterDrawerOpen: inventoryItemDetailDrawerFilter,
})), })),
withInventoryItemDetailsActions, withInventoryItemDetailsActions,
withDialogActions,
)(InventoryItemDetailsActionsBar); )(InventoryItemDetailsActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { InventoryItemDetailsPdfDialog } from './dialogs/InventoryItemDetailsPdfDialog';
export function InventoryItemDetailsDialogs() {
return (
<>
<InventoryItemDetailsPdfDialog
dialogName={DialogsName.InventoryItemDetailsPdfPreview}
/>
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const InventoryItemDetailsPdfDialogContent = lazy(
() => import('./InventoryItemDetailsPdfDialogContent'),
);
/**
* Inventory item details sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function InventoryItemDetailsPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Inventory Item Details Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<InventoryItemDetailsPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const InventoryItemDetailsPdfDialog = compose(withDialogRedux())(
InventoryItemDetailsPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useInventoryItemDetailsPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function InventoryItemDetailsPdfDialogContent() {
const { isLoading, pdfUrl } = useInventoryItemDetailsPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './InventoryItemDetailsPdfDialog';

View File

@@ -1,5 +1,5 @@
// @ts-nocheck // @ts-nocheck
import React, { useEffect, useState, useCallback } from 'react'; import { useEffect, useCallback } from 'react';
import moment from 'moment'; import moment from 'moment';
import { DashboardPageContent } from '@/components'; import { DashboardPageContent } from '@/components';
@@ -14,6 +14,7 @@ import { compose } from '@/utils';
import withInventoryValuationActions from './withInventoryValuationActions'; import withInventoryValuationActions from './withInventoryValuationActions';
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization'; import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
import { InventoryValuationDialogs } from './InventoryValuationDialogs';
/** /**
* Inventory valuation. * Inventory valuation.
@@ -65,6 +66,8 @@ function InventoryValuation({
/> />
<InventoryValuationBody /> <InventoryValuationBody />
</DashboardPageContent> </DashboardPageContent>
<InventoryValuationDialogs />
</InventoryValuationProvider> </InventoryValuationProvider>
); );
} }

View File

@@ -16,10 +16,12 @@ import NumberFormatDropdown from '@/components/NumberFormatDropdown';
import withInventoryValuation from './withInventoryValuation'; import withInventoryValuation from './withInventoryValuation';
import withInventoryValuationActions from './withInventoryValuationActions'; import withInventoryValuationActions from './withInventoryValuationActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useInventoryValuationContext } from './InventoryValuationProvider'; import { useInventoryValuationContext } from './InventoryValuationProvider';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { InventoryValuationExportMenu } from './components'; import { InventoryValuationExportMenu } from './components';
import { DialogsName } from '@/constants/dialogs';
function InventoryValuationActionsBar({ function InventoryValuationActionsBar({
// #withInventoryValuation // #withInventoryValuation
@@ -28,27 +30,35 @@ function InventoryValuationActionsBar({
// #withInventoryValuationActions // #withInventoryValuationActions
toggleInventoryValuationFilterDrawer, toggleInventoryValuationFilterDrawer,
// #withDialogActions
openDialog,
// #ownProps // #ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
}) { }) {
const { refetchSheet, isLoading } = useInventoryValuationContext(); const { refetchSheet, isLoading } = useInventoryValuationContext();
// Handle filter toggle click. // Handles filter toggle click.
const handleFilterToggleClick = () => { const handleFilterToggleClick = () => {
toggleInventoryValuationFilterDrawer(); toggleInventoryValuationFilterDrawer();
}; };
// Handle re-calc button click. // Handles re-calc button click.
const handleRecalculateReport = () => { const handleRecalculateReport = () => {
refetchSheet(); refetchSheet();
}; };
// Handle number format submit. // Handles number format submit.
const handleNumberFormatSubmit = (numberFormat) => { const handleNumberFormatSubmit = (numberFormat) => {
saveInvoke(onNumberFormatSubmit, numberFormat); saveInvoke(onNumberFormatSubmit, numberFormat);
}; };
// Handles the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.InventoryValuationPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -109,6 +119,7 @@ function InventoryValuationActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<InventoryValuationExportMenu />} content={<InventoryValuationExportMenu />}
@@ -132,4 +143,5 @@ export default compose(
isFilterDrawerOpen: inventoryValuationDrawerFilter, isFilterDrawerOpen: inventoryValuationDrawerFilter,
})), })),
withInventoryValuationActions, withInventoryValuationActions,
withDialogActions,
)(InventoryValuationActionsBar); )(InventoryValuationActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { InventoryValuationPdfDialog } from './dialogs/InventoryValuationPdfDialog';
export function InventoryValuationDialogs() {
return (
<>
<InventoryValuationPdfDialog
dialogName={DialogsName.InventoryValuationPdfPreview}
/>
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const InventoryValuationPdfDialogContent = lazy(
() => import('./InventoryValuationSheetPdfDialogContent'),
);
/**
* Inventory valuation sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function InventoryValuationSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Inventory Valuation Sheet Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<InventoryValuationPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const InventoryValuationPdfDialog = compose(withDialogRedux())(
InventoryValuationSheetPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useInventoryValuationPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function InventoryValuationPdfDialogContent() {
const { isLoading, pdfUrl } = useInventoryValuationPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './InventoryValuationSheetPdfDialog';

View File

@@ -15,6 +15,7 @@ import withJournalActions from './withJournalActions';
import { useJournalQuery } from './utils'; import { useJournalQuery } from './utils';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { JournalDialogs } from './JournalDialogs';
/** /**
* Journal sheet. * Journal sheet.
@@ -23,7 +24,7 @@ function Journal({
// #withJournalActions // #withJournalActions
toggleJournalSheetFilter, toggleJournalSheetFilter,
}) { }) {
const {query, setLocationQuery} = useJournalQuery(); const { query, setLocationQuery } = useJournalQuery();
// Handle financial statement filter change. // Handle financial statement filter change.
const handleFilterSubmit = useCallback( const handleFilterSubmit = useCallback(
@@ -60,6 +61,8 @@ function Journal({
<JournalBody /> <JournalBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<JournalDialogs />
</JournalSheetProvider> </JournalSheetProvider>
); );
} }

View File

@@ -19,6 +19,8 @@ import withJournal from './withJournal';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { useJournalSheetContext } from './JournalProvider'; import { useJournalSheetContext } from './JournalProvider';
import { JournalSheetExportMenu } from './components'; import { JournalSheetExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* Journal sheeet - Actions bar. * Journal sheeet - Actions bar.
@@ -29,6 +31,9 @@ function JournalActionsBar({
// #withJournalActions // #withJournalActions
toggleJournalSheetFilter, toggleJournalSheetFilter,
// #withDialogActions
openDialog,
}) { }) {
const { refetchSheet } = useJournalSheetContext(); const { refetchSheet } = useJournalSheetContext();
@@ -42,6 +47,11 @@ function JournalActionsBar({
refetchSheet(); refetchSheet();
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.JournalPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -85,6 +95,7 @@ function JournalActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<JournalSheetExportMenu />} content={<JournalSheetExportMenu />}
@@ -108,4 +119,5 @@ export default compose(
isFilterDrawerOpen: journalSheetDrawerFilter, isFilterDrawerOpen: journalSheetDrawerFilter,
})), })),
withJournalActions, withJournalActions,
withDialogActions,
)(JournalActionsBar); )(JournalActionsBar);

View File

@@ -0,0 +1,10 @@
import { DialogsName } from '@/constants/dialogs';
import { JournalPdfDialog } from './dialogs/JournalPdfDialog';
export function JournalDialogs() {
return (
<>
<JournalPdfDialog dialogName={DialogsName.JournalPdfPreview} />
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const JournalPdfDialogContent = lazy(
() => import('./JournalPdfDialogContent'),
);
/**
* Journal sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function JournalPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Journal Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<JournalPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const JournalPdfDialog = compose(withDialogRedux())(
JournalPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useJournalSheetPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function JournalSheetPdfDialogContent() {
const { isLoading, pdfUrl } = useJournalSheetPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'journal.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './JournalPdfDialog';

View File

@@ -3,8 +3,10 @@ import { ProfitLossSheetPdfDialog } from './ProfitLossSheetPdfDialog';
export function ProfitLossSheetDialogs() { export function ProfitLossSheetDialogs() {
return ( return (
<ProfitLossSheetPdfDialog <>
dialogName={DialogsName.ProfitLossSheetPdfPreview} <ProfitLossSheetPdfDialog
/> dialogName={DialogsName.ProfitLossSheetPdfPreview}
/>
</>
); );
} }

View File

@@ -23,7 +23,7 @@ export default function ProfitLossSheetPdfDialogContent() {
<AnchorButton <AnchorButton
href={pdfUrl} href={pdfUrl}
download={'invoice.pdf'} download={'profit_loss_sheet.pdf'}
minimal={true} minimal={true}
outlined={true} outlined={true}
> >

View File

@@ -13,6 +13,7 @@ import { usePurchasesByItemsQuery } from './utils';
import { compose } from '@/utils'; import { compose } from '@/utils';
import withPurchasesByItemsActions from './withPurchasesByItemsActions'; import withPurchasesByItemsActions from './withPurchasesByItemsActions';
import { PurchasesByItemsDialogs } from './PurchasesByItemsDialogs';
/** /**
* Purchases by items. * Purchases by items.
@@ -67,6 +68,8 @@ function PurchasesByItems({
<PurchasesByItemsBody /> <PurchasesByItemsBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<PurchasesByItemsDialogs />
</PurchasesByItemsProvider> </PurchasesByItemsProvider>
); );
} }

View File

@@ -16,9 +16,11 @@ import NumberFormatDropdown from '@/components/NumberFormatDropdown';
import withPurchasesByItems from './withPurchasesByItems'; import withPurchasesByItems from './withPurchasesByItems';
import withPurchasesByItemsActions from './withPurchasesByItemsActions'; import withPurchasesByItemsActions from './withPurchasesByItemsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { usePurchaseByItemsContext } from './PurchasesByItemsProvider'; import { usePurchaseByItemsContext } from './PurchasesByItemsProvider';
import { PurchasesByItemsExportMenu } from './components'; import { PurchasesByItemsExportMenu } from './components';
import { DialogsName } from '@/constants/dialogs';
function PurchasesByItemsActionsBar({ function PurchasesByItemsActionsBar({
// #withPurchasesByItems // #withPurchasesByItems
@@ -27,6 +29,9 @@ function PurchasesByItemsActionsBar({
// #withPurchasesByItemsActions // #withPurchasesByItemsActions
togglePurchasesByItemsFilterDrawer, togglePurchasesByItemsFilterDrawer,
// #withDialogActions
openDialog,
// #ownProps // #ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
@@ -48,6 +53,11 @@ function PurchasesByItemsActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.PurchasesByItemsPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -106,6 +116,7 @@ function PurchasesByItemsActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<PurchasesByItemsExportMenu />} content={<PurchasesByItemsExportMenu />}
@@ -129,4 +140,5 @@ export default compose(
purchasesByItemsDrawerFilter, purchasesByItemsDrawerFilter,
})), })),
withPurchasesByItemsActions, withPurchasesByItemsActions,
withDialogActions,
)(PurchasesByItemsActionsBar); )(PurchasesByItemsActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { PurchasesByItemsPdfDialog } from './dialogs/PurchasesByItemsDialog';
export function PurchasesByItemsDialogs() {
return (
<>
<PurchasesByItemsPdfDialog
dialogName={DialogsName.PurchasesByItemsPdfPreview}
/>
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const PurchasesByItemsPdfDialogContent = lazy(
() => import('./PurchasesByItemsPdfDialogContent'),
);
/**
* Purchases by items sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function PurchasesByItemsPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Purchases By Items Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<PurchasesByItemsPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const PurchasesByItemsPdfDialog = compose(withDialogRedux())(
PurchasesByItemsPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import { AnchorButton } from '@blueprintjs/core';
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { usePurchasesByItemsPdfExport } from '@/hooks/query';
export default function PurchasesByItemsPdfDialogContent() {
const { isLoading, pdfUrl } = usePurchasesByItemsPdfExport();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './PurchasesByItemsPdfDialog';

View File

@@ -13,6 +13,7 @@ import withSalesByItemsActions from './withSalesByItemsActions';
import { useSalesByItemsQuery } from './utils'; import { useSalesByItemsQuery } from './utils';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { SalesByItemsDialogs } from './SalesByitemsDialogs';
/** /**
* Sales by items. * Sales by items.
@@ -66,6 +67,8 @@ function SalesByItems({
<SalesByItemsBody /> <SalesByItemsBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<SalesByItemsDialogs />
</SalesByItemProvider> </SalesByItemProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import withSalesByItemsActions from './withSalesByItemsActions';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { useSalesByItemsContext } from './SalesByItemProvider'; import { useSalesByItemsContext } from './SalesByItemProvider';
import { SalesByItemsSheetExportMenu } from './components'; import { SalesByItemsSheetExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
function SalesByItemsActionsBar({ function SalesByItemsActionsBar({
// #withSalesByItems // #withSalesByItems
@@ -28,6 +30,9 @@ function SalesByItemsActionsBar({
// #withSalesByItemsActions // #withSalesByItemsActions
toggleSalesByItemsFilterDrawer, toggleSalesByItemsFilterDrawer,
// #withDialogActions
openDialog,
// #ownProps // #ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
@@ -48,6 +53,11 @@ function SalesByItemsActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.SalesByItemsPdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -108,6 +118,7 @@ function SalesByItemsActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<SalesByItemsSheetExportMenu />} content={<SalesByItemsSheetExportMenu />}
@@ -131,4 +142,5 @@ export default compose(
salesByItemsDrawerFilter, salesByItemsDrawerFilter,
})), })),
withSalesByItemsActions, withSalesByItemsActions,
withDialogActions,
)(SalesByItemsActionsBar); )(SalesByItemsActionsBar);

View File

@@ -0,0 +1,10 @@
import { DialogsName } from '@/constants/dialogs';
import { SalesByItemsPdfDialog } from './dialogs/SalesByItemsPdfDialog';
export function SalesByItemsDialogs() {
return (
<>
<SalesByItemsPdfDialog dialogName={DialogsName.SalesByItemsPdfPreview} />
</>
);
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const SalesByItemsPdfDialogContent = lazy(
() => import('./SalesByItemsPdfDialogContent'),
);
/**
* Sales by items sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function SalesByItemsPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Sales By Items Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<SalesByItemsPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const SalesByItemsPdfDialog = compose(withDialogRedux())(
SalesByItemsPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useSalesByItemsPdfExport } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function SalesByItemsPdfDialogContent() {
const { isLoading, pdfUrl } = useSalesByItemsPdfExport();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'sales_by_items.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './SalesByItemsPdfDialog';

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const SalesTaxLiabilityPdfDialogContent = lazy(
() => import('./SalesTaxLiabilityPdfDialogContent'),
);
/**
* Cashflow sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function SalesTaxLiabilityPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Sales Tax Liability Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<SalesTaxLiabilityPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const SalesTaxLiabiltiyPdfDialog = compose(withDialogRedux())(
SalesTaxLiabilityPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { AnchorButton } from '@blueprintjs/core';
import { useSalesTaxLiabilitySummaryPdf } from '@/hooks/query';
export default function SalesTaxLiabilityPdfDialogContent() {
const { isLoading, pdfUrl } = useSalesTaxLiabilitySummaryPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'profit_loss_sheet.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './SalesTaxLiabilityPdfDialog';

View File

@@ -10,8 +10,10 @@ import SalesTaxLiabilitySummaryActionsBar from './SalesTaxLiabilitySummaryAction
import { SalesTaxLiabilitySummaryBoot } from './SalesTaxLiabilitySummaryBoot'; import { SalesTaxLiabilitySummaryBoot } from './SalesTaxLiabilitySummaryBoot';
import { SalesTaxLiabilitySummaryBody } from './SalesTaxLiabilitySummaryBody'; import { SalesTaxLiabilitySummaryBody } from './SalesTaxLiabilitySummaryBody';
import { useSalesTaxLiabilitySummaryQuery } from './utils'; import { useSalesTaxLiabilitySummaryQuery } from './utils';
import { SalesTaxLiabiltiyPdfDialog } from './SalesTaxLiabilityPdfDialog';
import withSalesTaxLiabilitySummaryActions from './withSalesTaxLiabilitySummaryActions'; import withSalesTaxLiabilitySummaryActions from './withSalesTaxLiabilitySummaryActions';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
/** /**
* Sales tax liability summary. * Sales tax liability summary.
@@ -63,6 +65,10 @@ function SalesTaxLiabilitySummary({
<SalesTaxLiabilitySummaryBody /> <SalesTaxLiabilitySummaryBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<SalesTaxLiabiltiyPdfDialog
dialogName={DialogsName.SalesTaxLiabilitySummaryPdfPreview}
/>
</SalesTaxLiabilitySummaryBoot> </SalesTaxLiabilitySummaryBoot>
); );
} }

View File

@@ -19,6 +19,8 @@ import { useSalesTaxLiabilitySummaryContext } from './SalesTaxLiabilitySummaryBo
import withSalesTaxLiabilitySummary from './withSalesTaxLiabilitySummary'; import withSalesTaxLiabilitySummary from './withSalesTaxLiabilitySummary';
import withSalesTaxLiabilitySummaryActions from './withSalesTaxLiabilitySummaryActions'; import withSalesTaxLiabilitySummaryActions from './withSalesTaxLiabilitySummaryActions';
import { SalesTaxLiabilityExportMenu } from './components'; import { SalesTaxLiabilityExportMenu } from './components';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
/** /**
* Sales tax liability summary - actions bar. * Sales tax liability summary - actions bar.
@@ -30,6 +32,9 @@ function SalesTaxLiabilitySummaryActionsBar({
// #withSalesTaxLiabilitySummaryActions // #withSalesTaxLiabilitySummaryActions
toggleSalesTaxLiabilitySummaryFilterDrawer: toggleFilterDrawer, toggleSalesTaxLiabilitySummaryFilterDrawer: toggleFilterDrawer,
// #withDialogActions
openDialog,
// #ownProps // #ownProps
numberFormat, numberFormat,
onNumberFormatSubmit, onNumberFormatSubmit,
@@ -49,6 +54,11 @@ function SalesTaxLiabilitySummaryActionsBar({
const handleNumberFormatSubmit = (values) => { const handleNumberFormatSubmit = (values) => {
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.SalesTaxLiabilitySummaryPdfPreview)
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
@@ -113,6 +123,7 @@ function SalesTaxLiabilitySummaryActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<SalesTaxLiabilityExportMenu />} content={<SalesTaxLiabilityExportMenu />}
@@ -136,4 +147,5 @@ export default compose(
salesTaxLiabilitySummaryFilter, salesTaxLiabilitySummaryFilter,
})), })),
withSalesTaxLiabilitySummaryActions, withSalesTaxLiabilitySummaryActions,
withDialogActions
)(SalesTaxLiabilitySummaryActionsBar); )(SalesTaxLiabilitySummaryActionsBar);

View File

@@ -23,7 +23,7 @@ export default function TrialBalanceSheetPdfDialogContent() {
<AnchorButton <AnchorButton
href={pdfUrl} href={pdfUrl}
download={'invoice.pdf'} download={'trial_balance_sheet.pdf'}
minimal={true} minimal={true}
outlined={true} outlined={true}
> >

View File

@@ -0,0 +1,10 @@
import { DialogsName } from '@/constants/dialogs';
import { VendorBalancePdfDialog } from './dialogs/VendorBalancePdfDialog';
export function VendorBalanceDialogs() {
return (
<>
<VendorBalancePdfDialog dialogName={DialogsName.VendorBalancePdfPreview} />
</>
);
}

View File

@@ -1,5 +1,5 @@
// @ts-nocheck // @ts-nocheck
import React, { useEffect, useState } from 'react'; import React, { useEffect } from 'react';
import moment from 'moment'; import moment from 'moment';
import { FinancialStatement, DashboardPageContent } from '@/components'; import { FinancialStatement, DashboardPageContent } from '@/components';
@@ -14,6 +14,7 @@ import { VendorBalanceSummaryBody } from './VendorsBalanceSummaryBody';
import withVendorsBalanceSummaryActions from './withVendorsBalanceSummaryActions'; import withVendorsBalanceSummaryActions from './withVendorsBalanceSummaryActions';
import { useVendorsBalanceSummaryQuery } from './utils'; import { useVendorsBalanceSummaryQuery } from './utils';
import { VendorBalanceDialogs } from './VendorBalanceDialogs';
import { compose } from '@/utils'; import { compose } from '@/utils';
/** /**
@@ -64,6 +65,8 @@ function VendorsBalanceSummary({
<VendorBalanceSummaryBody /> <VendorBalanceSummaryBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<VendorBalanceDialogs />
</VendorsBalanceSummaryProvider> </VendorsBalanceSummaryProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import { useVendorsBalanceSummaryContext } from './VendorsBalanceSummaryProvider
import { saveInvoke, compose } from '@/utils'; import { saveInvoke, compose } from '@/utils';
import { VendorSummarySheetExportMenu } from './components'; import { VendorSummarySheetExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* Vendors balance summary action bar. * Vendors balance summary action bar.
@@ -34,6 +36,9 @@ function VendorsBalanceSummaryActionsBar({
// #withVendorsBalanceSummaryActions // #withVendorsBalanceSummaryActions
toggleVendorSummaryFilterDrawer, toggleVendorSummaryFilterDrawer,
// #withDialogActions
openDialog,
}) { }) {
const { isVendorsBalanceLoading, refetch } = const { isVendorsBalanceLoading, refetch } =
useVendorsBalanceSummaryContext(); useVendorsBalanceSummaryContext();
@@ -52,6 +57,11 @@ function VendorsBalanceSummaryActionsBar({
saveInvoke(onNumberFormatSubmit, numberFormat); saveInvoke(onNumberFormatSubmit, numberFormat);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.VendorBalancePdfPreview);
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -106,6 +116,7 @@ function VendorsBalanceSummaryActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<VendorSummarySheetExportMenu />} content={<VendorSummarySheetExportMenu />}
@@ -128,4 +139,5 @@ export default compose(
withVendorsBalanceSummary(({ VendorsSummaryFilterDrawer }) => ({ withVendorsBalanceSummary(({ VendorsSummaryFilterDrawer }) => ({
isFilterDrawerOpen: VendorsSummaryFilterDrawer, isFilterDrawerOpen: VendorsSummaryFilterDrawer,
})), })),
withDialogActions,
)(VendorsBalanceSummaryActionsBar); )(VendorsBalanceSummaryActionsBar);

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const VendorBalancePdfDialogContent = lazy(
() => import('./VendorBalancePdfDialogContent'),
);
/**
* Vendor balance sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function VendorBalancePdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Vendor Balance Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<VendorBalancePdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const VendorBalancePdfDialog = compose(withDialogRedux())(
VendorBalancePdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useVendorBalanceSummaryPdfExport } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function VendorTransactionsPdfDialogContent() {
const { isLoading, pdfUrl } = useVendorBalanceSummaryPdfExport();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './VendorBalancePdfDialog';

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { VendorTransactionsPdfDialog } from './dialogs/VendorTransactionsPdfDialog';
export function VendorTransactionsDialogs() {
return (
<>
<VendorTransactionsPdfDialog
dialogName={DialogsName.VendorTransactionsPdfPreview}
/>
</>
);
}

View File

@@ -14,6 +14,7 @@ import withVendorsTransactionsActions from './withVendorsTransactionsActions';
import { compose } from '@/utils'; import { compose } from '@/utils';
import { useVendorsTransactionsQuery } from './_utils'; import { useVendorsTransactionsQuery } from './_utils';
import { VendorBalanceDialogs } from '../VendorsBalanceSummary/VendorBalanceDialogs';
/** /**
* Vendors transactions. * Vendors transactions.
@@ -65,6 +66,8 @@ function VendorsTransactions({
<VendorsTransactionsBody /> <VendorsTransactionsBody />
</FinancialStatement> </FinancialStatement>
</DashboardPageContent> </DashboardPageContent>
<VendorBalanceDialogs />
</VendorsTransactionsProvider> </VendorsTransactionsProvider>
); );
} }

View File

@@ -20,6 +20,8 @@ import withVendorsTransactionsActions from './withVendorsTransactionsActions';
import { compose, saveInvoke } from '@/utils'; import { compose, saveInvoke } from '@/utils';
import { VendorTransactionsExportMenu } from './components'; import { VendorTransactionsExportMenu } from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/** /**
* vendors transactions actions bar. * vendors transactions actions bar.
@@ -34,6 +36,9 @@ function VendorsTransactionsActionsBar({
//#withVendorsTransactionsActions //#withVendorsTransactionsActions
toggleVendorsTransactionsFilterDrawer, toggleVendorsTransactionsFilterDrawer,
//#withDialogActions
openDialog
}) { }) {
const { isVendorsTransactionsLoading, refetch } = const { isVendorsTransactionsLoading, refetch } =
useVendorsTransactionsContext(); useVendorsTransactionsContext();
@@ -53,6 +58,11 @@ function VendorsTransactionsActionsBar({
saveInvoke(onNumberFormatSubmit, values); saveInvoke(onNumberFormatSubmit, values);
}; };
// Handle the print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.VendorTransactionsPdfPreview)
}
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
<NavbarGroup> <NavbarGroup>
@@ -114,6 +124,7 @@ function VendorsTransactionsActionsBar({
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />} icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />} text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/> />
<Popover <Popover
content={<VendorTransactionsExportMenu />} content={<VendorTransactionsExportMenu />}
@@ -136,4 +147,5 @@ export default compose(
isFilterDrawerOpen: vendorsTransactionsDrawerFilter, isFilterDrawerOpen: vendorsTransactionsDrawerFilter,
})), })),
withVendorsTransactionsActions, withVendorsTransactionsActions,
withDialogActions
)(VendorsTransactionsActionsBar); )(VendorsTransactionsActionsBar);

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
import React, { lazy } from 'react';
import classNames from 'classnames';
import { Dialog, DialogSuspense } from '@/components';
import withDialogRedux from '@/components/DialogReduxConnect';
import { CLASSES } from '@/constants/classes';
import { compose } from '@/utils';
// Lazy loading the content.
const InventoryValuationPdfDialogContent = lazy(
() => import('./VendorTransactionsPdfDialogContent'),
);
/**
* Balance sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function VendorTransactionsPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Vendor Transactions Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<InventoryValuationPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const VendorTransactionsPdfDialog = compose(withDialogRedux())(
VendorTransactionsPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useTransactionsByVendorsPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function VendorTransactionsPdfDialogContent() {
const { isLoading, pdfUrl } = useTransactionsByVendorsPdf();
return (
<DialogContent>
<div className="dialog__header-actions">
<AnchorButton
href={pdfUrl}
target={'__blank'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.preview.button'} />
</AnchorButton>
<AnchorButton
href={pdfUrl}
download={'invoice.pdf'}
minimal={true}
outlined={true}
>
<T id={'pdf_preview.download.button'} />
</AnchorButton>
</div>
<PdfDocumentPreview
height={760}
width={1000}
isLoading={isLoading}
url={pdfUrl}
/>
</DialogContent>
);
}

View File

@@ -0,0 +1 @@
export * from './VendorTransactionsPdfDialog';