@silexpert/core 1.1.36 → 1.1.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
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",
@@ -3,13 +3,14 @@ import * as dayjs from 'dayjs';
3
3
  import { round } from 'lodash';
4
4
  import { Cerfa3514_2022, PayloadCerfa3514_2022 } from '../../../types/Interface/api/cerfa/3514';
5
5
  import { CerfaPayloadForm } from '../../../types/Interface/api/cerfa/ReadCerfa';
6
+ import { setZeroIfIsNegative } from '../utils';
6
7
 
7
8
  export function getCerfa3514Century22Payload(payload: PayloadCerfa3514_2022): Cerfa3514_2022 {
8
9
  const shouldHaveVatCode = isDefined(payload.setting?.tvaCode) && isDefined(payload.society.siret);
9
10
 
10
11
  const currentMonth = dayjs(payload.startDate).month() + 1;
11
12
 
12
- const previousCA12Rate = round(currentMonth === 7 ? (payload.previousCA12?.total ?? 0) * 0.55 : currentMonth === 1 ? (payload.previousCA12?.total ?? 0) * 0.4 : 0);
13
+ const previousCA12Rate = round(currentMonth === 7 ? (payload.previousCA12?.total ?? 0) * 0.4 : currentMonth === 1 ? (payload.previousCA12?.total ?? 0) * 0.55 : 0);
13
14
  const previousCA12Credit = round((payload.previousCA12?.recapitulation?.balance ?? 0) + (payload.previousCA12?.recapitulation?.imputedCredit ?? 0));
14
15
 
15
16
  const data: Cerfa3514_2022 = {
@@ -60,8 +61,8 @@ export function getCerfa3514Century22Payload(payload: PayloadCerfa3514_2022): Ce
60
61
  vatRefundedOnInvests: 0, // Calculé plus bas
61
62
  };
62
63
 
63
- data.vatAmountToPay = (data.amountWanted ?? 0) - (data.amountOfCredit ?? 0);
64
- data.vatAmountQuarter = (data.vatAmountDeductible ?? 0) - (data.vatAmountCollected ?? 0);
64
+ data.vatAmountToPay = setZeroIfIsNegative((data.amountWanted ?? 0) - (data.amountOfCredit ?? 0));
65
+ data.vatAmountQuarter = setZeroIfIsNegative((data.vatAmountDeductible ?? 0) - (data.vatAmountCollected ?? 0));
65
66
  data.vatRefundedOnInvests = data.vatAmountQuarter > 760 ? data.vatAmountQuarter : 0;
66
67
 
67
68
  return data;
@@ -311,7 +311,7 @@ export function getCerfa3517Century23Payload(accountingEntries: IAccountingEntry
311
311
  };
312
312
 
313
313
  data.vat.total.tax = data.vat.normalRate20.tax + data.vat.normalRate20OnPetrol.tax + data.vat.reduceRate5Dot5.tax + data.vat.reduceRate10.tax + data.vat.reduceRate8Dot5.tax + data.vat.reduceRate2Dot1.tax + data.vat.particularRate.tax + data.vat.reducedRateOnPetrol.tax + data.vat.oldRate.tax + data.vat.energyBought.tax + data.vat.prestation.tax + data.vat.prestation2.tax + data.vat.saleOfImmobilization.tax + data.vat.ownDelivery.tax + data.vat.other.tax;
314
- data.other.total = data.other.refund + data.other.previousDeducted + data.other.sum;
314
+ data.other.total = data.vat.total.tax + data.other.refund + data.other.previousDeducted + data.other.sum;
315
315
  data.deductible.total1 = data.deductible.onInvoice + data.deductible.onFlatRate;
316
316
  data.deductible.total = data.deductible.total1 + data.deductible.onImmobilization + data.deductible.previousCredit + data.deductible.forget + data.deductible.sumToImpute;
317
317