mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
WIP
This commit is contained in:
@@ -1,6 +1,49 @@
|
||||
import {getObjectDiff} from 'utils';
|
||||
|
||||
|
||||
// Financial Statements selectors.
|
||||
|
||||
/**
|
||||
* Retrieve financial statement sheet by the given query.
|
||||
* @param {array} sheets
|
||||
* @param {object} query
|
||||
*/
|
||||
export const getFinancialSheetIndexByQuery = (sheets, query) => {
|
||||
return sheets.findIndex(balanceSheet => (
|
||||
getObjectDiff(query, balanceSheet.query).length === 0
|
||||
));
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve financial statement sheet by the given sheet index.
|
||||
* @param {array} sheets
|
||||
* @param {number} index
|
||||
*/
|
||||
export const getFinancialSheet = (sheets, index) => {
|
||||
return (typeof sheets[index] !== 'undefined') ? sheets[index] : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve financial statement columns by the given sheet index.
|
||||
* @param {array} sheets
|
||||
* @param {number} index
|
||||
*/
|
||||
export const getFinancialSheetColumns = (sheets, index) => {
|
||||
const sheet = getFinancialSheet(sheets, index);
|
||||
return (sheet && sheet.columns) ? sheet.columns : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve financial statement query by the given sheet index.
|
||||
* @param {array} sheets
|
||||
* @param {number} index
|
||||
*/
|
||||
export const getFinancialSheetsQuery = (sheets, index) => {
|
||||
const sheet = getFinancialSheet(sheets, index);
|
||||
return (sheet && sheet.query) ? sheet.columns : {};
|
||||
};
|
||||
|
||||
|
||||
// Balance Sheet.
|
||||
export const getBalanceSheetByQuery = (balanceSheets, query) => {
|
||||
return balanceSheets.find(balanceSheet => {
|
||||
|
||||
Reference in New Issue
Block a user