mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
BIG-3: refactoring financial reports filtering.
This commit is contained in:
@@ -1,145 +1,7 @@
|
||||
import * as R from 'ramda';
|
||||
import intl from 'react-intl-universal';
|
||||
import { displayColumnsByOptions } from './constants';
|
||||
import { transfromToSnakeCase, flatten } from 'utils';
|
||||
|
||||
export const displayColumnsByOptions = [
|
||||
{ key: 'total', name: intl.get('total'), type: 'total', by: '' },
|
||||
{
|
||||
key: 'year',
|
||||
name: intl.get('date_year'),
|
||||
type: 'date_periods',
|
||||
by: 'year',
|
||||
},
|
||||
{
|
||||
key: 'month',
|
||||
name: intl.get('date_month'),
|
||||
type: 'date_periods',
|
||||
by: 'month',
|
||||
},
|
||||
{
|
||||
key: 'week',
|
||||
name: intl.get('date_week'),
|
||||
type: 'date_periods',
|
||||
by: 'month',
|
||||
},
|
||||
{
|
||||
key: 'day',
|
||||
name: intl.get('date_day'),
|
||||
type: 'date_periods',
|
||||
by: 'day',
|
||||
},
|
||||
{
|
||||
key: 'quarter',
|
||||
name: intl.get('date_quarter'),
|
||||
type: 'date_periods',
|
||||
by: 'quarter',
|
||||
},
|
||||
];
|
||||
|
||||
export const dateRangeOptions = [
|
||||
{ value: 'today', label: intl.get('today') },
|
||||
{ value: 'this_week', label: intl.get('this_week') },
|
||||
{ value: 'this_month', label: intl.get('this_month') },
|
||||
{ value: 'this_quarter', label: intl.get('this_quarter') },
|
||||
{ value: 'this_year', label: intl.get('this_year') },
|
||||
{ value: 'custom', label: intl.get('custom_range') },
|
||||
];
|
||||
|
||||
export const filterAccountsOptions = [
|
||||
{
|
||||
key: 'all-accounts',
|
||||
name: intl.get('all_accounts'),
|
||||
hint: intl.get('all_accounts_including_with_zero_balance'),
|
||||
},
|
||||
{
|
||||
key: 'without-zero-balance',
|
||||
name: intl.get('accounts_without_zero_balance'),
|
||||
hint: intl.get('include_accounts_and_exclude_zero_balance'),
|
||||
},
|
||||
{
|
||||
key: 'with-transactions',
|
||||
name: intl.get('accounts_with_transactions'),
|
||||
hint: intl.get(
|
||||
'include_accounts_once_has_transactions_on_given_date_period',
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export const filterItemsOptions = [
|
||||
{
|
||||
key: 'all-items',
|
||||
name: intl.get('all_items'),
|
||||
hint: intl.get('items.option_all_items.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-transactions',
|
||||
name: intl.get('items.option_with_transactions'),
|
||||
hint: intl.get('items.option_with_transactions.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-only-active',
|
||||
name: intl.get('items.option.only_active'),
|
||||
},
|
||||
];
|
||||
|
||||
export const filterCustomersOptions = [
|
||||
{
|
||||
key: 'all-customers',
|
||||
name: intl.get('all_customers'),
|
||||
hint: intl.get('customers.option_all_customers.hint'),
|
||||
},
|
||||
{
|
||||
key: 'without-zero-balance',
|
||||
name: intl.get('customers.option_without_zero_balance'),
|
||||
hint: intl.get('customers.option_without_zero_balance.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-transactions',
|
||||
name: intl.get('customers.option_with_transactions'),
|
||||
hint: intl.get('customers.option_with_transactions.hint'),
|
||||
},
|
||||
];
|
||||
|
||||
export const filterVendorsOptions = [
|
||||
{
|
||||
key: 'all-vendors',
|
||||
name: intl.get('all_vendors'),
|
||||
hint: intl.get('vendors.option_all_vendors.hint'),
|
||||
},
|
||||
{
|
||||
key: 'without-zero-balance',
|
||||
name: intl.get('vendors.option_without_zero_balance'),
|
||||
hint: intl.get('vendors.option_without_zero_balance.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-transactions',
|
||||
name: intl.get('vendors.option_with_transactions'),
|
||||
hint: intl.get('vendors.option_with_transactions.hint'),
|
||||
},
|
||||
];
|
||||
|
||||
export const filterInventoryValuationOptions = [
|
||||
{
|
||||
key: 'all-items',
|
||||
name: intl.get('all_items'),
|
||||
hint: intl.get('items.option_all_items.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-transactions',
|
||||
name: intl.get('items.option_with_transactions'),
|
||||
hint: intl.get('items.option_with_transactions.hint'),
|
||||
},
|
||||
{
|
||||
key: 'without-zero-balance',
|
||||
name: intl.get('items.option_without_zero_balance'),
|
||||
hint: intl.get('items.option_without_zero_balance.hint'),
|
||||
},
|
||||
{
|
||||
key: 'with-only-active',
|
||||
name: intl.get('items.option.only_active'),
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* Associate display columns by and type properties to query object.
|
||||
*/
|
||||
@@ -160,14 +22,14 @@ export const transformDisplayColumnsType = (form) => {
|
||||
const setNoneZeroTransactions = (form) => {
|
||||
return {
|
||||
...form,
|
||||
noneZero: form.accountsFilter === 'without-zero-balance',
|
||||
noneTransactions: form.accountsFilter === 'with-transactions',
|
||||
onlyActive: form.accountsFilter === 'with-only-active',
|
||||
noneZero: form.filterByOption === 'without-zero-balance',
|
||||
noneTransactions: form.filterByOption === 'with-transactions',
|
||||
onlyActive: form.filterByOption === 'with-only-active',
|
||||
};
|
||||
};
|
||||
|
||||
// filterByOption
|
||||
export const transformAccountsFilter = (form) => {
|
||||
return R.compose(R.omit(['accountsFilter']), setNoneZeroTransactions)(form);
|
||||
return R.compose(R.omit(['filterByOption']), setNoneZeroTransactions)(form);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user