Skip to content

Commit

Permalink
fix(webapp): change the default from/to date values of reports
Browse files Browse the repository at this point in the history
  • Loading branch information
abouolia committed Aug 27, 2023
1 parent c7a3bac commit 4df6356
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ 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 {
data: ARAgingSummary,
isLoading: isARAgingLoading,
isFetching: isARAgingFetching,
refetch,
} = useARAgingSummaryReport(query, { keepPreviousData: true });
} = useARAgingSummaryReport(requestQuery, { keepPreviousData: true });

const provider = {
ARAgingSummary,

isARAgingLoading,
isARAgingFetching,
refetch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ReceivableAgingSummaryTable({
}) {
// AR aging summary report context.
const {
ARAgingSummary: { table },
ARAgingSummary: { table, query },
isARAgingLoading,
} = useARAgingSummaryContext();

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function CustomersBalanceSummaryTable({
companyName,
}) {
const {
CustomerBalanceSummary: { table },
CustomerBalanceSummary: { table, query },
} = useCustomersBalanceSummaryContext();

// Retrieves the customers summary columns.
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getCustomersTransactionsQuerySchema = () => {
};

export const getCustomersTransactionsDefaultQuery = () => ({
fromDate: moment().toDate(),
fromDate: moment().startOf('month').toDate(),
toDate: moment().toDate(),
customersIds: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function InventoryValuationTable({
}) {
// inventory valuation context.
const {
inventoryValuation: { tableRows },
inventoryValuation: { tableRows, query },
isLoading,
} = useInventoryValuationContext();

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 4df6356

Please sign in to comment.