@silexpert/core 2.0.122 → 2.0.123-0

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,5 @@
1
1
  import { t as __name } from "../rolldown-runtime-BhWHdk3m.mjs";
2
- import { $q as ReadCommercialMailTemplate, JJ as CreateInvoiceDocument, Qq as ReadCommercialDocumentTemplate, YJ as CreateMailHeader, ZJ as CreatePreSaleDocument, gX as EstimateInvoiceType, lW as IUser } from "../index-BTRchHCY.mjs";
2
+ import { $q as ReadCommercialMailTemplate, JJ as CreateInvoiceDocument, Qq as ReadCommercialDocumentTemplate, YJ as CreateMailHeader, ZJ as CreatePreSaleDocument, gX as EstimateInvoiceType, lW as IUser } from "../index-DlYrtlbn.mjs";
3
3
  import "dayjs/locale/fr.js";
4
4
  //#region ts/utils/email.d.ts
5
5
  export declare function getHoraires(user: IUser): "Du lundi au vendredi de 9h à 18h" | "Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "2.0.122",
3
+ "version": "2.0.123-0",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "keywords": [
6
6
  "accounting",
@@ -51,6 +51,10 @@ export class Registration extends Resource {
51
51
  return this.axios.$post(`/registrations/${id}/declare`, params);
52
52
  }
53
53
 
54
+ synchronize(idRegistration: number): Promise<ReadRegistration> {
55
+ return this.axios.$post(`/registrations/${idRegistration}/synchronize`);
56
+ }
57
+
54
58
  delete(idSociety: number, idRegistration: number): Promise<true> {
55
59
  return this.axios.$delete(`/societies/${idSociety}/registrations/${idRegistration}`);
56
60
  }
package/ts/utils/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from './commercialOffer.js';
21
21
  export * from './societyApproval.js';
22
22
  export * from './commercialManagement/saleEmail.js';
23
23
  export * from './acdVat.js';
24
+ export * from './vat/registration.js';
24
25
  export * from './transforms/boolean.transform.js';
25
26
  export * from './transforms/number.transform.js';
26
27
  export * from './transforms/numericEnum.transform.js';
@@ -27,6 +27,14 @@ const waitingState: ReadRegistrationTick = {
27
27
  isPayment: false,
28
28
  };
29
29
 
30
+ // Aspone recipient types displayed under their historical name.
31
+ const RECIPIENT_TYPE_LABELS: Record<string, string> = { TAX_ADMINISTRATION: 'DGFiP' };
32
+
33
+ function getDeclarationTickType(declaration: ReadDeclaration): string | null {
34
+ if (!isDefined(declaration?.type) || !isDefined(declaration?.declarationType?.label)) return null;
35
+ return `${RECIPIENT_TYPE_LABELS[declaration.type] ?? declaration.type} - ${declaration.declarationType.label}`;
36
+ }
37
+
30
38
  export function getTicks(registration: ReadRegistration): ReadRegistrationTick[][] {
31
39
  const declarations: Array<ReadDeclaration> = registration.response?.declarations ?? [];
32
40
  const history: InterchangeHistory[] = registration.response?.history;
@@ -35,28 +43,43 @@ export function getTicks(registration: ReadRegistration): ReadRegistrationTick[]
35
43
  const data: ReadRegistrationTick[][] = [];
36
44
 
37
45
  declarations.forEach((declaration) => {
38
- const result = [
46
+ const result: ReadRegistrationTick[] = [
39
47
  {
40
- type:
41
- isDefined(declaration?.type) && isDefined(declaration?.declarationType?.label)
42
- ? `${declaration?.type} - ${declaration?.declarationType?.label}`
43
- : null,
48
+ type: getDeclarationTickType(declaration),
44
49
  state: RegistrationTickState.FINISHED,
45
50
  title: 'Déclaration envoyée',
46
51
  details: [],
47
52
  date: registration.sendAt ? dayjs(registration.sendAt).toISOString() : null,
48
53
  isPayment: false,
49
54
  },
50
- waitingState,
51
- waitingState,
52
- waitingState,
55
+ ...(declaration.states?.length
56
+ ? [...declaration.states].reverse().map((d: InterchangeHistory) => ({
57
+ state: d.isError ? RegistrationTickState.FAILED : RegistrationTickState.FINISHED,
58
+ title: d.label ?? null,
59
+ details: d?.stateDetailsHistory,
60
+ date: d.date ?? null,
61
+ }))
62
+ : []),
53
63
  ];
54
64
 
55
- if (registration.amountToPay && registration.amountToPay > 0) {
65
+ for (let index = declaration.states?.length ?? 0; index < 3; index++) {
66
+ result.push({ ...waitingState, title: null });
67
+ }
68
+
69
+ if (isDefined(declaration.payment)) {
56
70
  result.push({
57
- ...waitingState,
71
+ state: declaration.payment.isError
72
+ ? RegistrationTickState.FAILED
73
+ : declaration.payment.isError === null
74
+ ? RegistrationTickState.IN_PROGRESS
75
+ : RegistrationTickState.FINISHED,
76
+ title: declaration.payment?.label ?? '',
77
+ details: [],
58
78
  isPayment: true,
79
+ date: declaration.payment.date ?? null,
59
80
  });
81
+ } else if (registration.amountToPay && registration.amountToPay > 0) {
82
+ result.push({ ...waitingState, isPayment: true });
60
83
  }
61
84
 
62
85
  data.push(result);
@@ -99,10 +122,7 @@ export function getTicks(registration: ReadRegistration): ReadRegistrationTick[]
99
122
  declarations.forEach((declaration) => {
100
123
  const response: ReadRegistrationTick[] = [
101
124
  {
102
- type:
103
- isDefined(declaration?.type) && isDefined(declaration?.declarationType?.label)
104
- ? `${declaration?.type} - ${declaration?.declarationType?.label}`
105
- : null,
125
+ type: getDeclarationTickType(declaration),
106
126
  state: RegistrationTickState.FINISHED,
107
127
  title: 'Déclaration envoyée',
108
128
  date: registration.sendAt ? dayjs(registration.sendAt).toISOString() : null,