mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat(webapp): remove the un-used functions
This commit is contained in:
@@ -1,194 +1,4 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
|
||||||
import moment from 'moment';
|
|
||||||
import { chain } from 'lodash';
|
|
||||||
import { FormattedMessage as T } from '@/components';
|
|
||||||
|
|
||||||
export const trialBalanceSheetReducer = (sheet) => {
|
|
||||||
const results = [];
|
|
||||||
|
|
||||||
if (sheet.accounts) {
|
|
||||||
sheet.accounts.forEach((account) => {
|
|
||||||
results.push(account);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (sheet.total) {
|
|
||||||
results.push({
|
|
||||||
row_types: 'total',
|
|
||||||
...sheet.total,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const journalTableRowsReducer = (journal) => {
|
|
||||||
const TYPES = {
|
|
||||||
ENTRY: 'ENTRY',
|
|
||||||
TOTAL_ENTRIES: 'TOTAL_ENTRIES',
|
|
||||||
EMPTY_ROW: 'EMPTY_ROW',
|
|
||||||
};
|
|
||||||
|
|
||||||
const entriesMapper = (transaction) => {
|
|
||||||
return transaction.entries.map((entry, index) => ({
|
|
||||||
...(index === 0
|
|
||||||
? {
|
|
||||||
date: transaction.date,
|
|
||||||
reference_type: transaction.reference_type,
|
|
||||||
reference_id: transaction.reference_id,
|
|
||||||
reference_type_formatted: transaction.reference_type_formatted,
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
row_types: TYPES.ENTRY,
|
|
||||||
...entry,
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return chain(journal)
|
|
||||||
.map((transaction) => {
|
|
||||||
const entries = entriesMapper(transaction);
|
|
||||||
|
|
||||||
return [
|
|
||||||
...entries,
|
|
||||||
{
|
|
||||||
row_types: TYPES.TOTAL_ENTRIES,
|
|
||||||
currency_code: transaction.currency_code,
|
|
||||||
credit: transaction.credit,
|
|
||||||
debit: transaction.debit,
|
|
||||||
formatted_credit: transaction.formatted_credit,
|
|
||||||
formatted_debit: transaction.formatted_debit,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
row_types: TYPES.EMPTY_ROW,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
})
|
|
||||||
.flatten()
|
|
||||||
.value();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const generalLedgerTableRowsReducer = (accounts) => {
|
|
||||||
return chain(accounts)
|
|
||||||
.map((account) => {
|
|
||||||
return {
|
|
||||||
name: '',
|
|
||||||
code: account.code,
|
|
||||||
row_types: 'ACCOUNT_ROW',
|
|
||||||
date: account.name,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
...account.opening_balance,
|
|
||||||
name: <T id={'opening_balance'} />,
|
|
||||||
row_types: 'OPENING_BALANCE',
|
|
||||||
date: moment(account.opening_balance.date).format('DD MMM YYYY'),
|
|
||||||
},
|
|
||||||
...account.transactions.map((transaction) => ({
|
|
||||||
...transaction,
|
|
||||||
name: account.name,
|
|
||||||
code: account.code,
|
|
||||||
date: moment(transaction.date).format('DD MMM YYYY'),
|
|
||||||
})),
|
|
||||||
{
|
|
||||||
...account.closing_balance,
|
|
||||||
name: <T id={'closing_balance'} />,
|
|
||||||
row_types: 'CLOSING_BALANCE',
|
|
||||||
date: moment(account.closing_balance.date).format('DD MMM YYYY'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
amount: account.closing_balance.amount,
|
|
||||||
formatted_amount: account.closing_balance.formatted_amount,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.value();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ARAgingSummaryTableRowsMapper = (sheet, total) => {
|
|
||||||
const rows = [];
|
|
||||||
|
|
||||||
const mapAging = (agingPeriods) => {
|
|
||||||
return agingPeriods.reduce((acc, aging, index) => {
|
|
||||||
acc[`aging-${index}`] = aging.total.formatted_amount;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
};
|
|
||||||
sheet.customers.forEach((customer) => {
|
|
||||||
const agingRow = mapAging(customer.aging);
|
|
||||||
|
|
||||||
rows.push({
|
|
||||||
row_types: 'customer',
|
|
||||||
name: customer.customer_name,
|
|
||||||
...agingRow,
|
|
||||||
current: customer.current.formatted_amount,
|
|
||||||
total: customer.total.formatted_amount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (rows.length <= 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
...rows,
|
|
||||||
{
|
|
||||||
name: '',
|
|
||||||
row_types: 'total',
|
|
||||||
current: sheet.total.current.formatted_amount,
|
|
||||||
...mapAging(sheet.total.aging),
|
|
||||||
total: sheet.total.total.formatted_amount,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const APAgingSummaryTableRowsMapper = (sheet, total) => {
|
|
||||||
const rows = [];
|
|
||||||
|
|
||||||
const mapAging = (agingPeriods) => {
|
|
||||||
return agingPeriods.reduce((acc, aging, index) => {
|
|
||||||
acc[`aging-${index}`] = aging.total.formatted_amount;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
};
|
|
||||||
sheet.vendors.forEach((vendor) => {
|
|
||||||
const agingRow = mapAging(vendor.aging);
|
|
||||||
|
|
||||||
rows.push({
|
|
||||||
row_types: 'vendor',
|
|
||||||
name: vendor.vendor_name,
|
|
||||||
...agingRow,
|
|
||||||
current: vendor.current.formatted_amount,
|
|
||||||
total: vendor.total.formatted_amount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (rows.length <= 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
...rows,
|
|
||||||
{
|
|
||||||
name: '',
|
|
||||||
row_types: 'total',
|
|
||||||
current: sheet.total.current.formatted_amount,
|
|
||||||
...mapAging(sheet.total.aging),
|
|
||||||
total: sheet.total.total.formatted_amount,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const inventoryValuationReducer = (sheet) => {
|
|
||||||
const results = [];
|
|
||||||
|
|
||||||
if (sheet.items) {
|
|
||||||
sheet.items.forEach((item) => {
|
|
||||||
results.push(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (sheet.total) {
|
|
||||||
results.push({
|
|
||||||
row_types: 'total',
|
|
||||||
...sheet.total,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const purchasesByItemsReducer = (sheet) => {
|
export const purchasesByItemsReducer = (sheet) => {
|
||||||
const results = [];
|
const results = [];
|
||||||
@@ -206,19 +16,3 @@ export const purchasesByItemsReducer = (sheet) => {
|
|||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
export const salesByItemsReducer = (sheet) => {
|
|
||||||
const results = [];
|
|
||||||
|
|
||||||
if (sheet.items) {
|
|
||||||
sheet.items.forEach((item) => {
|
|
||||||
results.push(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (sheet.total) {
|
|
||||||
results.push({
|
|
||||||
row_types: 'total',
|
|
||||||
...sheet.total,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { useRequestQuery } from '../useQueryRequest';
|
import { useRequestQuery } from '../useQueryRequest';
|
||||||
import {
|
import { purchasesByItemsReducer } from '@/containers/FinancialStatements/reducers';
|
||||||
inventoryValuationReducer,
|
|
||||||
purchasesByItemsReducer,
|
|
||||||
salesByItemsReducer,
|
|
||||||
} from '@/containers/FinancialStatements/reducers';
|
|
||||||
import t from './types';
|
|
||||||
import { useDownloadFile } from '../useDownloadFile';
|
import { useDownloadFile } from '../useDownloadFile';
|
||||||
|
import t from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve balance sheet.
|
* Retrieve balance sheet.
|
||||||
@@ -362,15 +358,8 @@ export function useInventoryValuation(query, props) {
|
|||||||
params: query,
|
params: query,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
select: (res) => ({
|
select: (res) => res.data,
|
||||||
tableRows: inventoryValuationReducer(res.data.data),
|
|
||||||
...res.data,
|
|
||||||
}),
|
|
||||||
defaultData: {
|
|
||||||
tableRows: [],
|
|
||||||
data: [],
|
|
||||||
query: {},
|
|
||||||
},
|
|
||||||
...props,
|
...props,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
// @ts-nocheck
|
|
||||||
import { omit, chain } from 'lodash';
|
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
export const mapBalanceSheetToTableRows = (accounts) => {
|
|
||||||
return accounts.map((account) => {
|
|
||||||
return {
|
|
||||||
...account,
|
|
||||||
children: mapBalanceSheetToTableRows([
|
|
||||||
...(account.children ? account.children : []),
|
|
||||||
...(account.total && account.children && account.children.length > 0
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
name: `Total ${account.name}`,
|
|
||||||
row_types: ['total-row', account.section_type],
|
|
||||||
total: { ...account.total },
|
|
||||||
...(account.total_periods && {
|
|
||||||
total_periods: account.total_periods,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
]),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const profitLossToTableRowsMapper = () => {};
|
|
||||||
|
|
||||||
export const journalToTableRowsMapper = (journal) => {
|
|
||||||
const TYPES = {
|
|
||||||
ENTRY: 'ENTRY',
|
|
||||||
TOTAL_ENTRIES: 'TOTAL_ENTRIES',
|
|
||||||
EMPTY_ROW: 'EMPTY_ROW',
|
|
||||||
};
|
|
||||||
|
|
||||||
const entriesMapper = (transaction) => {
|
|
||||||
return transaction.entries.map((entry, index) => ({
|
|
||||||
...(index === 0
|
|
||||||
? {
|
|
||||||
date: transaction.date,
|
|
||||||
reference_type: transaction.reference_type,
|
|
||||||
reference_id: transaction.reference_id,
|
|
||||||
reference_type_formatted: transaction.reference_type_formatted,
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
rowType: TYPES.ENTRY,
|
|
||||||
...entry,
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return chain(journal)
|
|
||||||
.map((transaction) => {
|
|
||||||
const entries = entriesMapper(transaction);
|
|
||||||
|
|
||||||
return [
|
|
||||||
...entries,
|
|
||||||
{
|
|
||||||
rowType: TYPES.TOTAL_ENTRIES,
|
|
||||||
currency_code: transaction.currency_code,
|
|
||||||
credit: transaction.credit,
|
|
||||||
debit: transaction.debit,
|
|
||||||
formatted_credit: transaction.formatted_credit,
|
|
||||||
formatted_debit: transaction.formatted_debit,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rowType: TYPES.EMPTY_ROW,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
})
|
|
||||||
.flatten()
|
|
||||||
.value();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const generalLedgerToTableRows = (accounts) => {
|
|
||||||
return chain(accounts)
|
|
||||||
.map((account) => {
|
|
||||||
return {
|
|
||||||
name: '',
|
|
||||||
code: account.code,
|
|
||||||
rowType: 'ACCOUNT_ROW',
|
|
||||||
date: account.name,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
...account.opening_balance,
|
|
||||||
name: 'Opening balance',
|
|
||||||
rowType: 'OPENING_BALANCE',
|
|
||||||
},
|
|
||||||
...account.transactions.map((transaction) => ({
|
|
||||||
...transaction,
|
|
||||||
name: account.name,
|
|
||||||
code: account.code,
|
|
||||||
date: moment(transaction.date).format('DD MMM YYYY'),
|
|
||||||
})),
|
|
||||||
{
|
|
||||||
...account.closing_balance,
|
|
||||||
name: 'Closing balance',
|
|
||||||
rowType: 'CLOSING_BALANCE',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.value();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ARAgingSummaryTableRowsMapper = (sheet, total) => {
|
|
||||||
const rows = [];
|
|
||||||
|
|
||||||
const mapAging = (agingPeriods) => {
|
|
||||||
return agingPeriods.reduce((acc, aging, index) => {
|
|
||||||
acc[`aging-${index}`] = aging.total.formatted_amount;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
};
|
|
||||||
sheet.customers.forEach((customer) => {
|
|
||||||
const agingRow = mapAging(customer.aging);
|
|
||||||
|
|
||||||
rows.push({
|
|
||||||
rowType: 'customer',
|
|
||||||
name: customer.customer_name,
|
|
||||||
...agingRow,
|
|
||||||
current: customer.current.formatted_amount,
|
|
||||||
total: customer.total.formatted_amount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (rows.length <= 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
...rows,
|
|
||||||
{
|
|
||||||
name: '',
|
|
||||||
rowType: 'total',
|
|
||||||
current: sheet.total.current.formatted_amount,
|
|
||||||
...mapAging(sheet.total.aging),
|
|
||||||
total: sheet.total.total.formatted_amount,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const APAgingSummaryTableRowsMapper = (sheet, total) => {
|
|
||||||
const rows = [];
|
|
||||||
|
|
||||||
const mapAging = (agingPeriods) => {
|
|
||||||
return agingPeriods.reduce((acc, aging, index) => {
|
|
||||||
acc[`aging-${index}`] = aging.total.formatted_amount;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
};
|
|
||||||
sheet.vendors.forEach((vendor) => {
|
|
||||||
const agingRow = mapAging(vendor.aging);
|
|
||||||
|
|
||||||
rows.push({
|
|
||||||
rowType: 'vendor',
|
|
||||||
name: vendor.vendor_name,
|
|
||||||
...agingRow,
|
|
||||||
current: vendor.current.formatted_amount,
|
|
||||||
total: vendor.total.formatted_amount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (rows.length <= 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
...rows,
|
|
||||||
{
|
|
||||||
name: '',
|
|
||||||
rowType: 'total',
|
|
||||||
current: sheet.total.current.formatted_amount,
|
|
||||||
...mapAging(sheet.total.aging),
|
|
||||||
total: sheet.total.total.formatted_amount,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mapTrialBalanceSheetToRows = (sheet) => {
|
|
||||||
const results = [];
|
|
||||||
|
|
||||||
if (sheet.accounts) {
|
|
||||||
sheet.accounts.forEach((account) => {
|
|
||||||
results.push(account);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (sheet.total) {
|
|
||||||
results.push({
|
|
||||||
rowType: 'total',
|
|
||||||
...sheet.total,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user