@viridial/shared 1.0.27 → 1.0.29
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.
|
@@ -5,8 +5,6 @@ import type { Subscription, Invoice, Plan, BillingStats, SubscriptionCreate, Sub
|
|
|
5
5
|
export declare const billingService: {
|
|
6
6
|
/**
|
|
7
7
|
* Récupérer toutes les abonnements
|
|
8
|
-
* Note: Le backend n'a pas d'endpoint GET /api/billing/subscriptions
|
|
9
|
-
* On utilise /expiring avec une date très lointaine comme workaround
|
|
10
8
|
*/
|
|
11
9
|
getAllSubscriptions(params?: {
|
|
12
10
|
organizationId?: number;
|
|
@@ -30,6 +28,34 @@ export declare const billingService: {
|
|
|
30
28
|
* Mettre à jour un abonnement
|
|
31
29
|
*/
|
|
32
30
|
updateSubscription(id: number, data: SubscriptionUpdate): Promise<Subscription>;
|
|
31
|
+
/**
|
|
32
|
+
* Créer une facture
|
|
33
|
+
*/
|
|
34
|
+
createInvoice(data: {
|
|
35
|
+
subscriptionId: number;
|
|
36
|
+
amount: number;
|
|
37
|
+
taxAmount?: number;
|
|
38
|
+
}): Promise<Invoice>;
|
|
39
|
+
/**
|
|
40
|
+
* Récupérer une facture par numéro
|
|
41
|
+
*/
|
|
42
|
+
getInvoiceByNumber(invoiceNumber: string): Promise<Invoice>;
|
|
43
|
+
/**
|
|
44
|
+
* Récupérer les factures en retard
|
|
45
|
+
*/
|
|
46
|
+
getOverdueInvoices(date?: string): Promise<Invoice[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Mettre à jour le statut d'une facture
|
|
49
|
+
*/
|
|
50
|
+
updateInvoiceStatus(id: number, status: string): Promise<Invoice>;
|
|
51
|
+
/**
|
|
52
|
+
* Télécharger une facture en PDF
|
|
53
|
+
*/
|
|
54
|
+
downloadInvoicePdf(id: number): Promise<Blob>;
|
|
55
|
+
/**
|
|
56
|
+
* Générer automatiquement une facture pour un abonnement
|
|
57
|
+
*/
|
|
58
|
+
generateInvoiceForSubscription(subscriptionId: number): Promise<Invoice>;
|
|
33
59
|
/**
|
|
34
60
|
* Annuler un abonnement
|
|
35
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.service.d.ts","sourceRoot":"","sources":["../../api/billing.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE/H;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB
|
|
1
|
+
{"version":3,"file":"billing.service.d.ts","sourceRoot":"","sources":["../../api/billing.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE/H;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;iCACgC;QACjC,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAoB3B;;OAEG;4BAC2B,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK5D;;OAEG;wDACuD,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAOxF;;OAEG;6BAC4B,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAKzE;;OAEG;2BAC0B,MAAM,QAAQ,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAKrF;;OAEG;wBACuB;QACxB,cAAc,EAAE,MAAM,CAAA;QACtB,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,GAAG,OAAO,CAAC,OAAO,CAAC;IAKpB;;OAEG;sCACqC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjE;;OAEG;8BAC6B,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAM3D;;OAEG;4BAC2B,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvE;;OAEG;2BAC0B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;OAEG;mDACkD,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO9E;;OAEG;2BAC0B,MAAM,eAAe,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQhF;;OAEG;0BACyB,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK1D;;OAEG;oCACmC,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAStE;;OAEG;4BAC2B;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAKtB;;OAEG;uBACsB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlD;;OAEG;8CAC6C,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAO3E;;OAEG;0BACyB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrD;;;;OAIG;gBACe,OAAO,CAAC,YAAY,CAAC;IA8BvC;;OAEG;mBACkB,OAAO,CAAC,IAAI,EAAE,CAAC;IAKpC;;OAEG;oBACmB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI7C,CAAA"}
|
|
@@ -6,21 +6,15 @@ import { API_ENDPOINTS } from '../constants/api.constants';
|
|
|
6
6
|
export const billingService = {
|
|
7
7
|
/**
|
|
8
8
|
* Récupérer toutes les abonnements
|
|
9
|
-
* Note: Le backend n'a pas d'endpoint GET /api/billing/subscriptions
|
|
10
|
-
* On utilise /expiring avec une date très lointaine comme workaround
|
|
11
9
|
*/
|
|
12
10
|
async getAllSubscriptions(params) {
|
|
13
|
-
|
|
14
|
-
// TODO: Créer un endpoint GET /api/billing/subscriptions dans le backend
|
|
15
|
-
const futureDate = new Date();
|
|
16
|
-
futureDate.setFullYear(futureDate.getFullYear() + 100); // 100 ans dans le futur
|
|
17
|
-
const response = await httpClient.get(API_ENDPOINTS.BILLING.SUBSCRIPTIONS.EXPIRING, { params: { date: futureDate.toISOString() } });
|
|
18
|
-
let subscriptions = response.data || [];
|
|
19
|
-
// Filtrer par status si fourni
|
|
11
|
+
const queryParams = {};
|
|
20
12
|
if (params?.status) {
|
|
21
|
-
|
|
13
|
+
queryParams.status = params.status;
|
|
22
14
|
}
|
|
23
|
-
|
|
15
|
+
const response = await httpClient.get(API_ENDPOINTS.BILLING.SUBSCRIPTIONS.BASE, { params: queryParams });
|
|
16
|
+
let subscriptions = response.data || [];
|
|
17
|
+
// Filtrer par organizationId côté client si fourni (le backend ne le supporte pas encore)
|
|
24
18
|
if (params?.organizationId) {
|
|
25
19
|
subscriptions = subscriptions.filter(s => s.organizationId === params.organizationId);
|
|
26
20
|
}
|
|
@@ -54,6 +48,48 @@ export const billingService = {
|
|
|
54
48
|
const response = await httpClient.put(API_ENDPOINTS.BILLING.SUBSCRIPTIONS.BY_ID(id), data);
|
|
55
49
|
return response.data;
|
|
56
50
|
},
|
|
51
|
+
/**
|
|
52
|
+
* Créer une facture
|
|
53
|
+
*/
|
|
54
|
+
async createInvoice(data) {
|
|
55
|
+
const response = await httpClient.post(API_ENDPOINTS.BILLING.INVOICES.BASE, data);
|
|
56
|
+
return response.data;
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Récupérer une facture par numéro
|
|
60
|
+
*/
|
|
61
|
+
async getInvoiceByNumber(invoiceNumber) {
|
|
62
|
+
const response = await httpClient.get(API_ENDPOINTS.BILLING.INVOICES.BY_NUMBER(invoiceNumber));
|
|
63
|
+
return response.data;
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Récupérer les factures en retard
|
|
67
|
+
*/
|
|
68
|
+
async getOverdueInvoices(date) {
|
|
69
|
+
const params = date ? { date } : {};
|
|
70
|
+
const response = await httpClient.get(API_ENDPOINTS.BILLING.INVOICES.OVERDUE, { params });
|
|
71
|
+
return response.data || [];
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Mettre à jour le statut d'une facture
|
|
75
|
+
*/
|
|
76
|
+
async updateInvoiceStatus(id, status) {
|
|
77
|
+
const response = await httpClient.put(API_ENDPOINTS.BILLING.INVOICES.UPDATE_STATUS(id), { status });
|
|
78
|
+
return response.data;
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Télécharger une facture en PDF
|
|
82
|
+
*/
|
|
83
|
+
async downloadInvoicePdf(id) {
|
|
84
|
+
return await httpClient.getBlob(`${API_ENDPOINTS.BILLING.INVOICES.BY_ID(id)}/download`);
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Générer automatiquement une facture pour un abonnement
|
|
88
|
+
*/
|
|
89
|
+
async generateInvoiceForSubscription(subscriptionId) {
|
|
90
|
+
const response = await httpClient.post(`${API_ENDPOINTS.BILLING.INVOICES.BASE}/subscription/${subscriptionId}/generate`);
|
|
91
|
+
return response.data;
|
|
92
|
+
},
|
|
57
93
|
/**
|
|
58
94
|
* Annuler un abonnement
|
|
59
95
|
*/
|
|
@@ -9,6 +9,7 @@ declare class HttpClient {
|
|
|
9
9
|
private setupInterceptors;
|
|
10
10
|
private handleError;
|
|
11
11
|
get<T>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
12
|
+
getBlob(url: string, config?: AxiosRequestConfig): Promise<Blob>;
|
|
12
13
|
post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
13
14
|
put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
14
15
|
patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.client.d.ts","sourceRoot":"","sources":["../../api/http.client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAsB,KAAK,kBAAkB,EAAsB,MAAM,OAAO,CAAA;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,oBAAoB,CAAA;AAgB/D;;GAEG;AACH,cAAM,UAAU;IACd,OAAO,CAAC,MAAM,CAAe;gBAEjB,OAAO,CAAC,EAAE,MAAM;IAc5B,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,WAAW;IAcb,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IASzE,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAStF,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IASrF,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IASvF,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAQnF;AAED,eAAO,MAAM,UAAU,YAAmB,CAAA"}
|
|
1
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
CHANGED
|
@@ -91,6 +91,13 @@ class HttpClient {
|
|
|
91
91
|
message: 'Success'
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
+
async getBlob(url, config) {
|
|
95
|
+
const response = await this.client.get(url, {
|
|
96
|
+
...config,
|
|
97
|
+
responseType: 'blob'
|
|
98
|
+
});
|
|
99
|
+
return response.data;
|
|
100
|
+
}
|
|
94
101
|
async post(url, data, config) {
|
|
95
102
|
const response = await this.client.post(url, data, config);
|
|
96
103
|
return {
|