mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
Merge pull request #230 from bigcapitalhq/abouhuolia/big-60-fromto-date-is-not-showing-up-on-inventory-items-details
fix: change the default from/date date value of reports
This commit is contained in:
@@ -37,7 +37,7 @@ export default class BalanceSheetStatementService
|
||||
displayColumnsBy: 'month',
|
||||
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class CashFlowStatementService
|
||||
displayColumnsType: 'total',
|
||||
displayColumnsBy: 'day',
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
divideOn1000: false,
|
||||
|
||||
@@ -31,8 +31,8 @@ export default class GeneralLedgerService {
|
||||
*/
|
||||
get defaultQuery() {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'cash',
|
||||
numberFormat: {
|
||||
noCents: false,
|
||||
|
||||
@@ -16,13 +16,13 @@ import { Tenant } from '@/system/models';
|
||||
@Service()
|
||||
export default class InventoryDetailsService extends FinancialSheet {
|
||||
@Inject()
|
||||
tenancy: TenancyService;
|
||||
private tenancy: TenancyService;
|
||||
|
||||
@Inject()
|
||||
reportRepo: InventoryDetailsRepository;
|
||||
private reportRepo: InventoryDetailsRepository;
|
||||
|
||||
@Inject()
|
||||
inventoryService: InventoryService;
|
||||
private inventoryService: InventoryService;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
@@ -30,8 +30,8 @@ export default class InventoryDetailsService extends FinancialSheet {
|
||||
*/
|
||||
private get defaultQuery(): IInventoryDetailsQuery {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
itemsIds: [],
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
|
||||
@@ -27,7 +27,7 @@ export default class InventoryValuationSheetService {
|
||||
*/
|
||||
get defaultQuery(): IInventoryValuationReportQuery {
|
||||
return {
|
||||
asDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
asDate: moment().format('YYYY-MM-DD'),
|
||||
itemsIds: [],
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
|
||||
@@ -25,8 +25,8 @@ export default class JournalSheetService {
|
||||
*/
|
||||
get defaultQuery() {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
fromRange: null,
|
||||
toRange: null,
|
||||
accountsIds: [],
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IProfitLossSheetQuery } from '@/interfaces';
|
||||
*/
|
||||
export const getDefaultPLQuery = (): IProfitLossSheetQuery => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
|
||||
numberFormat: {
|
||||
divideOn1000: false,
|
||||
|
||||
@@ -12,10 +12,7 @@ import { Tenant } from '@/system/models';
|
||||
@Service()
|
||||
export default class InventoryValuationReportService {
|
||||
@Inject()
|
||||
tenancy: TenancyService;
|
||||
|
||||
@Inject('logger')
|
||||
logger: any;
|
||||
private tenancy: TenancyService;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
@@ -23,8 +20,8 @@ export default class InventoryValuationReportService {
|
||||
*/
|
||||
get defaultQuery(): IInventoryValuationReportQuery {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
itemsIds: [],
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
@@ -73,9 +70,9 @@ export default class InventoryValuationReportService {
|
||||
tenantId: number,
|
||||
query: IInventoryValuationReportQuery
|
||||
): Promise<{
|
||||
data: IInventoryValuationStatement,
|
||||
query: IInventoryValuationReportQuery,
|
||||
meta: IInventoryValuationSheetMeta,
|
||||
data: IInventoryValuationStatement;
|
||||
query: IInventoryValuationReportQuery;
|
||||
meta: IInventoryValuationSheetMeta;
|
||||
}> {
|
||||
const { Item, InventoryTransaction } = this.tenancy.models(tenantId);
|
||||
|
||||
@@ -87,7 +84,7 @@ export default class InventoryValuationReportService {
|
||||
...this.defaultQuery,
|
||||
...query,
|
||||
};
|
||||
const inventoryItems = await Item.query().onBuild(q => {
|
||||
const inventoryItems = await Item.query().onBuild((q) => {
|
||||
q.where('type', 'inventory');
|
||||
|
||||
if (filter.itemsIds.length > 0) {
|
||||
@@ -106,7 +103,7 @@ export default class InventoryValuationReportService {
|
||||
builder.whereIn('itemId', inventoryItemsIds);
|
||||
|
||||
// Filter the date range of the sheet.
|
||||
builder.modify('filterDateRange', filter.fromDate, filter.toDate)
|
||||
builder.modify('filterDateRange', filter.fromDate, filter.toDate);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ export default class SalesByItemsReportService {
|
||||
*/
|
||||
get defaultQuery(): ISalesByItemsReportQuery {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
itemsIds: [],
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
|
||||
@@ -31,8 +31,8 @@ export default class TransactionsByCustomersService
|
||||
*/
|
||||
get defaultQuery(): ITransactionsByCustomersFilter {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
divideOn1000: false,
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class TransactionsByVendorsService
|
||||
*/
|
||||
get defaultQuery(): ITransactionsByVendorsFilter {
|
||||
return {
|
||||
fromDate: moment().format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
numberFormat: {
|
||||
precision: 2,
|
||||
|
||||
@@ -27,7 +27,7 @@ export default class TrialBalanceSheetService extends FinancialSheet {
|
||||
get defaultQuery(): ITrialBalanceSheetQuery {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
numberFormat: {
|
||||
divideOn1000: false,
|
||||
negativeFormat: 'mines',
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function APAgingSummaryTable({
|
||||
}) {
|
||||
// AP aging summary report content.
|
||||
const {
|
||||
APAgingSummary: { table },
|
||||
APAgingSummary: { table, query },
|
||||
isAPAgingLoading,
|
||||
} = useAPAgingSummaryContext();
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function APAgingSummaryTable({
|
||||
<FinancialSheet
|
||||
companyName={organizationName}
|
||||
sheetType={intl.get('payable_aging_summary')}
|
||||
asDate={new Date()}
|
||||
asDate={query.as_date}
|
||||
loading={isAPAgingLoading}
|
||||
>
|
||||
<APAgingSummaryDataTable
|
||||
|
||||
@@ -11,7 +11,10 @@ const ARAgingSummaryContext = createContext();
|
||||
*/
|
||||
function ARAgingSummaryProvider({ filter, ...props }) {
|
||||
// Transformes the filter from to the url query.
|
||||
const query = useMemo(() => transformFilterFormToQuery(filter), [filter]);
|
||||
const requestQuery = useMemo(
|
||||
() => transformFilterFormToQuery(filter),
|
||||
[filter],
|
||||
);
|
||||
|
||||
// A/R aging summary sheet context.
|
||||
const {
|
||||
@@ -19,11 +22,10 @@ function ARAgingSummaryProvider({ filter, ...props }) {
|
||||
isLoading: isARAgingLoading,
|
||||
isFetching: isARAgingFetching,
|
||||
refetch,
|
||||
} = useARAgingSummaryReport(query, { keepPreviousData: true });
|
||||
} = useARAgingSummaryReport(requestQuery, { keepPreviousData: true });
|
||||
|
||||
const provider = {
|
||||
ARAgingSummary,
|
||||
|
||||
isARAgingLoading,
|
||||
isARAgingFetching,
|
||||
refetch,
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function ReceivableAgingSummaryTable({
|
||||
}) {
|
||||
// AR aging summary report context.
|
||||
const {
|
||||
ARAgingSummary: { table },
|
||||
ARAgingSummary: { table, query },
|
||||
isARAgingLoading,
|
||||
} = useARAgingSummaryContext();
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function ReceivableAgingSummaryTable({
|
||||
<FinancialSheet
|
||||
companyName={organizationName}
|
||||
sheetType={intl.get('receivable_aging_summary')}
|
||||
asDate={new Date()}
|
||||
asDate={query.as_date}
|
||||
loading={isARAgingLoading}
|
||||
>
|
||||
<ARAgingSummaryDataTable
|
||||
|
||||
@@ -15,7 +15,7 @@ import { useAppQueryString } from '@/hooks';
|
||||
*/
|
||||
export const getDefaultBalanceSheetQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'cash',
|
||||
displayColumnsType: 'total',
|
||||
filterByOption: 'without-zero-balance',
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useAppQueryString } from '@/hooks';
|
||||
export const getDefaultCashFlowSheetQuery = () => {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'cash',
|
||||
displayColumnsType: 'total',
|
||||
filterByOption: 'with-transactions',
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function CustomersBalanceSummaryTable({
|
||||
companyName,
|
||||
}) {
|
||||
const {
|
||||
CustomerBalanceSummary: { table },
|
||||
CustomerBalanceSummary: { table, query },
|
||||
} = useCustomersBalanceSummaryContext();
|
||||
|
||||
// Retrieves the customers summary columns.
|
||||
@@ -28,7 +28,7 @@ export default function CustomersBalanceSummaryTable({
|
||||
<FinancialSheet
|
||||
companyName={companyName}
|
||||
sheetType={intl.get('customers_balance_summary')}
|
||||
asDate={new Date()}
|
||||
asDate={query.as_date}
|
||||
>
|
||||
<CustomerBalanceDataTable
|
||||
columns={columns}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { CustomersTransactionsBody } from './CustomersTransactionsBody';
|
||||
import { CustomersTransactionsProvider } from './CustomersTransactionsProvider';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { useCustomersTransactionsQuery } from './_utils';
|
||||
|
||||
/**
|
||||
* Customers transactions.
|
||||
@@ -22,11 +23,7 @@ function CustomersTransactions({
|
||||
toggleCustomersTransactionsFilterDrawer,
|
||||
}) {
|
||||
// filter
|
||||
const [filter, setFilter] = useState({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
filterByOption: 'with-transactions',
|
||||
});
|
||||
const [filter, setFilter] = useCustomersTransactionsQuery();
|
||||
|
||||
const handleFilterSubmit = (filter) => {
|
||||
const _filter = {
|
||||
|
||||
@@ -14,7 +14,7 @@ function CustomersTransactionsProvider({ filter, ...props }) {
|
||||
filter,
|
||||
]);
|
||||
|
||||
// fetches the customers transactions.
|
||||
// Fetches the customers transactions.
|
||||
const {
|
||||
data: customersTransactions,
|
||||
isFetching: isCustomersTransactionsFetching,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
// @ts-nocheck
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
import moment from 'moment';
|
||||
import { transformToForm } from '@/utils';
|
||||
import { castArray } from 'lodash';
|
||||
import { useMemo } from 'react';
|
||||
import { useAppQueryString } from '@/hooks';
|
||||
|
||||
export const getCustomersTransactionsQuerySchema = () => {
|
||||
return Yup.object().shape({
|
||||
@@ -13,7 +18,31 @@ export const getCustomersTransactionsQuerySchema = () => {
|
||||
};
|
||||
|
||||
export const getCustomersTransactionsDefaultQuery = () => ({
|
||||
fromDate: moment().toDate(),
|
||||
toDate: moment().toDate(),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
customersIds: [],
|
||||
filterByOption: 'with-transactions',
|
||||
});
|
||||
|
||||
const parseCustomersTransactionsQuery = (query) => {
|
||||
const defaultQuery = getCustomersTransactionsDefaultQuery();
|
||||
|
||||
const transformedQuery = {
|
||||
...defaultQuery,
|
||||
...transformToForm(query, defaultQuery),
|
||||
};
|
||||
return {
|
||||
...transformedQuery,
|
||||
customersIds: castArray(transformedQuery.customersIds),
|
||||
};
|
||||
};
|
||||
|
||||
export const useCustomersTransactionsQuery = () => {
|
||||
const [locationQuery, setLocationQuery] = useAppQueryString();
|
||||
|
||||
const query = useMemo(
|
||||
() => parseCustomersTransactionsQuery(locationQuery),
|
||||
[locationQuery],
|
||||
);
|
||||
return [query, setLocationQuery];
|
||||
};
|
||||
|
||||
@@ -28,8 +28,8 @@ export const filterAccountsOptions = [
|
||||
* Retrieves the default general ledger query.
|
||||
*/
|
||||
export const getDefaultGeneralLedgerQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'accrual',
|
||||
filterByOption: 'with-transactions',
|
||||
branchesIds: [],
|
||||
|
||||
@@ -35,8 +35,8 @@ export function InventoryItemDetailsTable({
|
||||
companyName={companyName}
|
||||
sheetType={intl.get('inventory_item_details')}
|
||||
loading={isInventoryItemDetailsLoading}
|
||||
fromDate={query.from_date}
|
||||
toDate={query.to_date}
|
||||
fromDate={query.fromDate}
|
||||
toDate={query.toDate}
|
||||
fullWidth={true}
|
||||
>
|
||||
<InventoryItemDetailsDataTable
|
||||
|
||||
@@ -31,9 +31,6 @@ const numericColumn = R.curry((data, index, column) => ({
|
||||
align: Align.Right,
|
||||
}));
|
||||
|
||||
/**
|
||||
* columns mapper.
|
||||
*/
|
||||
const columnsMapper = R.curry((data, index, column) => ({
|
||||
id: column.key,
|
||||
key: column.key,
|
||||
|
||||
@@ -12,8 +12,8 @@ import { transformToForm } from '@/utils';
|
||||
* Retrieves inventory item details default query.
|
||||
*/
|
||||
export const getInventoryItemDetailsDefaultQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
itemsIds: [],
|
||||
warehousesIds: [],
|
||||
branchesIds: [],
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function InventoryValuationTable({
|
||||
}) {
|
||||
// inventory valuation context.
|
||||
const {
|
||||
inventoryValuation: { tableRows },
|
||||
inventoryValuation: { tableRows, query },
|
||||
isLoading,
|
||||
} = useInventoryValuationContext();
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function InventoryValuationTable({
|
||||
<InventoryValuationSheet
|
||||
companyName={companyName}
|
||||
sheetType={intl.get('inventory_valuation')}
|
||||
asDate={new Date()}
|
||||
asDate={query.as_date}
|
||||
loading={isLoading}
|
||||
>
|
||||
<InventoryValuationDataTable
|
||||
|
||||
@@ -20,7 +20,7 @@ export const getInventoryValuationQuerySchema = () => {
|
||||
* Retrieves the inventory valuation sheet default query.
|
||||
*/
|
||||
export const getInventoryValuationQuery = () => ({
|
||||
asDate: moment().endOf('day').format('YYYY-MM-DD'),
|
||||
asDate: moment().format('YYYY-MM-DD'),
|
||||
filterByOption: 'with-transactions',
|
||||
itemsIds: [],
|
||||
branchesIds: [],
|
||||
|
||||
@@ -11,17 +11,16 @@ import { transformToForm } from '@/utils';
|
||||
*/
|
||||
export const getDefaultJournalQuery = () => {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'accrual',
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parses balance sheet query.
|
||||
*/
|
||||
const parseJournalQuery = (locationQuery) => {
|
||||
const parseJournalQuery = (locationQuery) => {
|
||||
const defaultQuery = getDefaultJournalQuery();
|
||||
|
||||
return {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function ProfitLossSheetTable({
|
||||
} = useProfitLossSheetContext();
|
||||
|
||||
// Retrieves the profit/loss table columns.
|
||||
const tableColumns = useProfitLossSheetColumns();
|
||||
const columns = useProfitLossSheetColumns();
|
||||
|
||||
// Retrieve default expanded rows of balance sheet.
|
||||
const expandedRows = React.useMemo(
|
||||
@@ -40,7 +40,7 @@ export default function ProfitLossSheetTable({
|
||||
basis={query.basis}
|
||||
>
|
||||
<ProfitLossDataTable
|
||||
columns={tableColumns}
|
||||
columns={columns}
|
||||
data={table.rows}
|
||||
noInitialFetch={true}
|
||||
expanded={expandedRows}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { castArray } from 'lodash';
|
||||
export const getDefaultProfitLossQuery = () => ({
|
||||
basis: 'cash',
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
displayColumnsType: 'total',
|
||||
filterByOption: 'with-transactions',
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import { castArray } from 'lodash';
|
||||
* Retrieves the purchases by items query.
|
||||
*/
|
||||
export const getDefaultPurchasesByItemsQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
filterByOption: 'with-transactions',
|
||||
itemsIds: [],
|
||||
});
|
||||
|
||||
@@ -25,8 +25,8 @@ export const getSalesByItemsQueryShema = () => {
|
||||
* Retrieves the default query.
|
||||
*/
|
||||
export const getDefaultSalesByItemsQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
filterByOption: 'with-transactions',
|
||||
itemsIds: [],
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import { transformToForm } from '@/utils';
|
||||
export function getDefaultTrialBalanceQuery() {
|
||||
return {
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
basis: 'accrual',
|
||||
filterByOption: 'with-transactions',
|
||||
branchesIds: [],
|
||||
|
||||
@@ -9,7 +9,6 @@ import { tableRowTypesToClassnames } from '@/utils';
|
||||
import { useVendorsBalanceColumns } from './components';
|
||||
import { useVendorsBalanceSummaryContext } from './VendorsBalanceSummaryProvider';
|
||||
|
||||
|
||||
/**
|
||||
* Vendors balance summary table.
|
||||
*/
|
||||
@@ -18,7 +17,7 @@ export default function VendorsBalanceSummaryTable({
|
||||
organizationName,
|
||||
}) {
|
||||
const {
|
||||
VendorBalanceSummary: { table },
|
||||
VendorBalanceSummary: { table, query },
|
||||
} = useVendorsBalanceSummaryContext();
|
||||
|
||||
// vendors balance summary columns.
|
||||
@@ -28,7 +27,7 @@ export default function VendorsBalanceSummaryTable({
|
||||
<VendorBalanceFinancialSheet
|
||||
companyName={organizationName}
|
||||
sheetType={intl.get('vendors_balance_summary')}
|
||||
asDate={new Date()}
|
||||
asDate={query.as_date}
|
||||
>
|
||||
<VendorBalanceDataTable
|
||||
columns={columns}
|
||||
|
||||
@@ -13,6 +13,7 @@ import VendorsTransactionsActionsBar from './VendorsTransactionsActionsBar';
|
||||
import withVendorsTransactionsActions from './withVendorsTransactionsActions';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { useVendorsTransactionsQuery } from './_utils';
|
||||
|
||||
/**
|
||||
* Vendors transactions.
|
||||
@@ -22,11 +23,7 @@ function VendorsTransactions({
|
||||
toggleVendorsTransactionsFilterDrawer,
|
||||
}) {
|
||||
// filter
|
||||
const [filter, setFilter] = useState({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
filterByOption: 'with-transactions',
|
||||
});
|
||||
const [filter, setFilter] = useVendorsTransactionsQuery();
|
||||
|
||||
const handleFilterSubmit = (filter) => {
|
||||
const _filter = {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// @ts-nocheck
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
import moment from 'moment';
|
||||
import { useMemo } from 'react';
|
||||
import { transformToForm } from '@/utils';
|
||||
import { useAppQueryString } from '@/hooks';
|
||||
|
||||
/**
|
||||
* The validation schema of vendors transactions.
|
||||
@@ -19,7 +23,35 @@ export const getVendorTransactionsQuerySchema = () => {
|
||||
* Retrieves the default query of vendors transactions.
|
||||
*/
|
||||
export const getVendorsTransactionsDefaultQuery = () => ({
|
||||
fromDate: moment().toDate(),
|
||||
toDate: moment().toDate(),
|
||||
fromDate: moment().startOf('month').format('YYYY-MM-DD'),
|
||||
toDate: moment().format('YYYY-MM-DD'),
|
||||
vendorsIds: [],
|
||||
});
|
||||
|
||||
/**
|
||||
* Parses the query of vendors transactions.
|
||||
*/
|
||||
const parseVendorsTransactionsQuery = (query) => {
|
||||
const defaultQuery = getVendorsTransactionsDefaultQuery();
|
||||
const transformed = {
|
||||
...defaultQuery,
|
||||
...transformToForm(query, defaultQuery),
|
||||
};
|
||||
return {
|
||||
...transformed,
|
||||
vendorsIds: transformed.vendorsIds ? transformed.vendorsIds : [],
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the query of vendors transactions.
|
||||
*/
|
||||
export const useVendorsTransactionsQuery = () => {
|
||||
const [locationQuery, setLocationQuery] = useAppQueryString();
|
||||
|
||||
const query = useMemo(
|
||||
() => parseVendorsTransactionsQuery(locationQuery),
|
||||
[locationQuery],
|
||||
);
|
||||
return [query, setLocationQuery];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user