@silexpert/core 1.1.28 → 1.1.30
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/es/types/Interface/api/cerfa/3310.d.ts.map +1 -1
- package/es/types/Interface/api/cerfa/3310.js.map +1 -1
- package/es/utils/vat/3310/century23.d.ts +2 -1
- package/es/utils/vat/3310/century23.d.ts.map +1 -1
- package/es/utils/vat/3310/century23.js +26 -4
- package/es/utils/vat/3310/century23.js.map +1 -1
- package/es/utils/vat/3517/century23.js +3 -3
- package/es/utils/vat/3517/century23.js.map +1 -1
- package/es/utils/vat/utils.d.ts +1 -1
- package/es/utils/vat/utils.d.ts.map +1 -1
- package/es/utils/vat/utils.js +3 -3
- package/es/utils/vat/utils.js.map +1 -1
- package/js/types/Interface/api/cerfa/3310.js.map +1 -1
- package/js/utils/vat/3310/century23.js +25 -3
- package/js/utils/vat/3310/century23.js.map +1 -1
- package/js/utils/vat/3517/century23.js +3 -3
- package/js/utils/vat/3517/century23.js.map +1 -1
- package/js/utils/vat/utils.js +3 -3
- package/js/utils/vat/utils.js.map +1 -1
- package/package.json +1 -1
- package/ts/types/Interface/api/cerfa/3310.ts +1 -1
- package/ts/utils/vat/3310/century23.ts +26 -4
- package/ts/utils/vat/3517/century23.ts +3 -3
- package/ts/utils/vat/utils.ts +3 -3
package/js/utils/vat/utils.js
CHANGED
|
@@ -8,20 +8,20 @@ exports.getTaxAmountByAccountNumber = getTaxAmountByAccountNumber;
|
|
|
8
8
|
exports.textFormatting = textFormatting;
|
|
9
9
|
var _lodash = require("lodash");
|
|
10
10
|
var _Vat = require("../../types/Enum/Vat");
|
|
11
|
-
function getAmountByAccountNumber(accountingEntries, accountsNumber, precision = 0,
|
|
11
|
+
function getAmountByAccountNumber(accountingEntries, accountsNumber, precision = 0, isAbs = false) {
|
|
12
12
|
const accountingEntriesUniq = (0, _lodash.uniqBy)(accountingEntries, 'id');
|
|
13
13
|
const result = (0, _lodash.round)(accountingEntriesUniq.reduce((acc, accountingEntry) => {
|
|
14
14
|
let accTmp = acc;
|
|
15
15
|
accountsNumber.some(number => {
|
|
16
16
|
if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {
|
|
17
|
-
accTmp +=
|
|
17
|
+
accTmp += accountingEntry.debit - accountingEntry.credit;
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
return false;
|
|
21
21
|
});
|
|
22
22
|
return accTmp;
|
|
23
23
|
}, 0), precision);
|
|
24
|
-
return result;
|
|
24
|
+
return isAbs ? Math.abs(result) : result;
|
|
25
25
|
}
|
|
26
26
|
function getTaxAmountByAccountNumber(accountingEntries, accountsNumber, precision = 0) {
|
|
27
27
|
const accountingEntriesUniq = (0, _lodash.uniqBy)(accountingEntries, 'id');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["getAmountByAccountNumber","exports","getTaxAmountByAccountNumber","textFormatting","_lodash","require","_Vat","accountingEntries","accountsNumber","precision","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getAmountByAccountNumber","exports","getTaxAmountByAccountNumber","textFormatting","_lodash","require","_Vat","accountingEntries","accountsNumber","precision","isAbs","accountingEntriesUniq","_uniqBy","result","_round","reduce","acc","accountingEntry","accTmp","some","number","account","toString","startsWith","debit","credit","Math","abs","_b","_a","Object","values","Vat","find","v","id","idVat","value","length","formattedValue","replace","slice"],"sources":["../../../ts/utils/vat/utils.ts"],"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}"],"mappings":";;;;;QAIgBA,wBAAwB,GAAxBA,wBAAwB;AAAAC,OAAA,CAgBxBC,2BAA2B,GAA3BA,2BAA2B;AAAAD,OAAA,CAe3BE,cAAc,GAAdA,cAAc;AAnC9B,IAAAC,OAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEM,SAAUL,wBAAwBA,CAACO,iBAAqC,EAAEC,cAAwB,EAAEC,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,GAAGA,cAAc,CAACE,KAAK,CAAC,CAAC,EAAEH,MAAM,CAAC;IAC5D,OAAOC,cAAc;;EAEvB,OAAO,IAAI;AACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silexpert/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30",
|
|
4
4
|
"description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
|
|
5
5
|
"homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
|
|
6
6
|
"main": "js/index.js",
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as dayjs from 'dayjs';
|
|
2
2
|
import { isDefined } from 'class-validator';
|
|
3
|
-
import { round as _round } from 'lodash';
|
|
3
|
+
import { round as _round, flatten } from 'lodash';
|
|
4
4
|
import { IAccountingEntry } from '../../../types/Interface/models/IAccountingEntry';
|
|
5
5
|
import { Cerfa3310_2023, PayloadCerfa3310_2023 } from '../../../types/Interface/api/cerfa/3310';
|
|
6
6
|
import { Vat } from '../../../types/Enum/Vat';
|
|
7
7
|
import { getAmountByAccountNumber, getTaxAmountByAccountNumber, textFormatting } from '../utils';
|
|
8
8
|
import { AsponeFormFields, CerfaPayloadForm } from '../../../types/Interface/api/cerfa/ReadCerfa';
|
|
9
|
+
import { ReadVatDeclarationUpdatedEntry } from '../../../types/Interface/api/vatDeclaration/ReadVatDeclaration';
|
|
9
10
|
|
|
10
|
-
export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry[], payload: PayloadCerfa3310_2023): Cerfa3310_2023 {
|
|
11
|
+
export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry[], payload: PayloadCerfa3310_2023, updatedEntries: ReadVatDeclarationUpdatedEntry[] = []): Cerfa3310_2023 {
|
|
11
12
|
const shouldHaveVatCode = isDefined(payload.setting?.tvaCode) && isDefined(payload.society.siret);
|
|
12
13
|
const vats = Object.values(Vat);
|
|
13
14
|
|
|
@@ -19,6 +20,27 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
|
|
|
19
20
|
|
|
20
21
|
const vatEntries = accountingEntries.filter((ae) => typeof ae.idVat === 'number') as Array<IAccountingEntry & { idVat: number }>;
|
|
21
22
|
|
|
23
|
+
const oldEntries = flatten(updatedEntries?.map((u) => u.old.entries));
|
|
24
|
+
const newEntries = flatten(updatedEntries?.map((u) => u.new.entries));
|
|
25
|
+
|
|
26
|
+
const collectedOldAmount = getAmountByAccountNumber(oldEntries, ['4457'], 0);
|
|
27
|
+
const collectedNewAmount = getAmountByAccountNumber(newEntries, ['4457'], 0);
|
|
28
|
+
|
|
29
|
+
const deductedOldAmount = getAmountByAccountNumber(oldEntries, ['4456'], 0);
|
|
30
|
+
const deductedNewAmount = getAmountByAccountNumber(newEntries, ['4456'], 0);
|
|
31
|
+
|
|
32
|
+
const mxCollected = collectedNewAmount - collectedOldAmount;
|
|
33
|
+
const mxDeducted = deductedNewAmount - deductedOldAmount;
|
|
34
|
+
|
|
35
|
+
let mxToAdd = 0;
|
|
36
|
+
let mxToSub = 0;
|
|
37
|
+
|
|
38
|
+
if (mxCollected > 0) { mxToAdd += mxCollected; }
|
|
39
|
+
if (mxDeducted < 0) { mxToAdd += Math.abs(mxDeducted); }
|
|
40
|
+
|
|
41
|
+
if (mxCollected < 0) { mxToSub += Math.abs(mxCollected); }
|
|
42
|
+
if (mxDeducted > 0) { mxToSub += mxDeducted; }
|
|
43
|
+
|
|
22
44
|
// Opérations taxées
|
|
23
45
|
const taxedServicesEntries = vatEntries.filter((ae) => frenchVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat));
|
|
24
46
|
const servicesAccounts = ['701', '702', '703', '704', '705', '706', '707', '708', '472'];
|
|
@@ -82,7 +104,7 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
|
|
|
82
104
|
const isNil = payload.isNil === true;
|
|
83
105
|
const isHolidayDeposit = payload.isHolidayDeposit === true;
|
|
84
106
|
|
|
85
|
-
const sumToAdd = isNil ? 0 : isHolidayDeposit ? (_round((payload.previousVatDeclaration?.toPay?.total ?? 0) * 0.8, 2)) : _round(payload.vat?.sumToAdd ?? 0);
|
|
107
|
+
const sumToAdd = isNil ? 0 : isHolidayDeposit ? (_round((payload.previousVatDeclaration?.toPay?.total ?? 0) * 0.8, 2)) : (_round(payload.vat?.sumToAdd ?? 0) + mxToAdd);
|
|
86
108
|
const comment = isHolidayDeposit ? `ACOMPTE CONGES ${payload.comment ?? ''}` : (payload.comment ?? null);
|
|
87
109
|
|
|
88
110
|
const initialPayload: Cerfa3310_2023 = {
|
|
@@ -249,7 +271,7 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
|
|
|
249
271
|
total: isNil || isHolidayDeposit ? 0 : otherDeductibles,
|
|
250
272
|
},
|
|
251
273
|
report,
|
|
252
|
-
toImpute: isNil || isHolidayDeposit ? 0 : _round(payload.vat?.deductible?.toImpute ?? 0),
|
|
274
|
+
toImpute: isNil || isHolidayDeposit ? 0 : (_round(payload.vat?.deductible?.toImpute ?? 0) + mxToSub),
|
|
253
275
|
total: 0, // Calculé plus bas
|
|
254
276
|
onImportOtherThanOilProducts: isNil || isHolidayDeposit ? 0 : otherDeductibles,
|
|
255
277
|
coefficient: isNil || isHolidayDeposit ? 100 : coefficient,
|
|
@@ -35,7 +35,7 @@ export function getCerfa3517Century23Payload(accountingEntries: IAccountingEntry
|
|
|
35
35
|
const saleOfImmobilization = getAmountByAccountNumber(vatEntries.filter((ae) => !withoutTaxVat.includes(ae.idVat) && frenchVat.includes(ae.idVat)), ['775'], 0, true);
|
|
36
36
|
|
|
37
37
|
const onInvoiceDeductible = getAmountByAccountNumber(vatEntries, ['445660'], 0, true);
|
|
38
|
-
const onImmobilizationDeductible = getAmountByAccountNumber(vatEntries, ['
|
|
38
|
+
const onImmobilizationDeductible = getAmountByAccountNumber(vatEntries, ['44562'], 0, true);
|
|
39
39
|
|
|
40
40
|
const julyAdvance: IRegistration | null = payload?.exerciceAdvanceRegistrations?.find((a) => dayjs(a.endDate).month() === 6) ?? null;
|
|
41
41
|
const julyAdvancePayload: Cerfa3514_2022 | null = julyAdvance?.payload?.cerfa3514 ?? null;
|
|
@@ -178,11 +178,11 @@ export function getCerfa3517Century23Payload(accountingEntries: IAccountingEntry
|
|
|
178
178
|
due: 0, // Calculé plus bas
|
|
179
179
|
credit: 0, // Calculé plus bas
|
|
180
180
|
advance1: {
|
|
181
|
-
paid: isNil ? 0 : _round((julyAdvancePayload?.amountWanted ?? 0)
|
|
181
|
+
paid: isNil ? 0 : _round((julyAdvancePayload?.amountWanted ?? 0)),
|
|
182
182
|
toPay: isNil ? 0 : _round(payload.advance1?.toPay ?? 0),
|
|
183
183
|
},
|
|
184
184
|
advance2: {
|
|
185
|
-
paid: isNil ? 0 : _round((decemberAdvancePayload?.amountWanted ?? 0)
|
|
185
|
+
paid: isNil ? 0 : _round((decemberAdvancePayload?.amountWanted ?? 0)),
|
|
186
186
|
toPay: isNil ? 0 : _round(payload.advance2?.toPay ?? 0),
|
|
187
187
|
},
|
|
188
188
|
advance: {
|
package/ts/utils/vat/utils.ts
CHANGED
|
@@ -2,20 +2,20 @@ import { round as _round, uniqBy as _uniqBy } from 'lodash';
|
|
|
2
2
|
import { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';
|
|
3
3
|
import { Vat } from '../../types/Enum/Vat';
|
|
4
4
|
|
|
5
|
-
export function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0,
|
|
5
|
+
export function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0, isAbs = false): number {
|
|
6
6
|
const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');
|
|
7
7
|
const result = _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {
|
|
8
8
|
let accTmp = acc;
|
|
9
9
|
accountsNumber.some((number) => {
|
|
10
10
|
if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {
|
|
11
|
-
accTmp +=
|
|
11
|
+
accTmp += accountingEntry.debit - accountingEntry.credit;
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
});
|
|
16
16
|
return accTmp;
|
|
17
17
|
}, 0), precision);
|
|
18
|
-
return result;
|
|
18
|
+
return isAbs ? Math.abs(result) : result;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {
|