@silexpert/core 1.1.29 → 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.
@@ -34,9 +34,4 @@ export const AdjustmentTypeList: Array<{ id:AdjustmentTypeId; label: string; cen
34
34
  key: 'vat.deductible.toImpute',
35
35
  inputKey: 'adjustment.notEnoughDeducted',
36
36
  },
37
- ];
38
-
39
- export const VatDeclarationMxAdjustment: Array<{ key: string; label: string; }> = [
40
- { key: 'mx.collected', label: 'Opérations modifiées M-X (collecté)' },
41
- { key: 'mx.deducted', label: 'Opérations modifiées M-X (déductible)' },
42
37
  ];
@@ -175,7 +175,7 @@ export interface Cerfa3310_2023 {
175
175
  ticgn?: Tic,
176
176
  ticc?: Tic,
177
177
  total?: Tic,
178
- }
178
+ },
179
179
  }
180
180
 
181
181
  export type PayloadCerfa3310_2023 = {
@@ -187,10 +187,6 @@ export type PayloadCerfa3310_2023 = {
187
187
  isNil: boolean;
188
188
  previousVatDeclaration: Cerfa3310_2023 | null;
189
189
  sie: ServiceOfTax | null;
190
- mx: {
191
- collected: number;
192
- deducted: number;
193
- };
194
190
  comment?: string;
195
191
  taxedOperations?: {
196
192
  withdrawSuspensiveRegime?: number;
@@ -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) + _round(payload.mx?.collected ?? 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) + _round(payload.mx?.deducted ?? 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,