diff --git a/packages/webapp/src/hooks/query/FinancialReports/index.ts b/packages/webapp/src/hooks/query/FinancialReports/index.ts new file mode 100644 index 000000000..74097ca99 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/index.ts @@ -0,0 +1,18 @@ +export * from './use-balance-sheet'; +export * from './use-trial-balance-sheet'; +export * from './use-cashflow-sheet'; +export * from './use-profit-loss-sheet'; +export * from './use-general-ledger'; +export * from './use-journal-sheet'; +export * from './use-AP-aging-summary'; +export * from './use-AR-aging-summary'; +export * from './use-inventory-valuation'; +export * from './use-inventory-item-details'; +export * from './use-purchases-by-items'; +export * from './use-sales-by-items'; +export * from './use-customer-balance-summary'; +export * from './use-vendor-balance-summary'; +export * from './use-customer-transactions'; +export * from './use-vendor-transactions'; +export * from './use-sales-tax-liabilities-summary'; +export * from './use-transactions-by-reference'; \ No newline at end of file diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-AP-aging-summary.ts b/packages/webapp/src/hooks/query/FinancialReports/use-AP-aging-summary.ts new file mode 100644 index 000000000..734b401ac --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-AP-aging-summary.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve A/P aging summary report. + */ +export function useAPAgingSummaryReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.AP_AGING_SUMMARY, query], + { + method: 'get', + url: '/financial_statements/payable_aging_summary', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useAPAgingSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/payable_aging_summary', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'payable_aging_summary.xlsx', + ...args, + }); +}; + +export const useAPAgingSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/payable_aging_summary', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'payable_aging_summary.csv', + ...args, + }); +}; + +/** + * Retrieves the balance sheet pdf document data. + */ +export function useAPAgingSummaryPdf() { + return useRequestPdf(`financial_statements/payable_aging_summary`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-AR-aging-summary.ts b/packages/webapp/src/hooks/query/FinancialReports/use-AR-aging-summary.ts new file mode 100644 index 000000000..9059ca55b --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-AR-aging-summary.ts @@ -0,0 +1,60 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; +/** + * Retrieve A/R aging summary report. + */ +export function useARAgingSummaryReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.AR_AGING_SUMMARY, query], + { + method: 'get', + url: '/financial_statements/receivable_aging_summary', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useARAgingSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/receivable_aging_summary', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'receivable_aging_summary.xlsx', + ...args, + }); +}; + +export const useARAgingSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/receivable_aging_summary', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'receivable_aging_summary.csv', + ...args, + }); +}; + +/** + * Retrieves the A/R aging summary pdf document data. + */ +export function useARAgingSummaryPdf() { + return useRequestPdf(`financial_statements/receivable_aging_summary`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-balance-sheet.ts b/packages/webapp/src/hooks/query/FinancialReports/use-balance-sheet.ts new file mode 100644 index 000000000..99abf33ef --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-balance-sheet.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve balance sheet. + */ +export function useBalanceSheet(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.BALANCE_SHEET, query], + { + method: 'get', + url: '/financial_statements/balance_sheet', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useBalanceSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/balance_sheet', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'balance_sheet.xlsx', + ...args, + }); +}; + +export const useBalanceSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/balance_sheet', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'balance_sheet.csv', + ...args, + }); +}; + +/** + * Retrieves the balance sheet pdf document data. + */ +export function useBalanceSheetPdf() { + return useRequestPdf(`financial_statements/balance_sheet`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-cashflow-sheet.ts b/packages/webapp/src/hooks/query/FinancialReports/use-cashflow-sheet.ts new file mode 100644 index 000000000..6abf1888d --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-cashflow-sheet.ts @@ -0,0 +1,80 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve cash flow statement report. + */ +export function useCashFlowStatementReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.CASH_FLOW_STATEMENT, query], + { + method: 'get', + url: '/financial_statements/cash-flow', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => ({ + columns: res.data.table.columns, + query: res.data.query, + meta: res.data.meta, + tableRows: res.data.table.rows, + }), + defaultData: { + tableRows: [], + columns: [], + query: {}, + meta: {}, + }, + ...props, + }, + ); +} + +export const useCashFlowStatementXlsxExport = (query, args) => { + const url = '/financial_statements/cash-flow'; + const config = { + headers: { + accept: 'application/xlsx', + }, + params: query, + }; + const filename = 'cashflow_statement.xlsx'; + + return useDownloadFile({ + url, + config, + filename, + ...args, + }); +}; + +export const useCashFlowStatementCsvExport = (query, args) => { + const url = '/financial_statements/cash-flow'; + const config = { + headers: { + accept: 'application/csv', + }, + params: query, + }; + const filename = 'cashflow_statement.csv'; + + return useDownloadFile({ + url, + config, + filename, + ...args, + }); +}; + +/** + * Retrieves the cashflow sheet pdf document data. + */ +export function useCashflowSheetPdf() { + return useRequestPdf(`financial_statements/cash-flow`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-customer-balance-summary.ts b/packages/webapp/src/hooks/query/FinancialReports/use-customer-balance-summary.ts new file mode 100644 index 000000000..95cf5de04 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-customer-balance-summary.ts @@ -0,0 +1,68 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve customers balance summary report. + */ +export function useCustomerBalanceSummaryReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.CUSTOMERS_BALANCE_SUMMARY, query], + { + method: 'get', + url: '/financial_statements/customer-balance-summary', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => ({ + query: res.data.query, + table: res.data.table, + }), + defaultData: { + table: {}, + query: {}, + }, + ...props, + }, + ); +} + +export const useCustomerBalanceSummaryXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/customer-balance-summary', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'customer_balance_summary.xlsx', + ...args, + }); +}; + +export const useCustomerBalanceSummaryCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/customer-balance-summary', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'customer_balance_summary.csv', + ...args, + }); +}; + +/** + * Retrieves the balance sheet pdf document data. + */ +export function useCustomerBalanceSummaryPdf() { + return useRequestPdf(`financial_statements/customer-balance-summary`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-customer-transactions.ts b/packages/webapp/src/hooks/query/FinancialReports/use-customer-transactions.ts new file mode 100644 index 000000000..08acc7e0e --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-customer-transactions.ts @@ -0,0 +1,69 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve customers transactions report. + */ +export function useCustomersTransactionsReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.CUSTOMERS_TRANSACTIONS, query], + { + method: 'get', + url: '/financial_statements/transactions-by-customers', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => ({ + data: res.data.table, + tableRows: res.data.table.rows, + }), + defaultData: { + tableRows: [], + data: [], + }, + ...props, + }, + ); +} + +export const useCustomersTransactionsXlsxExport = (query, args) => { + const url = '/financial_statements/transactions-by-customers'; + const config = { + headers: { + accept: 'application/xlsx', + }, + params: query, + }; + const filename = 'customers_transactions.xlsx'; + + return useDownloadFile({ + url, + config, + filename, + ...args, + }); +}; + +export const useCustomersTransactionsCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/transactions-by-customers', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'customers_transactions.csv', + ...args, + }); +}; + +export const useCustomersTransactionsPdfExport = () => { + return useRequestPdf('/financial_statements/transactions-by-customers'); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-general-ledger.ts b/packages/webapp/src/hooks/query/FinancialReports/use-general-ledger.ts new file mode 100644 index 000000000..bf684a365 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-general-ledger.ts @@ -0,0 +1,60 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve general ledger (GL) sheet. + */ +export function useGeneralLedgerSheet(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.GENERAL_LEDGER, query], + { + method: 'get', + url: '/financial_statements/general_ledger', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} +export const useGeneralLedgerSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/general_ledger', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'general_ledger.xlsx', + ...args, + }); +}; + +export const useGeneralLedgerSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/general_ledger', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'general_ledger.csv', + ...args, + }); +}; + +/** + * Retrieves the general ledger pdf document data. + */ +export function useGeneralLedgerPdf() { + return useRequestPdf(`financial_statements/general_ledger`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-inventory-item-details.ts b/packages/webapp/src/hooks/query/FinancialReports/use-inventory-item-details.ts new file mode 100644 index 000000000..c81e3a3d5 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-inventory-item-details.ts @@ -0,0 +1,72 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve inventory item detail report. + */ +export function useInventoryItemDetailsReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.INVENTORY_ITEM_DETAILS, query], + { + method: 'get', + url: '/financial_statements/inventory-item-details', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => ({ + columns: res.data.table.columns, + query: res.data.query, + meta: res.data.meta, + tableRows: res.data.table.rows, + }), + defaultData: { + tableRows: [], + columns: [], + query: {}, + meta: {}, + }, + ...props, + }, + ); +} + +export const useInventoryItemDetailsXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/inventory-item-details', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'inventory_item_details.xlsx', + ...args, + }); +}; + +export const useInventoryItemDetailsCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/inventory-item-details', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'inventory_item_details.csv', + ...args, + }); +}; + +/** + * Retrieves the balance sheet pdf document data. + */ +export function useInventoryItemDetailsPdf() { + return useRequestPdf(`financial_statements/inventory-item-details`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-inventory-valuation.ts b/packages/webapp/src/hooks/query/FinancialReports/use-inventory-valuation.ts new file mode 100644 index 000000000..da5f2bc36 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-inventory-valuation.ts @@ -0,0 +1,80 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve inventory valuation. + */ +export function useInventoryValuation(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.INVENTORY_VALUATION, query], + { + method: 'get', + url: '/financial_statements/inventory-valuation', + params: query, + }, + { + select: (res) => res.data, + + ...props, + }, + ); +} + +/** + * Retrieve inventory valuation. + */ +export function useInventoryValuationTable(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.INVENTORY_VALUATION, query], + { + method: 'get', + url: '/financial_statements/inventory-valuation', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useInventoryValuationXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/inventory-valuation', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'inventory_valuation.xlsx', + ...args, + }); +}; + +/** + * Retrieves the inventory valuation pdf document data. + */ +export function useInventoryValuationPdf() { + return useRequestPdf(`financial_statements/inventory-valuation`); +} + +export const useInventoryValuationCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/inventory-valuation', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'inventory_valuation.csv', + ...args, + }); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-journal-sheet.ts b/packages/webapp/src/hooks/query/FinancialReports/use-journal-sheet.ts new file mode 100644 index 000000000..badb63fc5 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-journal-sheet.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve journal sheet. + */ +export function useJournalSheet(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.JOURNAL, query], + { + method: 'get', + url: '/financial_statements/journal', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useJournalSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/journal', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'journal.xlsx', + ...args, + }); +}; + +export const useJournalSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/journal', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'journal.csv', + ...args, + }); +}; + +/** + * Retrieves the journal sheet pdf content. + */ +export const useJournalSheetPdf = (query = {}) => { + return useRequestPdf(`financial_statements/journal`); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-profit-loss-sheet.ts b/packages/webapp/src/hooks/query/FinancialReports/use-profit-loss-sheet.ts new file mode 100644 index 000000000..8925aa4e2 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-profit-loss-sheet.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve profit/loss (P&L) sheet. + */ +export function useProfitLossSheet(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.PROFIT_LOSS_SHEET, query], + { + method: 'get', + url: '/financial_statements/profit_loss_sheet', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useProfitLossSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/profit_loss_sheet', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'profit_loss_sheet.xlsx', + ...args, + }); +}; + +export const useProfitLossSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/profit_loss_sheet', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'profit_loss_sheet.csv', + ...args, + }); +}; + +/** + * Retrieves the cashflow sheet pdf document data. + */ +export function useProfitLossSheetPdf() { + return useRequestPdf(`financial_statements/profit_loss_sheet`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-purchases-by-items.ts b/packages/webapp/src/hooks/query/FinancialReports/use-purchases-by-items.ts new file mode 100644 index 000000000..8a77473b4 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-purchases-by-items.ts @@ -0,0 +1,77 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve purchases by items. + */ +export function usePurchasesByItems(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.PURCHASES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/purchases-by-items', + params: query, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export function usePurchasesByItemsTable(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.PURCHASES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/purchases-by-items', + params: query, + headers: { + accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const usePurchasesByItemsCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/purchases-by-items', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'purchases_by_items.csv', + ...args, + }); +}; + +export const usePurchasesByItemsXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/purchases-by-items', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'purchases_by_items.xlsx', + ...args, + }); +}; + +/** + * + * @returns + */ +export const usePurchasesByItemsPdfExport = () => { + return useRequestPdf('/financial_statements/purchases-by-items'); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-sales-by-items.ts b/packages/webapp/src/hooks/query/FinancialReports/use-sales-by-items.ts new file mode 100644 index 000000000..e9e559857 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-sales-by-items.ts @@ -0,0 +1,75 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve sales by items. + */ +export function useSalesByItems(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.SALES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/sales-by-items', + params: query, + }, + { + ...props, + }, + ); +} + +/** + * Retrieves sales by items table format. + */ +export function useSalesByItemsTable(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.SALES_BY_ITEMS, query], + { + method: 'get', + url: '/financial_statements/sales-by-items', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useSalesByItemsCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/sales-by-items', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'sales_by_items.csv', + ...args, + }); +}; + +export const useSalesByItemsXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/sales-by-items', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'sales_by_items.xlsx', + ...args, + }); +}; + +export const useSalesByItemsPdfExport = () => { + return useRequestPdf('/financial_statements/sales-by-items'); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-sales-tax-liabilities-summary.ts b/packages/webapp/src/hooks/query/FinancialReports/use-sales-tax-liabilities-summary.ts new file mode 100644 index 000000000..abcca6f28 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-sales-tax-liabilities-summary.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieves the sales tax liability summary report. + */ +export function useSalesTaxLiabilitySummary(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.SALES_TAX_LIABILITY_SUMMARY, query], + { + method: 'get', + url: '/financial_statements/sales-tax-liability-summary', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useSalesTaxLiabilitySummaryXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/sales-tax-liability-summary', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'sales_tax_liability_summary.xlsx', + ...args, + }); +}; + +export const useSalesTaxLiabilitySummaryCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/sales-tax-liability-summary', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'sales_tax_liability_summary.csv', + ...args, + }); +}; + +/** + * Retrieves the balance sheet pdf document data. + */ +export function useSalesTaxLiabilitySummaryPdf() { + return useRequestPdf(`financial_statements/sales-tax-liability-summary`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-transactions-by-reference.ts b/packages/webapp/src/hooks/query/FinancialReports/use-transactions-by-reference.ts new file mode 100644 index 000000000..680e98a5a --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-transactions-by-reference.ts @@ -0,0 +1,23 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import t from '../types'; +/** + * Retrieve transactions by reference report. + */ +export function useTransactionsByReference(query, props) { + return useRequestQuery( + [t.TRANSACTIONS_BY_REFERENCE, query], + { + method: 'get', + url: `/financial_statements/transactions-by-reference`, + params: query, + }, + { + select: (res) => res.data, + defaultData: { + transactions: [], + }, + ...props, + }, + ); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-trial-balance-sheet.ts b/packages/webapp/src/hooks/query/FinancialReports/use-trial-balance-sheet.ts new file mode 100644 index 000000000..8aaac170c --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-trial-balance-sheet.ts @@ -0,0 +1,61 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve trial balance sheet. + */ +export function useTrialBalanceSheet(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.TRIAL_BALANCE_SHEET, query], + { + method: 'get', + url: '/financial_statements/trial_balance_sheet', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => res.data, + ...props, + }, + ); +} + +export const useTrialBalanceSheetXlsxExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/trial_balance_sheet', + config: { + headers: { + accept: 'application/xlsx', + }, + params: query, + }, + filename: 'trial_balance_sheet.xlsx', + ...args, + }); +}; + +export const useTrialBalanceSheetCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/trial_balance_sheet', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'trial_balance_sheet.csv', + ...args, + }); +}; + +/** + * Retrieves the trial balance sheet pdf document data. + */ +export function useTrialBalanceSheetPdf() { + return useRequestPdf(`financial_statements/trial_balance_sheet`); +} diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-vendor-balance-summary.ts b/packages/webapp/src/hooks/query/FinancialReports/use-vendor-balance-summary.ts new file mode 100644 index 000000000..b9f84017a --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-vendor-balance-summary.ts @@ -0,0 +1,68 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve vendors balance summary report. + */ +export function useVendorsBalanceSummaryReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.VENDORS_BALANCE_SUMMARY, query], + { + method: 'get', + url: '/financial_statements/vendor-balance-summary', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + + { + select: (res) => ({ + query: res.data.query, + table: res.data.table, + }), + defaultData: { + table: {}, + query: {}, + }, + ...props, + }, + ); +} + +export const useVendorBalanceSummaryXlsxExport = (args) => { + const url = '/financial_statements/vendor-balance-summary'; + const config = { + headers: { + accept: 'application/xlsx', + }, + }; + const filename = 'vendor_balance_summary.xlsx'; + + return useDownloadFile({ + url, + config, + filename, + ...args, + }); +}; + +export const useVendorBalanceSummaryCsvExport = (args) => { + return useDownloadFile({ + url: '/financial_statements/vendor-balance-summary', + config: { + headers: { + accept: 'application/csv', + }, + }, + filename: 'vendor_balance_summary.csv', + ...args, + }); +}; + +export const useVendorBalanceSummaryPdfExport = () => { + return useRequestPdf('/financial_statements/vendor-balance-summary'); +}; diff --git a/packages/webapp/src/hooks/query/FinancialReports/use-vendor-transactions.ts b/packages/webapp/src/hooks/query/FinancialReports/use-vendor-transactions.ts new file mode 100644 index 000000000..c9da544a9 --- /dev/null +++ b/packages/webapp/src/hooks/query/FinancialReports/use-vendor-transactions.ts @@ -0,0 +1,71 @@ +// @ts-nocheck +import { useRequestQuery } from '../../useQueryRequest'; +import { useDownloadFile } from '../../useDownloadFile'; +import { useRequestPdf } from '../../useRequestPdf'; +import t from '../types'; + +/** + * Retrieve vendors transactions report. + */ +export function useVendorsTransactionsReport(query, props) { + return useRequestQuery( + [t.FINANCIAL_REPORT, t.VENDORS_TRANSACTIONS, query], + { + method: 'get', + url: '/financial_statements/transactions-by-vendors', + params: query, + headers: { + Accept: 'application/json+table', + }, + }, + { + select: (res) => ({ + data: res.data.table, + tableRows: res.data.table.rows, + }), + defaultData: { + tableRows: [], + data: [], + }, + ...props, + }, + ); +} + +export const useVendorsTransactionsXlsxExport = (query, args) => { + const url = '/financial_statements/transactions-by-vendors'; + const config = { + headers: { + accept: 'application/xlsx', + }, + params: query, + }; + const filename = 'transactions_by_vendor.xlsx'; + + return useDownloadFile({ + url, + config, + filename, + ...args, + }); +}; + +export const useVendorsTransactionsCsvExport = (query, args) => { + return useDownloadFile({ + url: '/financial_statements/transactions-by-vendors', + config: { + headers: { + accept: 'application/csv', + }, + params: query, + }, + filename: 'transactions_by_vendor.csv', + ...args, + }); +}; +/** + * Retrieves the balance sheet pdf document data. + */ +export function useTransactionsByVendorsPdf() { + return useRequestPdf(`financial_statements/transactions-by-vendors`); +} diff --git a/packages/webapp/src/hooks/query/financialReports.tsx b/packages/webapp/src/hooks/query/financialReports.tsx deleted file mode 100644 index 6738cbc44..000000000 --- a/packages/webapp/src/hooks/query/financialReports.tsx +++ /dev/null @@ -1,1008 +0,0 @@ -// @ts-nocheck -import { useRequestQuery } from '../useQueryRequest'; -import { purchasesByItemsReducer } from '@/containers/FinancialStatements/reducers'; -import { useDownloadFile } from '../useDownloadFile'; -import t from './types'; -import { useRequestPdf } from '../useRequestPdf'; - -/** - * Retrieve balance sheet. - */ -export function useBalanceSheet(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.BALANCE_SHEET, query], - { - method: 'get', - url: '/financial_statements/balance_sheet', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useBalanceSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/balance_sheet', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'balance_sheet.xlsx', - ...args, - }); -}; - -export const useBalanceSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/balance_sheet', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'balance_sheet.csv', - ...args, - }); -}; - -/** - * Retrieves the balance sheet pdf document data. - */ -export function useBalanceSheetPdf() { - return useRequestPdf(`financial_statements/balance_sheet`); -} - -/** - * Retrieve trial balance sheet. - */ -export function useTrialBalanceSheet(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.TRIAL_BALANCE_SHEET, query], - { - method: 'get', - url: '/financial_statements/trial_balance_sheet', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useTrialBalanceSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/trial_balance_sheet', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'trial_balance_sheet.xlsx', - ...args, - }); -}; - -/** - * Retrieves the trial balance sheet pdf document data. - */ -export function useTrialBalanceSheetPdf() { - return useRequestPdf(`financial_statements/trial_balance_sheet`); -} - -export const useTrialBalanceSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/trial_balance_sheet', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'trial_balance_sheet.csv', - ...args, - }); -}; - -/** - * Retrieve profit/loss (P&L) sheet. - */ -export function useProfitLossSheet(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.PROFIT_LOSS_SHEET, query], - { - method: 'get', - url: '/financial_statements/profit_loss_sheet', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useProfitLossSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/profit_loss_sheet', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'profit_loss_sheet.xlsx', - ...args, - }); -}; - -export const useProfitLossSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/profit_loss_sheet', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'profit_loss_sheet.csv', - ...args, - }); -}; - -/** - * Retrieves the cashflow sheet pdf document data. - */ -export function useProfitLossSheetPdf() { - return useRequestPdf(`financial_statements/profit_loss_sheet`); -} - - -/** - * Retrieve general ledger (GL) sheet. - */ -export function useGeneralLedgerSheet(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.GENERAL_LEDGER, query], - { - method: 'get', - url: '/financial_statements/general_ledger', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} -export const useGeneralLedgerSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/general_ledger', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'general_ledger.xlsx', - ...args, - }); -}; - -export const useGeneralLedgerSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/general_ledger', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'general_ledger.csv', - ...args, - }); -}; - -/** - * Retrieve journal sheet. - */ -export function useJournalSheet(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.JOURNAL, query], - { - method: 'get', - url: '/financial_statements/journal', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useJournalSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/journal', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'journal.xlsx', - ...args, - }); -}; - -export const useJournalSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/journal', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'journal.csv', - ...args, - }); -}; - -/** - * Retrieve A/R aging summary report. - */ -export function useARAgingSummaryReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.AR_AGING_SUMMARY, query], - { - method: 'get', - url: '/financial_statements/receivable_aging_summary', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useARAgingSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/receivable_aging_summary', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'receivable_aging_summary.xlsx', - ...args, - }); -}; - -export const useARAgingSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/receivable_aging_summary', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'receivable_aging_summary.csv', - ...args, - }); -}; - -/** - * Retrieve A/P aging summary report. - */ -export function useAPAgingSummaryReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.AP_AGING_SUMMARY, query], - { - method: 'get', - url: '/financial_statements/payable_aging_summary', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useAPAgingSheetXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/payable_aging_summary', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'payable_aging_summary.xlsx', - ...args, - }); -}; - -export const useAPAgingSheetCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/payable_aging_summary', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'payable_aging_summary.csv', - ...args, - }); -}; - -/** - * Retrieve inventory valuation. - */ -export function useInventoryValuation(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.INVENTORY_VALUATION, query], - { - method: 'get', - url: '/financial_statements/inventory-valuation', - params: query, - }, - { - select: (res) => res.data, - - ...props, - }, - ); -} - -/** - * Retrieve inventory valuation. - */ -export function useInventoryValuationTable(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.INVENTORY_VALUATION, query], - { - method: 'get', - url: '/financial_statements/inventory-valuation', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useInventoryValuationXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/inventory-valuation', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'inventory_valuation.xlsx', - ...args, - }); -}; - -export const useInventoryValuationCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/inventory-valuation', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'inventory_valuation.csv', - ...args, - }); -}; - -/** - * Retrieve purchases by items. - */ -export function usePurchasesByItems(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.PURCHASES_BY_ITEMS, query], - { - method: 'get', - url: '/financial_statements/purchases-by-items', - params: query, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export function usePurchasesByItemsTable(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.PURCHASES_BY_ITEMS, query], - { - method: 'get', - url: '/financial_statements/purchases-by-items', - params: query, - headers: { - accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const usePurchasesByItemsCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/purchases-by-items', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'purchases_by_items.csv', - ...args, - }); -}; - -export const usePurchasesByItemsXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/purchases-by-items', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'purchases_by_items.xlsx', - ...args, - }); -}; - -/** - * Retrieve sales by items. - */ -export function useSalesByItems(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.SALES_BY_ITEMS, query], - { - method: 'get', - url: '/financial_statements/sales-by-items', - params: query, - }, - { - ...props, - }, - ); -} - -/** - * Retrieves sales by items table format. - */ -export function useSalesByItemsTable(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.SALES_BY_ITEMS, query], - { - method: 'get', - url: '/financial_statements/sales-by-items', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useSalesByItemsCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/sales-by-items', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'sales_by_items.csv', - ...args, - }); -}; - -export const useSalesByItemsXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/sales-by-items', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'sales_by_items.xlsx', - ...args, - }); -}; - -/** - * Retrieve customers balance summary report. - */ -export function useCustomerBalanceSummaryReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.CUSTOMERS_BALANCE_SUMMARY, query], - { - method: 'get', - url: '/financial_statements/customer-balance-summary', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => ({ - query: res.data.query, - table: res.data.table, - }), - defaultData: { - table: {}, - query: {}, - }, - ...props, - }, - ); -} - -export const useCustomerBalanceSummaryXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/customer-balance-summary', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'customer_balance_summary.xlsx', - ...args, - }); -}; - -export const useCustomerBalanceSummaryCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/customer-balance-summary', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'customer_balance_summary.csv', - ...args, - }); -}; - -/** - * Retrieve vendors balance summary report. - */ -export function useVendorsBalanceSummaryReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.VENDORS_BALANCE_SUMMARY, query], - { - method: 'get', - url: '/financial_statements/vendor-balance-summary', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - - { - select: (res) => ({ - query: res.data.query, - table: res.data.table, - }), - defaultData: { - table: {}, - query: {}, - }, - ...props, - }, - ); -} - -export const useVendorBalanceSummaryXlsxExport = (args) => { - const url = '/financial_statements/vendor-balance-summary'; - const config = { - headers: { - accept: 'application/xlsx', - }, - }; - const filename = 'vendor_balance_summary.xlsx'; - - return useDownloadFile({ - url, - config, - filename, - ...args, - }); -}; - -export const useVendorBalanceSummaryCsvExport = (args) => { - return useDownloadFile({ - url: '/financial_statements/vendor-balance-summary', - config: { - headers: { - accept: 'application/csv', - }, - }, - filename: 'vendor_balance_summary.csv', - ...args, - }); -}; - -/** - * Retrieve customers transactions report. - */ -export function useCustomersTransactionsReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.CUSTOMERS_TRANSACTIONS, query], - { - method: 'get', - url: '/financial_statements/transactions-by-customers', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => ({ - data: res.data.table, - tableRows: res.data.table.rows, - }), - defaultData: { - tableRows: [], - data: [], - }, - ...props, - }, - ); -} - -export const useCustomersTransactionsXlsxExport = (query, args) => { - const url = '/financial_statements/transactions-by-customers'; - const config = { - headers: { - accept: 'application/xlsx', - }, - params: query, - }; - const filename = 'customers_transactions.xlsx'; - - return useDownloadFile({ - url, - config, - filename, - ...args, - }); -}; - -export const useCustomersTransactionsCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/transactions-by-customers', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'customers_transactions.csv', - ...args, - }); -}; - -/** - * Retrieve vendors transactions report. - */ -export function useVendorsTransactionsReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.VENDORS_TRANSACTIONS, query], - { - method: 'get', - url: '/financial_statements/transactions-by-vendors', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => ({ - data: res.data.table, - tableRows: res.data.table.rows, - }), - defaultData: { - tableRows: [], - data: [], - }, - ...props, - }, - ); -} - -export const useVendorsTransactionsXlsxExport = (query, args) => { - const url = '/financial_statements/transactions-by-vendors'; - const config = { - headers: { - accept: 'application/xlsx', - }, - params: query, - }; - const filename = 'transactions_by_vendor.xlsx'; - - return useDownloadFile({ - url, - config, - filename, - ...args, - }); -}; - -export const useVendorsTransactionsCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/transactions-by-vendors', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'transactions_by_vendor.csv', - ...args, - }); -}; - -/** - * Retrieve cash flow statement report. - */ -export function useCashFlowStatementReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.CASH_FLOW_STATEMENT, query], - { - method: 'get', - url: '/financial_statements/cash-flow', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => ({ - columns: res.data.table.columns, - query: res.data.query, - meta: res.data.meta, - tableRows: res.data.table.rows, - }), - defaultData: { - tableRows: [], - columns: [], - query: {}, - meta: {}, - }, - ...props, - }, - ); -} - -export const useCashFlowStatementXlsxExport = (query, args) => { - const url = '/financial_statements/cash-flow'; - const config = { - headers: { - accept: 'application/xlsx', - }, - params: query, - }; - const filename = 'cashflow_statement.xlsx'; - - return useDownloadFile({ - url, - config, - filename, - ...args, - }); -}; - -export const useCashFlowStatementCsvExport = (query, args) => { - const url = '/financial_statements/cash-flow'; - const config = { - headers: { - accept: 'application/csv', - }, - params: query, - }; - const filename = 'cashflow_statement.csv'; - - return useDownloadFile({ - url, - config, - filename, - ...args, - }); -}; - -/** - * Retrieves the cashflow sheet pdf document data. - */ -export function useCashflowSheetPdf() { - return useRequestPdf(`financial_statements/cash-flow`); -} - -/** - * Retrieve inventory item detail report. - */ -export function useInventoryItemDetailsReport(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.INVENTORY_ITEM_DETAILS, query], - { - method: 'get', - url: '/financial_statements/inventory-item-details', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => ({ - columns: res.data.table.columns, - query: res.data.query, - meta: res.data.meta, - tableRows: res.data.table.rows, - }), - defaultData: { - tableRows: [], - columns: [], - query: {}, - meta: {}, - }, - ...props, - }, - ); -} - -export const useInventoryItemDetailsXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/inventory-item-details', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'inventory_item_details.xlsx', - ...args, - }); -}; - -export const useInventoryItemDetailsCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/inventory-item-details', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'inventory_item_details.csv', - ...args, - }); -}; - -/** - * Retrieve transactions by reference report. - */ -export function useTransactionsByReference(query, props) { - return useRequestQuery( - [t.TRANSACTIONS_BY_REFERENCE, query], - { - method: 'get', - url: `/financial_statements/transactions-by-reference`, - params: query, - }, - { - select: (res) => res.data, - defaultData: { - transactions: [], - }, - ...props, - }, - ); -} - -/** - * Retrieves the sales tax liability summary report. - */ -export function useSalesTaxLiabilitySummary(query, props) { - return useRequestQuery( - [t.FINANCIAL_REPORT, t.SALES_TAX_LIABILITY_SUMMARY, query], - { - method: 'get', - url: '/financial_statements/sales-tax-liability-summary', - params: query, - headers: { - Accept: 'application/json+table', - }, - }, - { - select: (res) => res.data, - ...props, - }, - ); -} - -export const useSalesTaxLiabilitySummaryXlsxExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/sales-tax-liability-summary', - config: { - headers: { - accept: 'application/xlsx', - }, - params: query, - }, - filename: 'sales_tax_liability_summary.xlsx', - ...args, - }); -}; - -export const useSalesTaxLiabilitySummaryCsvExport = (query, args) => { - return useDownloadFile({ - url: '/financial_statements/sales-tax-liability-summary', - config: { - headers: { - accept: 'application/csv', - }, - params: query, - }, - filename: 'sales_tax_liability_summary.csv', - ...args, - }); -}; diff --git a/packages/webapp/src/hooks/query/index.tsx b/packages/webapp/src/hooks/query/index.tsx index 0a7f4feff..fd193b62f 100644 --- a/packages/webapp/src/hooks/query/index.tsx +++ b/packages/webapp/src/hooks/query/index.tsx @@ -6,7 +6,6 @@ export * from './items'; export * from './itemsCategories'; export * from './inventoryAdjustments'; export * from './expenses'; -export * from './financialReports'; export * from './customers'; export * from './vendors'; export * from './manualJournals'; @@ -37,3 +36,4 @@ export * from './transactionsLocking'; export * from './warehouses'; export * from './branches'; export * from './warehousesTransfers'; +export * from './FinancialReports';