@silexpert/core 1.1.34 → 1.1.35

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.
@@ -1,5 +1,6 @@
1
1
  import { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';
2
2
  export declare function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision?: number, isAbs?: boolean): number;
3
+ export declare function setZeroIfIsNegative(value: number): number;
3
4
  export declare function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision?: number): number;
4
5
  export declare function textFormatting(value: any, length?: number | null): string | null;
5
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/utils/vat/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAGjF,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,SAAI,EAAE,KAAK,UAAQ,GAAG,MAAM,CAc9I;AAED,wBAAgB,2BAA2B,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,SAAI,GAAG,MAAM,CAalI;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,GAAG,IAAI,CActF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/utils/vat/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAGjF,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,SAAI,EAAE,KAAK,UAAQ,GAAG,MAAM,CAc9I;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,SAAI,GAAG,MAAM,CAalI;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,GAAG,IAAI,CActF"}
@@ -15,6 +15,9 @@ export function getAmountByAccountNumber(accountingEntries, accountsNumber, prec
15
15
  }, 0), precision);
16
16
  return isAbs ? Math.abs(result) : result;
17
17
  }
18
+ export function setZeroIfIsNegative(value) {
19
+ return value < 0 ? 0 : value;
20
+ }
18
21
  export function getTaxAmountByAccountNumber(accountingEntries, accountsNumber, precision = 0) {
19
22
  const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');
20
23
  return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/utils/vat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAE3C,MAAM,UAAU,wBAAwB,CAAC,iBAAqC,EAAE,cAAwB,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK;IACpI,MAAM,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE;QAC1E,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7B,IAAI,eAAe,CAAC,OAAO,IAAI,eAA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G,CAAC,CAAC,CAAC,CAAC;gBACtJ,OAAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAU,EAAE,SAAwB,IAAI;IACrE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACtC,IAAI,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,iCAAiC;QAC9F,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB;QACvE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB;QACvE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,8BAA8B;QACpF,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,oBAAoB;QACzE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB;QACvE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,mCAAmC;QACvF,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,iCAAiC;QACrF,IAAI,MAAM;YAAE,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7D,OAAO,cAAc,CAAC;KACvB;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { round as _round, uniqBy as _uniqBy } from 'lodash';\nimport { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';\nimport { Vat } from '../../types/Enum/Vat';\n\nexport function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0, isAbs = false): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n const result = _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += accountingEntry.debit - accountingEntry.credit;\n return true;\n }\n return false;\n });\n return accTmp;\n }, 0), precision);\n return isAbs ? Math.abs(result) : result;\n}\n\nexport function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += ((accountingEntry.debit - accountingEntry.credit) * (((Object.values(Vat).find((v) => v.id === accountingEntry.idVat)?.value ?? 0) / 100)));\n return true;\n }\n return false;\n });\n return accTmp;\n }, precision));\n}\n\nexport function textFormatting(value: any, length: number | null = null): string | null {\n if (value && typeof value === 'string') {\n let formattedValue = value.replace(/[\\u2018\\u2019]/g, '\\''); // Suppression des \"Curly Quotes\"\n formattedValue = formattedValue.replace(/&/g, ''); // Suppression des &\n formattedValue = formattedValue.replace(/!/g, ''); // Suppression des !\n formattedValue = formattedValue.replace(/[\\t]/g, ''); // Suppression des tabulations\n formattedValue = formattedValue.replace(/`/g, '\\''); // Suppression des `\n formattedValue = formattedValue.replace(/\"/g, ''); // Suppression des \"\n formattedValue = formattedValue.replace(/^ */, ''); // Suppression des espaces de début\n formattedValue = formattedValue.replace(/ *$/, ''); // Suppression des espaces de fin\n if (length) formattedValue = formattedValue.slice(0, length);\n return formattedValue;\n }\n return null;\n}"]}
1
+ {"version":3,"file":"utils.js","sour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OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB;QACvE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,8BAA8B;QACpF,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,oBAAoB;QACzE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB;QACvE,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,mCAAmC;QACvF,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,iCAAiC;QACrF,IAAI,MAAM;YAAE,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7D,OAAO,cAAc,CAAC;KACvB;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { round as _round, uniqBy as _uniqBy } from 'lodash';\nimport { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';\nimport { Vat } from '../../types/Enum/Vat';\n\nexport function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0, isAbs = false): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n const result = _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += accountingEntry.debit - accountingEntry.credit;\n return true;\n }\n return false;\n });\n return accTmp;\n }, 0), precision);\n return isAbs ? Math.abs(result) : result;\n}\n\nexport function setZeroIfIsNegative(value: number): number {\n return value < 0 ? 0 : value;\n}\n\nexport function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += ((accountingEntry.debit - accountingEntry.credit) * (((Object.values(Vat).find((v) => v.id === accountingEntry.idVat)?.value ?? 0) / 100)));\n return true;\n }\n return false;\n });\n return accTmp;\n }, precision));\n}\n\nexport function textFormatting(value: any, length: number | null = null): string | null {\n if (value && typeof value === 'string') {\n let formattedValue = value.replace(/[\\u2018\\u2019]/g, '\\''); // Suppression des \"Curly Quotes\"\n formattedValue = formattedValue.replace(/&/g, ''); // Suppression des &\n formattedValue = formattedValue.replace(/!/g, ''); // Suppression des !\n formattedValue = formattedValue.replace(/[\\t]/g, ''); // Suppression des tabulations\n formattedValue = formattedValue.replace(/`/g, '\\''); // Suppression des `\n formattedValue = formattedValue.replace(/\"/g, ''); // Suppression des \"\n formattedValue = formattedValue.replace(/^ */, ''); // Suppression des espaces de début\n formattedValue = formattedValue.replace(/ *$/, ''); // Suppression des espaces de fin\n if (length) formattedValue = formattedValue.slice(0, length);\n return formattedValue;\n }\n return null;\n}"]}
@@ -3,4 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ class UpdatedAnnotationObject {}
7
+ exports.UpdatedAnnotationObject = UpdatedAnnotationObject;
6
8
  //# sourceMappingURL=ReadRegistration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReadRegistration.js","names":[],"sources":["../../../../../ts/types/Interface/api/registration/ReadRegistration.ts"],"sourcesContent":["import { IRegistration } from '../../models/IRegistration';\nimport {\n IAccount, IAccountingEntry, InterchangeState, RegistrationState, RegistrationTickState,\n} from '../../..';\n\nexport type ReadRegistration = IRegistration & { state: RegistrationState };\n\nexport interface ReadSynchronization {\n id: number;\n hasError: boolean;\n hasDepositError: boolean;\n isProcessFinished: boolean;\n hasPaymentError: boolean;\n isTimeOut: boolean;\n hasFailed: boolean;\n}\n\nexport type ReadRegistrationHistory = InterchangeState;\n\nexport interface ReadRegistrationTick {\n state: RegistrationTickState;\n title: string | null;\n details: InterchangeState,\n date: string | null;\n isPayment?: boolean;\n}\n\nexport interface ReadVatEntry {\n isAsset: boolean;\n idVat: number | null;\n account: IAccount | null;\n totalTaxIncluded: number;\n totalTaxExcluded: number,\n totalTax: number,\n label: string,\n date: Date,\n idAccountingTransaction: number;\n isRevised: boolean;\n entry?: IAccountingEntry\n}\n\nexport type UpdatedAnnotationObject = { old: IAccountingEntry[]; new: IAccountingEntry[] };\n\nexport type UpdatedAnnotation = UpdatedAnnotationObject[];"],"mappings":""}
1
+ {"version":3,"file":"ReadRegistration.js","names":["UpdatedAnnotationObject","exports"],"sources":["../../../../../ts/types/Interface/api/registration/ReadRegistration.ts"],"sourcesContent":["import { IRegistration } from '../../models/IRegistration';\nimport {\n IAccount, IAccountingEntry, InterchangeState, RegistrationState, RegistrationTickState,\n} from '../../..';\n\nexport type ReadRegistration = IRegistration & { state: RegistrationState };\n\nexport interface ReadSynchronization {\n id: number;\n hasError: boolean;\n hasDepositError: boolean;\n isProcessFinished: boolean;\n hasPaymentError: boolean;\n isTimeOut: boolean;\n hasFailed: boolean;\n}\n\nexport type ReadRegistrationHistory = InterchangeState;\n\nexport interface ReadRegistrationTick {\n state: RegistrationTickState;\n title: string | null;\n details: InterchangeState,\n date: string | null;\n isPayment?: boolean;\n}\n\nexport interface ReadVatEntry {\n isAsset: boolean;\n idVat: number | null;\n account: IAccount | null;\n totalTaxIncluded: number;\n totalTaxExcluded: number,\n totalTax: number,\n label: string,\n date: Date,\n idAccountingTransaction: number;\n isRevised: boolean;\n entry?: IAccountingEntry\n}\n\nexport class UpdatedAnnotationObject {\n old: IAccountingEntry[];\n new: IAccountingEntry[];\n}\n\nexport type UpdatedAnnotation = UpdatedAnnotationObject[];"],"mappings":";;;;;AAyCM,MAAOA,uBAAuB;AAGnCC,OAAA,CAHYD,uBAAuB,GAAvBA,uBAAuB"}
@@ -49,49 +49,49 @@ function getCerfa3310Century23Payload(accountingEntries, payload, updatedEntries
49
49
  // Opérations taxées
50
50
  const taxedServicesEntries = vatEntries.filter(ae => frenchVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat));
51
51
  const servicesAccounts = ['701', '702', '703', '704', '705', '706', '707', '708', '472'];
52
- const taxedServicesFromFrance = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries, servicesAccounts, 0, true);
53
- const taxedOther = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => withTaxVat.includes(ae.idVat)), ['775'], 0, true);
52
+ const taxedServicesFromFrance = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries, servicesAccounts, 0, true));
53
+ const taxedOther = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => withTaxVat.includes(ae.idVat)), ['775'], 0, true));
54
54
  const intracommunityServiceAccounts = ['604', '611', '612', '613', '614', '615', '616', '617', '618', '619', '62'];
55
55
  const intracommunityServiceEntries = vatEntries.filter(ae => withTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat));
56
- const taxedPurchaseOfIntracommunityService = (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries, intracommunityServiceAccounts, 0, true);
56
+ const taxedPurchaseOfIntracommunityService = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries, intracommunityServiceAccounts, 0, true));
57
57
  const taxedImportEntries = vatEntries.filter(ae => importationVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat));
58
58
  const taxedImportAccounts = ['6'];
59
- const taxedImport = (0, _utils.getAmountByAccountNumber)(taxedImportEntries, taxedImportAccounts, 0, true);
60
- const taxedIntracommunityAcquisitions = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => intracomVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true);
59
+ const taxedImport = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries, taxedImportAccounts, 0, true));
60
+ const taxedIntracommunityAcquisitions = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => intracomVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true));
61
61
  // Opérations non taxées
62
- const untaxedExportationNotInEurope = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), servicesAccounts, 0, true);
63
- const untaxedOther = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => frenchVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['7'], 0, true);
64
- const untaxedImport = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['6'], 0, true);
65
- const untaxedIntracomunity = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => intracomVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true);
66
- const untaxedIntracommunityDelivery = (0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => withoutTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat)), ['701', '707'], 0, true);
62
+ const untaxedExportationNotInEurope = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), servicesAccounts, 0, true));
63
+ const untaxedOther = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => frenchVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['7'], 0, true));
64
+ const untaxedImport = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['6'], 0, true));
65
+ const untaxedIntracomunity = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => intracomVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true));
66
+ const untaxedIntracommunityDelivery = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(vatEntries.filter(ae => withoutTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat)), ['701', '707'], 0, true));
67
67
  // TVA brute
68
- const normalRate = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), ['6'], 0, true);
68
+ const normalRate = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), ['6'], 0, true));
69
69
  const normalRateTax = (0, _lodash.round)(normalRate * 0.2);
70
- const reducedRate5Dot5 = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), ['6'], 0, true);
70
+ const reducedRate5Dot5 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), ['6'], 0, true));
71
71
  const reducedRate5Dot5Tax = (0, _lodash.round)(reducedRate5Dot5 * 0.055);
72
- const reducedRate10 = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), ['6'], 0, true);
72
+ const reducedRate10 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), ['6'], 0, true));
73
73
  const reducedRate10Tax = (0, _lodash.round)(reducedRate10 * 0.1);
74
- const reducedRate8Dot5 = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), ['6'], 0, true);
74
+ const reducedRate8Dot5 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), ['6'], 0, true));
75
75
  const reducedRate8Dot5Tax = (0, _lodash.round)(reducedRate8Dot5 * 0.085);
76
- const reducedRate2Dot1 = (0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), ['6'], 0, true);
76
+ const reducedRate2Dot1 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedServicesEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), servicesAccounts, 0, true) + (0, _utils.getAmountByAccountNumber)(intracommunityServiceEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), ['6'], 0, true));
77
77
  const reducedRate2Dot1Tax = (0, _lodash.round)(reducedRate2Dot1 * 0.021);
78
- const importNormalRate = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
78
+ const importNormalRate = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 20).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
79
79
  const importNormalRateTax = (0, _lodash.round)(importNormalRate * 0.2);
80
- const importReducedRate10 = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
80
+ const importReducedRate10 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 10).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
81
81
  const importReducedRate10Tax = (0, _lodash.round)(importReducedRate10 * 0.1);
82
- const importReducedRate8Dot5 = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
82
+ const importReducedRate8Dot5 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 8.5).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
83
83
  const importReducedRate8Dot5Tax = (0, _lodash.round)(importReducedRate8Dot5 * 0.085);
84
- const importReducedRate5Dot5 = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
84
+ const importReducedRate5Dot5 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 5.5).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
85
85
  const importReducedRate5Dot5Tax = (0, _lodash.round)(importReducedRate8Dot5 * 0.055);
86
- const importReducedRate2Dot1 = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
86
+ const importReducedRate2Dot1 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 2.1).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
87
87
  const importReducedRate2Dot1Tax = (0, _lodash.round)(importReducedRate2Dot1 * 0.021);
88
- const importReducedRate1Dot05 = (0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 1.05).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
88
+ const importReducedRate1Dot05 = (0, _utils.setZeroIfIsNegative)((0, _utils.getAmountByAccountNumber)(taxedImportEntries.filter(e => vats.filter(v => v.value === 1.05).map(v => v.id).includes(e.idVat)), taxedImportAccounts, 0, true));
89
89
  const importReducedRate1Dot05Tax = (0, _lodash.round)(importReducedRate1Dot05 * 0.0105);
90
- const intracommunityTax = (0, _utils.getTaxAmountByAccountNumber)(intracommunityServiceEntries, intracommunityServiceAccounts);
90
+ const intracommunityTax = (0, _utils.setZeroIfIsNegative)((0, _utils.getTaxAmountByAccountNumber)(intracommunityServiceEntries, intracommunityServiceAccounts));
91
91
  // TVA Déductible
92
- const immobilizationTax = (0, _utils.getTaxAmountByAccountNumber)(vatEntries, ['2']);
93
- const otherGoodsAndServices = (0, _utils.getTaxAmountByAccountNumber)(vatEntries.filter(e => vats.filter(v => !v.isVatImportation).map(v => v.id).includes(e.idVat)), ['6']);
94
- const otherDeductibles = (0, _utils.getTaxAmountByAccountNumber)(vatEntries.filter(e => vats.filter(v => v.isVatImportation).map(v => v.id).includes(e.idVat)), ['6']);
92
+ const immobilizationTax = (0, _utils.setZeroIfIsNegative)((0, _utils.getTaxAmountByAccountNumber)(vatEntries, ['2']));
93
+ const otherGoodsAndServices = (0, _utils.setZeroIfIsNegative)((0, _utils.getTaxAmountByAccountNumber)(vatEntries.filter(e => vats.filter(v => !v.isVatImportation).map(v => v.id).includes(e.idVat)), ['6']));
94
+ const otherDeductibles = (0, _utils.setZeroIfIsNegative)((0, _utils.getTaxAmountByAccountNumber)(vatEntries.filter(e => vats.filter(v => v.isVatImportation).map(v => v.id).includes(e.idVat)), ['6']));
95
95
  const report = (_d = (_c = (_b = payload.previousVatDeclaration) === null || _b === void 0 ? void 0 : _b.credit) === null || _c === void 0 ? void 0 : _c.toReport) !== null && _d !== void 0 ? _d : 0;
96
96
  const coefficient = (0, _lodash.round)((_g = (_f = (_e = payload.vat) === null || _e === void 0 ? void 0 : _e.deductible) === null || _f === void 0 ? void 0 : _f.coefficient) !== null && _g !== void 0 ? _g : 100, 2);
97
97
  const isNil = payload.isNil === true;