odoo18/addons/spreadsheet_account/static/src/utils.js

30 lines
820 B
JavaScript

/** @odoo-module **/
// @ts-check
import { helpers } from "@odoo/o-spreadsheet";
const { getFunctionsFromTokens } = helpers;
/**
* @typedef {import("@odoo/o-spreadsheet").Token} Token
* @typedef {import("@spreadsheet/helpers/odoo_functions_helpers").OdooFunctionDescription} OdooFunctionDescription
*/
/**
* @param {Token[]} tokens
* @returns {number}
*/
export function getNumberOfAccountFormulas(tokens) {
return getFunctionsFromTokens(tokens, ["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"]).length;
}
/**
* Get the first Account function description of the given formula.
*
* @param {Token[]} tokens
* @returns {OdooFunctionDescription | undefined}
*/
export function getFirstAccountFunction(tokens) {
return getFunctionsFromTokens(tokens, ["ODOO.BALANCE", "ODOO.CREDIT", "ODOO.DEBIT"])[0];
}