mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
fix HyperFormula custom functions and add FIXED formula (#6645)
* fix custom HyperFormula functions * add FIXED formula * note * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -148,6 +148,7 @@ const LOGICAL_FUNCTIONS = new Set([
|
||||
|
||||
const TEXT_FUNCTIONS = new Set([
|
||||
'TEXT',
|
||||
'FIXED',
|
||||
'CONCATENATE',
|
||||
'LEFT',
|
||||
'RIGHT',
|
||||
|
||||
@@ -511,6 +511,14 @@ export const queryModeFunctions: Record<string, FunctionDef> = {
|
||||
{ name: 'format', description: 'Format' },
|
||||
],
|
||||
},
|
||||
FIXED: {
|
||||
name: 'FIXED',
|
||||
description: t('Formats a number to a fixed amount of decimal places.'),
|
||||
parameters: [
|
||||
{ name: 'number', description: 'Number' },
|
||||
{ name: 'decimals', description: 'Decimals' },
|
||||
],
|
||||
},
|
||||
REPT: {
|
||||
name: 'REPT',
|
||||
description: t('Repeats text specified number of times.'),
|
||||
|
||||
@@ -122,6 +122,14 @@ export const transactionModeFunctions: Record<string, FunctionDef> = {
|
||||
{ name: 'format', description: 'Format' },
|
||||
],
|
||||
},
|
||||
FIXED: {
|
||||
name: 'FIXED',
|
||||
description: t('Formats a number to a fixed amount of decimal places.'),
|
||||
parameters: [
|
||||
{ name: 'number', description: 'Number' },
|
||||
{ name: 'decimals', description: 'Decimals' },
|
||||
],
|
||||
},
|
||||
REPT: {
|
||||
name: 'REPT',
|
||||
description: t('Repeats text specified number of times.'),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { HyperFormula } from 'hyperformula';
|
||||
|
||||
import { send } from 'loot-core/platform/client/fetch';
|
||||
import * as monthUtils from 'loot-core/shared/months';
|
||||
import { q, type Query } from 'loot-core/shared/query';
|
||||
@@ -40,7 +42,6 @@ export function useFormulaExecution(
|
||||
let cancelled = false;
|
||||
|
||||
async function executeFormula() {
|
||||
const { HyperFormula } = await import('hyperformula');
|
||||
let hfInstance: ReturnType<typeof HyperFormula.buildEmpty> | null = null;
|
||||
|
||||
if (!formula || !formula.startsWith('=')) {
|
||||
@@ -118,6 +119,7 @@ export function useFormulaExecution(
|
||||
hfInstance = HyperFormula.buildEmpty({
|
||||
licenseKey: 'gpl-v3',
|
||||
localeLang: typeof locale === 'string' ? locale : 'en-US',
|
||||
language: 'enUS',
|
||||
});
|
||||
|
||||
// Add a sheet and set the formula in cell A1
|
||||
|
||||
Reference in New Issue
Block a user