@fragment-dev/cli 2025.11.19 → 2025.11.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LAOHNXFN.js → chunk-2VHWON64.js} +19 -19
- package/dist/{chunk-UXTOXY2F.js → chunk-7N2Q46HP.js} +6 -0
- package/dist/{chunk-65EPGXM5.js → chunk-DD3MOZDA.js} +1 -1
- package/dist/{chunk-IWMNMIA6.js → chunk-EJ2G2JEJ.js} +1 -1
- package/dist/{chunk-GRMPAF2X.js → chunk-EXS5ZS4O.js} +1 -1
- package/dist/{chunk-LCVLN3SZ.js → chunk-G3K3FJ7S.js} +1 -1
- package/dist/{chunk-YGEYBIHA.js → chunk-GBHTHL6T.js} +1 -1
- package/dist/{chunk-ZQHWOO25.js → chunk-M6SFKLXU.js} +1 -1
- package/dist/{chunk-H3DG2EYM.js → chunk-N4SWSXTR.js} +1 -1
- package/dist/{chunk-O5U5EZDT.js → chunk-N6JOCCTG.js} +1 -1
- package/dist/{chunk-3LSL4JNW.js → chunk-NCIRJV5V.js} +1 -1
- package/dist/{chunk-SEXV6TUY.js → chunk-NTPTG2JX.js} +305 -152
- package/dist/{chunk-6Z6OR4JK.js → chunk-OBJHIIXG.js} +1 -1
- package/dist/{chunk-3BFX3ZQM.js → chunk-R7QCNENW.js} +1 -1
- package/dist/{chunk-IVDQ4PQW.js → chunk-SHTFFJEV.js} +1 -1
- package/dist/{chunk-VRHCYGEJ.js → chunk-SJKYZPKQ.js} +1 -1
- package/dist/{chunk-BQJEXZ3Z.js → chunk-SQRQUPQM.js} +1 -1
- package/dist/{chunk-LWYIMR7B.js → chunk-SXJZMK5W.js} +1 -1
- package/dist/{chunk-JVO2IFFR.js → chunk-U5H3AES6.js} +1 -1
- package/dist/{chunk-P2FYO77R.js → chunk-UWS3TQHL.js} +1 -1
- package/dist/{chunk-J4ZTYY6X.js → chunk-WWLJSN25.js} +1 -1
- package/dist/{chunk-HLAM7IYL.js → chunk-WYGN3U5V.js} +1 -1
- package/dist/{chunk-ZDE3DZ3I.js → chunk-XTMYKL3N.js} +1 -1
- package/dist/{chunk-UOIGY3UB.js → chunk-ZXWT4UIL.js} +1 -1
- package/dist/commands/add-ledger-entry.js +3 -3
- package/dist/commands/create-custom-link.js +3 -3
- package/dist/commands/create-ledger.js +3 -3
- package/dist/commands/delete-custom-txs.js +3 -3
- package/dist/commands/delete-ledger.js +3 -3
- package/dist/commands/delete-schema.js +3 -3
- package/dist/commands/gen-graphql.js +2 -2
- package/dist/commands/get-schema.js +3 -3
- package/dist/commands/migrate-ledger-entry.js +3 -3
- package/dist/commands/query/ledgerAccounts.js +3 -3
- package/dist/commands/query/ledgers.js +3 -3
- package/dist/commands/query/schema.js +3 -3
- package/dist/commands/query/schemas.js +3 -3
- package/dist/commands/reverse-ledger-entry.js +3 -3
- package/dist/commands/store-schema.js +3 -3
- package/dist/commands/token.js +3 -3
- package/dist/commands/update-ledger-account.js +3 -3
- package/dist/commands/verify-schema.js +3 -3
- package/dist/commands/workspace.js +3 -3
- package/dist/commands.js +24 -24
- package/dist/index.js +24 -24
- package/dist/lib/authenticatedCommand.js +2 -2
- package/dist/lib/sdk.js +3 -1
- package/dist/utils/schemaValidation.js +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -4736,6 +4736,123 @@ var getEntryTypeVersion = ({
|
|
|
4736
4736
|
|
|
4737
4737
|
// ../../libs/schema-validation/utils/transformers/account.ts
|
|
4738
4738
|
init_cjs_shims();
|
|
4739
|
+
var validateAccountCurrency = ({
|
|
4740
|
+
currency,
|
|
4741
|
+
currencyMode,
|
|
4742
|
+
key,
|
|
4743
|
+
name,
|
|
4744
|
+
path
|
|
4745
|
+
}) => {
|
|
4746
|
+
const errors = [];
|
|
4747
|
+
if (currency && currencyMode === "multi") {
|
|
4748
|
+
errors.push({
|
|
4749
|
+
message: `Currency cannot be set for a multi-currency Ledger Account (key: ${key}, name: ${name})`,
|
|
4750
|
+
path: [...path, "currency"]
|
|
4751
|
+
});
|
|
4752
|
+
}
|
|
4753
|
+
if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
|
|
4754
|
+
if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
|
|
4755
|
+
errors.push({
|
|
4756
|
+
message: `Must provide custom currency ID for custom currency (key: ${key}, name: ${name})`,
|
|
4757
|
+
path: [...path, "currency", "customCurrencyId"]
|
|
4758
|
+
});
|
|
4759
|
+
} else if (currency.code !== "CUSTOM") {
|
|
4760
|
+
errors.push({
|
|
4761
|
+
message: `Currency code '${currency.code}' is invalid (key: ${key}, name: ${name})`,
|
|
4762
|
+
path: [...path, "currency", "code"]
|
|
4763
|
+
});
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4766
|
+
return errors;
|
|
4767
|
+
};
|
|
4768
|
+
var validateAccountLinkedAccount = ({
|
|
4769
|
+
linkedAccount,
|
|
4770
|
+
children,
|
|
4771
|
+
template,
|
|
4772
|
+
isTemplateChild,
|
|
4773
|
+
key,
|
|
4774
|
+
name,
|
|
4775
|
+
path
|
|
4776
|
+
}) => {
|
|
4777
|
+
const errors = [];
|
|
4778
|
+
if (!linkedAccount) {
|
|
4779
|
+
return errors;
|
|
4780
|
+
}
|
|
4781
|
+
if ((children ?? []).length > 0) {
|
|
4782
|
+
errors.push({
|
|
4783
|
+
message: `Linked Ledger Accounts cannot have children (key: ${key}, name: ${name})`,
|
|
4784
|
+
path: [...path, "children"]
|
|
4785
|
+
});
|
|
4786
|
+
}
|
|
4787
|
+
const { id, linkId, externalId } = linkedAccount;
|
|
4788
|
+
if (!id && !(externalId && linkId)) {
|
|
4789
|
+
errors.push({
|
|
4790
|
+
message: `Linked Ledger Accounts must specify both External ID + Link ID or the Fragment ID. (key: ${key}, name: ${name})`,
|
|
4791
|
+
path: [...path, "linkedAccount"]
|
|
4792
|
+
});
|
|
4793
|
+
}
|
|
4794
|
+
const doesNotExistOrNoParams = (arg) => arg === void 0 || getSchemaObjectParameters(arg).length === 0;
|
|
4795
|
+
if ((isTemplateChild || template) && [id, linkId, externalId].every(doesNotExistOrNoParams)) {
|
|
4796
|
+
errors.push({
|
|
4797
|
+
message: `Template accounts (and their children) cannot have linkedAccount properties hardcoded. You must provide parameters in the ExternalAccountMatchInput. (key: ${key}, name: ${name})`,
|
|
4798
|
+
path: [...path, "linkedAccount"]
|
|
4799
|
+
});
|
|
4800
|
+
}
|
|
4801
|
+
if (id) {
|
|
4802
|
+
errors.push(
|
|
4803
|
+
...safeGetZodErrors(ParameterizedString, id, [
|
|
4804
|
+
...path,
|
|
4805
|
+
"linkedAccount",
|
|
4806
|
+
"id"
|
|
4807
|
+
])
|
|
4808
|
+
);
|
|
4809
|
+
}
|
|
4810
|
+
if (linkId) {
|
|
4811
|
+
errors.push(
|
|
4812
|
+
...safeGetZodErrors(ParameterizedString, linkId, [
|
|
4813
|
+
...path,
|
|
4814
|
+
"linkedAccount",
|
|
4815
|
+
"linkId"
|
|
4816
|
+
])
|
|
4817
|
+
);
|
|
4818
|
+
}
|
|
4819
|
+
if (externalId) {
|
|
4820
|
+
errors.push(
|
|
4821
|
+
...safeGetZodErrors(ParameterizedString, externalId, [
|
|
4822
|
+
...path,
|
|
4823
|
+
"linkedAccount",
|
|
4824
|
+
"externalId"
|
|
4825
|
+
])
|
|
4826
|
+
);
|
|
4827
|
+
}
|
|
4828
|
+
return errors;
|
|
4829
|
+
};
|
|
4830
|
+
var validateAccountClearing = ({
|
|
4831
|
+
clearing,
|
|
4832
|
+
linkedAccount,
|
|
4833
|
+
children,
|
|
4834
|
+
key,
|
|
4835
|
+
name,
|
|
4836
|
+
path
|
|
4837
|
+
}) => {
|
|
4838
|
+
const errors = [];
|
|
4839
|
+
if (!clearing) {
|
|
4840
|
+
return errors;
|
|
4841
|
+
}
|
|
4842
|
+
if (linkedAccount) {
|
|
4843
|
+
errors.push({
|
|
4844
|
+
message: `Clearing accounts cannot be Linked Ledger Accounts (key: ${key}, name: ${name})`,
|
|
4845
|
+
path: [...path, "clearing"]
|
|
4846
|
+
});
|
|
4847
|
+
}
|
|
4848
|
+
if ((children ?? []).length > 0) {
|
|
4849
|
+
errors.push({
|
|
4850
|
+
message: `Clearing accounts cannot have children (key: ${key}, name: ${name})`,
|
|
4851
|
+
path: [...path, "clearing"]
|
|
4852
|
+
});
|
|
4853
|
+
}
|
|
4854
|
+
return errors;
|
|
4855
|
+
};
|
|
4739
4856
|
var validateAccount = ({
|
|
4740
4857
|
account,
|
|
4741
4858
|
path,
|
|
@@ -4777,88 +4894,36 @@ var validateAccount = ({
|
|
|
4777
4894
|
path: [...path, "type"]
|
|
4778
4895
|
});
|
|
4779
4896
|
}
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
if (linkId) {
|
|
4811
|
-
errors.push(
|
|
4812
|
-
...safeGetZodErrors(ParameterizedString, linkId, [
|
|
4813
|
-
...path,
|
|
4814
|
-
"linkedAccount",
|
|
4815
|
-
"linkId"
|
|
4816
|
-
])
|
|
4817
|
-
);
|
|
4818
|
-
}
|
|
4819
|
-
if (externalId) {
|
|
4820
|
-
errors.push(
|
|
4821
|
-
...safeGetZodErrors(ParameterizedString, externalId, [
|
|
4822
|
-
...path,
|
|
4823
|
-
"linkedAccount",
|
|
4824
|
-
"externalId"
|
|
4825
|
-
])
|
|
4826
|
-
);
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
if (account.currency && account.currencyMode === "multi") {
|
|
4830
|
-
errors.push({
|
|
4831
|
-
message: `Currency cannot be set for a multi-currency Ledger Account (key: ${account.key}, name: ${account.name})`,
|
|
4832
|
-
path: [...path, "currency"]
|
|
4833
|
-
});
|
|
4834
|
-
}
|
|
4835
|
-
if (account.currency && !SchemaCurrencyMatchInput2.safeParse(account.currency).success) {
|
|
4836
|
-
if (account.currency.code === "CUSTOM" && !account.currency.customCurrencyId) {
|
|
4837
|
-
errors.push({
|
|
4838
|
-
message: `Must provide custom currency ID for custom currency (key: ${account.key}, name: ${account.name})`,
|
|
4839
|
-
path: [...path, "currency", "customCurrencyId"]
|
|
4840
|
-
});
|
|
4841
|
-
} else if (account.currency.code !== "CUSTOM") {
|
|
4842
|
-
errors.push({
|
|
4843
|
-
message: `Currency code '${account.currency.code}' is invalid (key: ${account.key}, name: ${account.name})`,
|
|
4844
|
-
path: [...path, "currency", "code"]
|
|
4845
|
-
});
|
|
4846
|
-
}
|
|
4847
|
-
}
|
|
4848
|
-
if (account.clearing) {
|
|
4849
|
-
if (account.linkedAccount) {
|
|
4850
|
-
errors.push({
|
|
4851
|
-
message: `Clearing accounts cannot be Linked Ledger Accounts (key: ${account.key}, name: ${account.name})`,
|
|
4852
|
-
path: [...path, "clearing"]
|
|
4853
|
-
});
|
|
4854
|
-
}
|
|
4855
|
-
if ((account.children ?? []).length > 0) {
|
|
4856
|
-
errors.push({
|
|
4857
|
-
message: `Clearing accounts cannot have children (key: ${account.key}, name: ${account.name})`,
|
|
4858
|
-
path: [...path, "clearing"]
|
|
4859
|
-
});
|
|
4860
|
-
}
|
|
4861
|
-
}
|
|
4897
|
+
errors.push(
|
|
4898
|
+
...validateAccountLinkedAccount({
|
|
4899
|
+
linkedAccount: account.linkedAccount,
|
|
4900
|
+
children: account.children,
|
|
4901
|
+
template: account.template,
|
|
4902
|
+
isTemplateChild,
|
|
4903
|
+
key: account.key,
|
|
4904
|
+
name: account.name,
|
|
4905
|
+
path
|
|
4906
|
+
})
|
|
4907
|
+
);
|
|
4908
|
+
errors.push(
|
|
4909
|
+
...validateAccountCurrency({
|
|
4910
|
+
currency: account.currency,
|
|
4911
|
+
currencyMode: account.currencyMode,
|
|
4912
|
+
key: account.key,
|
|
4913
|
+
name: account.name,
|
|
4914
|
+
path
|
|
4915
|
+
})
|
|
4916
|
+
);
|
|
4917
|
+
errors.push(
|
|
4918
|
+
...validateAccountClearing({
|
|
4919
|
+
clearing: account.clearing,
|
|
4920
|
+
linkedAccount: account.linkedAccount,
|
|
4921
|
+
children: account.children,
|
|
4922
|
+
key: account.key,
|
|
4923
|
+
name: account.name,
|
|
4924
|
+
path
|
|
4925
|
+
})
|
|
4926
|
+
);
|
|
4862
4927
|
const accountConsistencyErrors = account.consistencyConfig ? validateAccountConsistencySettings(account.consistencyConfig) : { errors: [] };
|
|
4863
4928
|
errors.push(...accountConsistencyErrors.errors);
|
|
4864
4929
|
const status = getAccountStatus(account);
|
|
@@ -5710,123 +5775,201 @@ var validateUniqueByKey = ({
|
|
|
5710
5775
|
}))
|
|
5711
5776
|
);
|
|
5712
5777
|
};
|
|
5713
|
-
var
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5778
|
+
var validateLineKey = (key) => {
|
|
5779
|
+
return validateNonEmptySafeString({
|
|
5780
|
+
value: key,
|
|
5781
|
+
path: ["key"],
|
|
5782
|
+
name: "key",
|
|
5783
|
+
entityName: "Ledger Line"
|
|
5784
|
+
});
|
|
5785
|
+
};
|
|
5786
|
+
var validateLineAmount = (amount, entryType, accountPath, lineKey, entryHasTwoLines, entryHasAnyLineWithTx) => {
|
|
5787
|
+
const validationResults = safeGetZodErrors(
|
|
5788
|
+
ParameterizedAmount(),
|
|
5789
|
+
amount,
|
|
5790
|
+
["amount"]
|
|
5791
|
+
);
|
|
5792
|
+
if (!amount && (!entryHasTwoLines || !entryHasAnyLineWithTx)) {
|
|
5793
|
+
validationResults.push({
|
|
5794
|
+
message: `Must specify amount for line. Amount may only be left blank for 2-line entries reconciling to a linked account, since Fragment can infer it from the tx amount. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5795
|
+
path: ["amount"]
|
|
5796
|
+
});
|
|
5797
|
+
}
|
|
5798
|
+
return validationResults;
|
|
5799
|
+
};
|
|
5800
|
+
var getFullyParameterizedAccount = (accountPath, accountPathToAccount, entryParameters) => {
|
|
5801
|
+
const structuralPath = getStructuralPath(accountPath);
|
|
5802
|
+
const fullParameterizedAccount = accountPathToAccount.get(structuralPath);
|
|
5803
|
+
const account = fullParameterizedAccount && reparameterizeSchemaLedgerAccountInput({
|
|
5804
|
+
account: { ...fullParameterizedAccount, path: structuralPath },
|
|
5805
|
+
entryParameters,
|
|
5806
|
+
fillParamOptions: {
|
|
5807
|
+
allowMissing: true,
|
|
5808
|
+
allowMissingInChildren: true
|
|
5809
|
+
}
|
|
5810
|
+
});
|
|
5811
|
+
return account;
|
|
5812
|
+
};
|
|
5813
|
+
var validateLineAccount = (entryType, lineKey, accountPath, accountPathToAccount, entryParameters) => {
|
|
5814
|
+
const validationResults = safeGetZodErrors(
|
|
5815
|
+
ParameterizedString.refine((s) => s.length > 0, {
|
|
5816
|
+
message: `Ledger Line (${lineKey}) in Ledger Entry (${entryType}) must specify a Ledger Account path`
|
|
5817
|
+
}).refine((s) => !s.includes("#"), {
|
|
5818
|
+
message: `Ledger Line account path '${accountPath}' cannot contain '#'`
|
|
5720
5819
|
}),
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
}).refine((s) => !s.includes("#"), {
|
|
5725
|
-
message: `Ledger Line account path '${line.account.path}' cannot contain '#'`
|
|
5726
|
-
}),
|
|
5727
|
-
line.account.path,
|
|
5728
|
-
["account", "path"]
|
|
5729
|
-
),
|
|
5730
|
-
...safeGetZodErrors(ParameterizedAmount(), line.amount, ["amount"])
|
|
5731
|
-
];
|
|
5732
|
-
const accountPath = line.account.path;
|
|
5820
|
+
accountPath,
|
|
5821
|
+
["account", "path"]
|
|
5822
|
+
);
|
|
5733
5823
|
const structuralPath = getStructuralPath(accountPath);
|
|
5734
5824
|
const instanceValueMap = getInstanceValueByAccountPath(accountPath);
|
|
5735
5825
|
Array.from(instanceValueMap.keys()).forEach((ancestorPath) => {
|
|
5736
5826
|
const structuralAncestorPath = getStructuralPath(ancestorPath);
|
|
5737
5827
|
const ancestor = accountPathToAccount.get(structuralAncestorPath);
|
|
5738
5828
|
if (!ancestor) {
|
|
5739
|
-
|
|
5829
|
+
validationResults.push({
|
|
5740
5830
|
path: ["account"],
|
|
5741
|
-
message: `Entry (${
|
|
5831
|
+
message: `Entry (${entryType}) has a line that refers to a non-existent account path (path: ${accountPath} | line key: ${lineKey})`
|
|
5742
5832
|
});
|
|
5743
5833
|
return;
|
|
5744
5834
|
}
|
|
5745
5835
|
if (ancestor.template && !ancestor.linkedAccount && instanceValueMap.get(ancestorPath) === void 0) {
|
|
5746
|
-
|
|
5836
|
+
validationResults.push({
|
|
5747
5837
|
path: ["account"],
|
|
5748
|
-
message: `Invalid account path for line. This line refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. At: (entry: ${
|
|
5838
|
+
message: `Invalid account path for line. This line refers to a Template Account, but is missing a variable that identifies the instance of the Template Account. For example: ${ancestorPath}:{{var}}. At: (entry: ${entryType} | line key: ${lineKey} | account path: ${accountPath}).`
|
|
5749
5839
|
});
|
|
5750
5840
|
}
|
|
5751
5841
|
});
|
|
5752
|
-
const
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
entryParameters
|
|
5756
|
-
|
|
5757
|
-
allowMissing: true,
|
|
5758
|
-
allowMissingInChildren: true
|
|
5759
|
-
}
|
|
5760
|
-
});
|
|
5842
|
+
const account = getFullyParameterizedAccount(
|
|
5843
|
+
accountPath,
|
|
5844
|
+
accountPathToAccount,
|
|
5845
|
+
entryParameters
|
|
5846
|
+
);
|
|
5761
5847
|
if (instanceValueMap.get(structuralPath) !== void 0 && account && !account.template) {
|
|
5762
|
-
|
|
5763
|
-
message: `Account path may only contain variables for template accounts. (Entry: ${
|
|
5848
|
+
validationResults.push({
|
|
5849
|
+
message: `Account path may only contain variables for template accounts. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5764
5850
|
path: ["account", "path"]
|
|
5765
5851
|
});
|
|
5766
5852
|
}
|
|
5767
5853
|
if (instanceValueMap.get(structuralPath) === "" && account && account.template) {
|
|
5768
|
-
|
|
5769
|
-
message: `Instance value for template account cannot be empty. (Entry: ${
|
|
5854
|
+
validationResults.push({
|
|
5855
|
+
message: `Instance value for template account cannot be empty. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5770
5856
|
path: ["account", "path"]
|
|
5771
5857
|
});
|
|
5772
5858
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5859
|
+
return validationResults;
|
|
5860
|
+
};
|
|
5861
|
+
var validateLineCurrency = (currency, accountPath, accountPathToAccount, entryParameters, lineKey, entryType) => {
|
|
5862
|
+
const validationResults = [];
|
|
5863
|
+
const account = getFullyParameterizedAccount(
|
|
5864
|
+
accountPath,
|
|
5865
|
+
accountPathToAccount,
|
|
5866
|
+
entryParameters
|
|
5867
|
+
);
|
|
5868
|
+
if (currency && account && account.currencyMode === "single" && account.currency && account.currency.code !== currency.code) {
|
|
5869
|
+
if (!getSchemaObjectParameters(currency.code).length && getSchemaObjectParameters(account.currency.code).length) {
|
|
5870
|
+
} else if (getSchemaObjectParameters(currency.code).length && !getSchemaObjectParameters(account.currency.code).length) {
|
|
5871
|
+
validationResults.push({
|
|
5783
5872
|
path: ["currency", "code"],
|
|
5784
|
-
message: `Currency cannot be parameterized on a line posting to a single-currency account, as '${
|
|
5873
|
+
message: `Currency cannot be parameterized on a line posting to a single-currency account, as '${currency.code}' is not always guaranteed to be '${account.currency.code}' (Entry: ${entryType} | line key: ${lineKey} | account path: ${accountPath})`
|
|
5785
5874
|
});
|
|
5786
5875
|
} else {
|
|
5787
|
-
|
|
5876
|
+
validationResults.push({
|
|
5788
5877
|
path: ["currency", "code"],
|
|
5789
|
-
message: `Entry ${
|
|
5878
|
+
message: `Entry ${entryType}'s line ${accountPath} has currency ${currency.code}, which differs from its account's currency ${account.currency?.code}`
|
|
5790
5879
|
});
|
|
5791
5880
|
}
|
|
5792
5881
|
}
|
|
5793
|
-
if (!
|
|
5794
|
-
|
|
5795
|
-
message: `Entry ${
|
|
5882
|
+
if (!currency && account && account.currencyMode === "multi") {
|
|
5883
|
+
validationResults.push({
|
|
5884
|
+
message: `Entry ${entryType}'s line ${accountPath} must have a currency set for multi-currency account (Line key: ${lineKey}, account key: ${account.key})`,
|
|
5796
5885
|
path: ["currency"]
|
|
5797
5886
|
});
|
|
5798
5887
|
}
|
|
5799
|
-
if (
|
|
5800
|
-
if (
|
|
5801
|
-
|
|
5802
|
-
message: `Line must provide custom currency ID for custom currency (Line key: ${
|
|
5888
|
+
if (currency && !SchemaCurrencyMatchInput2.safeParse(currency).success) {
|
|
5889
|
+
if (currency.code === "CUSTOM" && !currency.customCurrencyId) {
|
|
5890
|
+
validationResults.push({
|
|
5891
|
+
message: `Line must provide custom currency ID for custom currency (Line key: ${lineKey}, entry: ${entryType})`,
|
|
5803
5892
|
path: ["currency", "customCurrencyId"]
|
|
5804
5893
|
});
|
|
5805
|
-
} else if (
|
|
5806
|
-
|
|
5807
|
-
message: `Currency code '${
|
|
5894
|
+
} else if (currency.code !== "CUSTOM") {
|
|
5895
|
+
validationResults.push({
|
|
5896
|
+
message: `Currency code '${currency.code}' is invalid (Line key: ${lineKey}, entry: ${entryType})`,
|
|
5808
5897
|
path: ["currency", "code"]
|
|
5809
5898
|
});
|
|
5810
5899
|
}
|
|
5811
5900
|
}
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5901
|
+
return validationResults;
|
|
5902
|
+
};
|
|
5903
|
+
var validateLineTx = (tx, accountPath, accountPathToAccount, entryParameters, lineKey, entryType) => {
|
|
5904
|
+
const validationResults = [];
|
|
5905
|
+
const account = getFullyParameterizedAccount(
|
|
5906
|
+
accountPath,
|
|
5907
|
+
accountPathToAccount,
|
|
5908
|
+
entryParameters
|
|
5909
|
+
);
|
|
5910
|
+
if (tx && account && !account.linkedAccount) {
|
|
5911
|
+
validationResults.push({
|
|
5912
|
+
message: `Cannot specify tx for an unlinked account. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5815
5913
|
path: ["tx"]
|
|
5816
5914
|
});
|
|
5817
5915
|
}
|
|
5818
|
-
if (!
|
|
5819
|
-
|
|
5820
|
-
message: `Must specify tx for a linked account. (Entry: ${
|
|
5916
|
+
if (!tx && account && account.linkedAccount) {
|
|
5917
|
+
validationResults.push({
|
|
5918
|
+
message: `Must specify tx for a linked account. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5821
5919
|
path: ["tx"]
|
|
5822
5920
|
});
|
|
5823
5921
|
}
|
|
5824
|
-
if (account && account.linkedAccount &&
|
|
5825
|
-
|
|
5826
|
-
message: `Must specify one of external ID or ID for the tx. (Entry: ${
|
|
5922
|
+
if (account && account.linkedAccount && tx && !(tx.externalId || tx.id)) {
|
|
5923
|
+
validationResults.push({
|
|
5924
|
+
message: `Must specify one of external ID or ID for the tx. (Entry: ${entryType}'s | Line account path: ${accountPath} | Line key: ${lineKey})`,
|
|
5827
5925
|
path: ["tx"]
|
|
5828
5926
|
});
|
|
5829
5927
|
}
|
|
5928
|
+
return validationResults;
|
|
5929
|
+
};
|
|
5930
|
+
var validateLine = (entryType, entryParameters, entryHasTwoLines, entryHasAnyLineWithTx, line, accountPathToAccount) => {
|
|
5931
|
+
const validationResult = validateLineKey(line.key);
|
|
5932
|
+
const accountPath = line.account.path;
|
|
5933
|
+
const parameters = entryParameters ?? {};
|
|
5934
|
+
validationResult.push(
|
|
5935
|
+
...validateLineAmount(
|
|
5936
|
+
line.amount,
|
|
5937
|
+
entryType,
|
|
5938
|
+
line.account.path,
|
|
5939
|
+
line.key,
|
|
5940
|
+
entryHasTwoLines,
|
|
5941
|
+
entryHasAnyLineWithTx
|
|
5942
|
+
)
|
|
5943
|
+
);
|
|
5944
|
+
validationResult.push(
|
|
5945
|
+
...validateLineAccount(
|
|
5946
|
+
entryType,
|
|
5947
|
+
line.key,
|
|
5948
|
+
accountPath,
|
|
5949
|
+
accountPathToAccount,
|
|
5950
|
+
parameters
|
|
5951
|
+
)
|
|
5952
|
+
);
|
|
5953
|
+
validationResult.push(
|
|
5954
|
+
...validateLineCurrency(
|
|
5955
|
+
line.currency ?? void 0,
|
|
5956
|
+
accountPath,
|
|
5957
|
+
accountPathToAccount,
|
|
5958
|
+
parameters,
|
|
5959
|
+
line.key,
|
|
5960
|
+
entryType
|
|
5961
|
+
)
|
|
5962
|
+
);
|
|
5963
|
+
validationResult.push(
|
|
5964
|
+
...validateLineTx(
|
|
5965
|
+
line.tx ?? void 0,
|
|
5966
|
+
accountPath,
|
|
5967
|
+
accountPathToAccount,
|
|
5968
|
+
parameters,
|
|
5969
|
+
line.key,
|
|
5970
|
+
entryType
|
|
5971
|
+
)
|
|
5972
|
+
);
|
|
5830
5973
|
return validationResult;
|
|
5831
5974
|
};
|
|
5832
5975
|
var isKDefined = (k, line) => {
|
|
@@ -5849,7 +5992,14 @@ var validateBalancedLines = (ledgerEntry, accountPathToAccount) => {
|
|
|
5849
5992
|
...line,
|
|
5850
5993
|
currency: line.currency ?? line.account?.currency
|
|
5851
5994
|
})).filter((line) => isKDefined("currency", line)).filter(
|
|
5852
|
-
(line) => isKDefined("account", line) && validateLine(
|
|
5995
|
+
(line) => isKDefined("account", line) && validateLine(
|
|
5996
|
+
ledgerEntry.type,
|
|
5997
|
+
ledgerEntry.parameters,
|
|
5998
|
+
ledgerEntry.lines.length === 2,
|
|
5999
|
+
ledgerEntry.lines.some((l) => l.tx),
|
|
6000
|
+
line,
|
|
6001
|
+
accountPathToAccount
|
|
6002
|
+
).length === 0
|
|
5853
6003
|
);
|
|
5854
6004
|
if (lines.length < ledgerEntry.lines.length) {
|
|
5855
6005
|
return [];
|
|
@@ -6239,7 +6389,10 @@ var validateEntry = (ledgerEntry, accountPathToAccount) => {
|
|
|
6239
6389
|
errors.push(
|
|
6240
6390
|
...ledgerEntry.lines.flatMap(
|
|
6241
6391
|
(line, idx) => validateLine(
|
|
6242
|
-
ledgerEntry,
|
|
6392
|
+
ledgerEntry.type,
|
|
6393
|
+
ledgerEntry.parameters,
|
|
6394
|
+
ledgerEntry.lines.length === 2,
|
|
6395
|
+
ledgerEntry.lines.some((l) => l.tx),
|
|
6243
6396
|
parameterizeSchemaLedgerLineInput({
|
|
6244
6397
|
line,
|
|
6245
6398
|
entryParameters: ledgerEntry.parameters
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AddLedgerEntry
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-SQRQUPQM.js";
|
|
4
|
+
import "../chunk-SHTFFJEV.js";
|
|
5
|
+
import "../chunk-7N2Q46HP.js";
|
|
6
6
|
import "../chunk-IH6BCA6S.js";
|
|
7
7
|
import "../chunk-UDU5PBTV.js";
|
|
8
8
|
import "../chunk-LJSFUVJW.js";
|