Files
odoo_source/addons/spreadsheet_account/static/src/utils.js
T
Lucas Lefèvre f78691a6b8 [MOV] spreadsheet_account: move module to community
The spreadsheet_account module is moved to the community version
for the upcoming spreadsheet dashboards

Task 2799682

Part-of: odoo/odoo#97606
2022-09-10 02:54:52 +02:00

27 lines
886 B
JavaScript

/** @odoo-module **/
import { getOdooFunctions } from "@spreadsheet/helpers/odoo_functions_helpers";
/** @typedef {import("@spreadsheet/helpers/odoo_functions_helpers").OdooFunctionDescription} OdooFunctionDescription*/
/**
* @param {string} formula
* @returns {number}
*/
export function getNumberOfAccountFormulas(formula) {
return getOdooFunctions(formula, (functionName) =>
["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"].includes(functionName)
).filter((fn) => fn.isMatched).length;
}
/**
* Get the first Account function description of the given formula.
*
* @param {string} formula
* @returns {OdooFunctionDescription | undefined}
*/
export function getFirstAccountFunction(formula) {
return getOdooFunctions(formula, (functionName) =>
["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"].includes(functionName)
).find((fn) => fn.isMatched);
}