oca-ocb-accounting/odoo-bringout-oca-ocb-spreadsheet_account/spreadsheet_account/static/src/utils.js
2025-08-29 15:20:47 +02:00

26 lines
806 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, ["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"]).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, ["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"]).find(
(fn) => fn.isMatched
);
}