@vulog/aima-billing 1.2.36 → 1.2.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/dist/index.d.cts CHANGED
@@ -122,6 +122,84 @@ type RefundableAmount = {
122
122
  refundablePaymentReceipts: Receipt[];
123
123
  refundedPaymentReceipts: Receipt[];
124
124
  };
125
+ /** Billing line item returned by the trip invoices endpoint (nested in Billing array). */
126
+ type TripBillingItem = {
127
+ trip?: unknown;
128
+ product?: unknown;
129
+ vehiculeModelName?: string;
130
+ vehiculePlate?: string;
131
+ modelId?: string;
132
+ userId?: string;
133
+ withoutTaxAmountForDriving?: number;
134
+ withoutTaxAmountForStopover?: number;
135
+ withoutTaxAmountForBooking?: number;
136
+ withoutTaxForOvermileage?: number;
137
+ withoutTaxAmountForStartZoneFee?: number;
138
+ withoutTaxAmountForEndZoneFee?: number;
139
+ withoutTaxAmountForCancellationFee?: number;
140
+ withoutTaxAmountForScheduleTripFee?: number;
141
+ withoutTaxAmountForTripSystemCredit?: number;
142
+ withoutTaxAmountForBillingGroupDiscount?: number | null;
143
+ withTaxAmountForDriving?: number;
144
+ withTaxAmountForStopover?: number;
145
+ withTaxAmountForBooking?: number;
146
+ withTaxForOvermileage?: number;
147
+ withTaxAmountForStartZoneFee?: number;
148
+ withTaxAmountForEndZoneFee?: number;
149
+ withTaxAmountForCancellationFee?: number;
150
+ withTaxAmountForScheduleTripFee?: number;
151
+ withTaxAmountForTripSystemCredit?: number;
152
+ withTaxAmountForBillingGroupDiscount?: number;
153
+ withoutTaxInitialTotalAmount?: number;
154
+ withTaxInitialTotalAmount?: number;
155
+ taxInitialTotalAmount?: number;
156
+ paymentMethodType?: string;
157
+ walletId?: string | null;
158
+ totalTaxAmount?: number;
159
+ totalWithTax?: number;
160
+ totalWithoutTax?: number;
161
+ taxRate?: number;
162
+ taxName?: string;
163
+ withoutTaxAmountRideCost?: number;
164
+ withTaxAmountRideCost?: number;
165
+ taxAmountRideCost?: number;
166
+ products?: unknown[];
167
+ taxesPerRate?: unknown;
168
+ serviceId?: string | null;
169
+ profileId?: string | null;
170
+ profileType?: string | null;
171
+ profileName?: string | null;
172
+ withoutTaxUnlockFee?: number;
173
+ withTaxUnlockFee?: number;
174
+ taxUnlockFee?: number;
175
+ withTaxRefundAmount?: number | null;
176
+ isRefunded?: boolean;
177
+ cityName?: string | null;
178
+ cityId?: string | null;
179
+ tripBillingBreakdown?: unknown;
180
+ pricingId?: string;
181
+ netJourney?: number;
182
+ taxJourney?: number;
183
+ grossJourney?: number;
184
+ durationJourney?: number;
185
+ taxRemainingToBePaid?: number;
186
+ grossRemainingToBePaid?: number;
187
+ netRemainingToBePaid?: number;
188
+ overriddenTripInfo?: unknown;
189
+ interrupted?: boolean;
190
+ interruptedReason?: string | null;
191
+ invoice?: unknown;
192
+ distanceUnit?: string;
193
+ isTaxIncluded?: boolean;
194
+ [key: string]: unknown;
195
+ };
196
+ /** Response shape of GET .../trips/:tripId/invoices */
197
+ type InvoicesByTripIdResponse = {
198
+ balance: number;
199
+ userId: string;
200
+ entityId: string;
201
+ Billing: TripBillingItem[];
202
+ };
125
203
  type Wallet = {
126
204
  initialAmount: number;
127
205
  validityStartDate: string;
@@ -157,7 +235,7 @@ declare const getInvoiceById: (client: Client, id: string) => Promise<Invoice>;
157
235
  declare const getInvoicePdf: (client: Client, invoiceId: string) => Promise<ArrayBuffer | null>;
158
236
  //#endregion
159
237
  //#region src/getInvoicesByTripId.d.ts
160
- declare const getInvoicesByTripId: (client: Client, tripId: string) => Promise<Invoice[]>;
238
+ declare const getInvoicesByTripId: (client: Client, tripId: string) => Promise<InvoicesByTripIdResponse>;
161
239
  //#endregion
162
240
  //#region src/getRefundableAmount.d.ts
163
241
  declare const getRefundableAmount: (client: Client, invoiceId: string) => Promise<RefundableAmount>;
@@ -182,4 +260,4 @@ declare const updateWallet: (client: Client, walletId: string, actions: PatchAct
182
260
  //#region src/payInvoice.d.ts
183
261
  declare const payInvoice: (client: Client, invoiceId: string, manualPayment: ManualPayment) => Promise<Invoice>;
184
262
  //#endregion
185
- export { ChargeProductInfo, Credit, Invoice, ManualPayment, Paths, Receipt, RefundableAmount, Wallet, addCredits, chargeProduct, getInvoiceById, getInvoicePdf, getInvoicesByTripId, getRefundableAmount, getUserCreditsByEntityId, getWalletsByEntity, payInvoice, refund, updateWallet };
263
+ export { ChargeProductInfo, Credit, Invoice, InvoicesByTripIdResponse, ManualPayment, Paths, Receipt, RefundableAmount, TripBillingItem, Wallet, addCredits, chargeProduct, getInvoiceById, getInvoicePdf, getInvoicesByTripId, getRefundableAmount, getUserCreditsByEntityId, getWalletsByEntity, payInvoice, refund, updateWallet };
package/dist/index.d.mts CHANGED
@@ -122,6 +122,84 @@ type RefundableAmount = {
122
122
  refundablePaymentReceipts: Receipt[];
123
123
  refundedPaymentReceipts: Receipt[];
124
124
  };
125
+ /** Billing line item returned by the trip invoices endpoint (nested in Billing array). */
126
+ type TripBillingItem = {
127
+ trip?: unknown;
128
+ product?: unknown;
129
+ vehiculeModelName?: string;
130
+ vehiculePlate?: string;
131
+ modelId?: string;
132
+ userId?: string;
133
+ withoutTaxAmountForDriving?: number;
134
+ withoutTaxAmountForStopover?: number;
135
+ withoutTaxAmountForBooking?: number;
136
+ withoutTaxForOvermileage?: number;
137
+ withoutTaxAmountForStartZoneFee?: number;
138
+ withoutTaxAmountForEndZoneFee?: number;
139
+ withoutTaxAmountForCancellationFee?: number;
140
+ withoutTaxAmountForScheduleTripFee?: number;
141
+ withoutTaxAmountForTripSystemCredit?: number;
142
+ withoutTaxAmountForBillingGroupDiscount?: number | null;
143
+ withTaxAmountForDriving?: number;
144
+ withTaxAmountForStopover?: number;
145
+ withTaxAmountForBooking?: number;
146
+ withTaxForOvermileage?: number;
147
+ withTaxAmountForStartZoneFee?: number;
148
+ withTaxAmountForEndZoneFee?: number;
149
+ withTaxAmountForCancellationFee?: number;
150
+ withTaxAmountForScheduleTripFee?: number;
151
+ withTaxAmountForTripSystemCredit?: number;
152
+ withTaxAmountForBillingGroupDiscount?: number;
153
+ withoutTaxInitialTotalAmount?: number;
154
+ withTaxInitialTotalAmount?: number;
155
+ taxInitialTotalAmount?: number;
156
+ paymentMethodType?: string;
157
+ walletId?: string | null;
158
+ totalTaxAmount?: number;
159
+ totalWithTax?: number;
160
+ totalWithoutTax?: number;
161
+ taxRate?: number;
162
+ taxName?: string;
163
+ withoutTaxAmountRideCost?: number;
164
+ withTaxAmountRideCost?: number;
165
+ taxAmountRideCost?: number;
166
+ products?: unknown[];
167
+ taxesPerRate?: unknown;
168
+ serviceId?: string | null;
169
+ profileId?: string | null;
170
+ profileType?: string | null;
171
+ profileName?: string | null;
172
+ withoutTaxUnlockFee?: number;
173
+ withTaxUnlockFee?: number;
174
+ taxUnlockFee?: number;
175
+ withTaxRefundAmount?: number | null;
176
+ isRefunded?: boolean;
177
+ cityName?: string | null;
178
+ cityId?: string | null;
179
+ tripBillingBreakdown?: unknown;
180
+ pricingId?: string;
181
+ netJourney?: number;
182
+ taxJourney?: number;
183
+ grossJourney?: number;
184
+ durationJourney?: number;
185
+ taxRemainingToBePaid?: number;
186
+ grossRemainingToBePaid?: number;
187
+ netRemainingToBePaid?: number;
188
+ overriddenTripInfo?: unknown;
189
+ interrupted?: boolean;
190
+ interruptedReason?: string | null;
191
+ invoice?: unknown;
192
+ distanceUnit?: string;
193
+ isTaxIncluded?: boolean;
194
+ [key: string]: unknown;
195
+ };
196
+ /** Response shape of GET .../trips/:tripId/invoices */
197
+ type InvoicesByTripIdResponse = {
198
+ balance: number;
199
+ userId: string;
200
+ entityId: string;
201
+ Billing: TripBillingItem[];
202
+ };
125
203
  type Wallet = {
126
204
  initialAmount: number;
127
205
  validityStartDate: string;
@@ -157,7 +235,7 @@ declare const getInvoiceById: (client: Client, id: string) => Promise<Invoice>;
157
235
  declare const getInvoicePdf: (client: Client, invoiceId: string) => Promise<ArrayBuffer | null>;
158
236
  //#endregion
159
237
  //#region src/getInvoicesByTripId.d.ts
160
- declare const getInvoicesByTripId: (client: Client, tripId: string) => Promise<Invoice[]>;
238
+ declare const getInvoicesByTripId: (client: Client, tripId: string) => Promise<InvoicesByTripIdResponse>;
161
239
  //#endregion
162
240
  //#region src/getRefundableAmount.d.ts
163
241
  declare const getRefundableAmount: (client: Client, invoiceId: string) => Promise<RefundableAmount>;
@@ -182,4 +260,4 @@ declare const updateWallet: (client: Client, walletId: string, actions: PatchAct
182
260
  //#region src/payInvoice.d.ts
183
261
  declare const payInvoice: (client: Client, invoiceId: string, manualPayment: ManualPayment) => Promise<Invoice>;
184
262
  //#endregion
185
- export { ChargeProductInfo, Credit, Invoice, ManualPayment, Paths, Receipt, RefundableAmount, Wallet, addCredits, chargeProduct, getInvoiceById, getInvoicePdf, getInvoicesByTripId, getRefundableAmount, getUserCreditsByEntityId, getWalletsByEntity, payInvoice, refund, updateWallet };
263
+ export { ChargeProductInfo, Credit, Invoice, InvoicesByTripIdResponse, ManualPayment, Paths, Receipt, RefundableAmount, TripBillingItem, Wallet, addCredits, chargeProduct, getInvoiceById, getInvoicePdf, getInvoicesByTripId, getRefundableAmount, getUserCreditsByEntityId, getWalletsByEntity, payInvoice, refund, updateWallet };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-billing",
3
3
  "type": "module",
4
- "version": "1.2.36",
4
+ "version": "1.2.37",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -32,8 +32,8 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.36",
36
- "@vulog/aima-core": "1.2.36"
35
+ "@vulog/aima-client": "1.2.37",
36
+ "@vulog/aima-core": "1.2.37"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^3.25.76"
@@ -1,7 +1,7 @@
1
1
  import { describe, test, expect, vi, beforeEach } from 'vitest';
2
2
  import { Client } from '@vulog/aima-client';
3
3
  import { getInvoicesByTripId } from './getInvoicesByTripId';
4
- import type { Invoice } from './types';
4
+ import type { InvoicesByTripIdResponse } from './types';
5
5
 
6
6
  describe('getInvoicesByTripId', () => {
7
7
  const getMock = vi.fn();
@@ -29,27 +29,27 @@ describe('getInvoicesByTripId', () => {
29
29
  expect(getMock).not.toHaveBeenCalled();
30
30
  });
31
31
 
32
- test('calls GET with correct URL and returns invoices', async () => {
32
+ test('calls GET with correct URL and returns trip billing response', async () => {
33
33
  const tripId = 'BEBD00056A9A16103D418CC36D940E26';
34
- const invoices: Invoice[] = [
35
- {
36
- id: '66bcbd77-37ef-47bd-b9af-877e5d213b8f',
37
- sequence: 1,
38
- userId: '20fb98a3-b60d-491a-9359-62e55f51fcb9',
39
- invoiceDate: '2026-03-03',
40
- updateDate: '2026-03-03T09:46:50Z',
41
- fleetId: 'FLEET_ID',
42
- invoiceYear: 2026,
43
- invoicesStatus: 'PAID',
44
- amount: 100,
45
- currency: 'EUR',
46
- entityId: 'entity-1',
47
- attempts: 0,
48
- pspReference: 'ref-1',
49
- withTaxRefundAmount: 0,
50
- },
51
- ];
52
- getMock.mockResolvedValueOnce({ data: invoices });
34
+ const response: InvoicesByTripIdResponse = {
35
+ balance: 499.99,
36
+ userId: '20fb98a3-b60d-491a-9359-62e55f51fcb9',
37
+ entityId: 'ba0b4e0b-ff0a-49f5-8e98-065b54355df9',
38
+ Billing: [
39
+ {
40
+ vehiculeModelName: 'Yaris_Subs',
41
+ vehiculePlate: 'Yaris_Abo_001',
42
+ modelId: '1754',
43
+ userId: '20fb98a3-b60d-491a-9359-62e55f51fcb9',
44
+ withTaxInitialTotalAmount: 499.99,
45
+ totalWithTax: 499.99,
46
+ pricingId: '96e1fff7-d422-4181-8e19-1b2759b2f073',
47
+ distanceUnit: 'KM',
48
+ isTaxIncluded: true,
49
+ },
50
+ ],
51
+ };
52
+ getMock.mockResolvedValueOnce({ data: response });
53
53
 
54
54
  const result = await getInvoicesByTripId(client, tripId);
55
55
 
@@ -57,17 +57,25 @@ describe('getInvoicesByTripId', () => {
57
57
  expect(getMock).toHaveBeenCalledWith(
58
58
  `/boapi/proxy/billing/fleets/FLEET_ID/trips/${tripId}/invoices`
59
59
  );
60
- expect(result).toEqual(invoices);
61
- expect(result).toHaveLength(1);
62
- expect(result[0].id).toBe(invoices[0].id);
60
+ expect(result).toEqual(response);
61
+ expect(result.balance).toBe(499.99);
62
+ expect(result.Billing).toHaveLength(1);
63
+ expect(result.Billing[0].vehiculeModelName).toBe('Yaris_Subs');
63
64
  });
64
65
 
65
- test('returns empty array when no invoices', async () => {
66
+ test('returns response with empty Billing array when no billing items', async () => {
66
67
  const tripId = 'some-trip-id';
67
- getMock.mockResolvedValueOnce({ data: [] });
68
+ const response: InvoicesByTripIdResponse = {
69
+ balance: 0,
70
+ userId: 'user-id',
71
+ entityId: 'entity-id',
72
+ Billing: [],
73
+ };
74
+ getMock.mockResolvedValueOnce({ data: response });
68
75
 
69
76
  const result = await getInvoicesByTripId(client, tripId);
70
77
 
71
- expect(result).toEqual([]);
78
+ expect(result).toEqual(response);
79
+ expect(result.Billing).toEqual([]);
72
80
  });
73
81
  });
@@ -1,9 +1,9 @@
1
1
  import { Client } from '@vulog/aima-client';
2
2
  import { z } from 'zod';
3
3
 
4
- import { Invoice } from './types';
4
+ import { InvoicesByTripIdResponse } from './types';
5
5
 
6
- export const getInvoicesByTripId = async (client: Client, tripId: string): Promise<Invoice[]> => {
6
+ export const getInvoicesByTripId = async (client: Client, tripId: string): Promise<InvoicesByTripIdResponse> => {
7
7
  const result = z.string().trim().min(1).safeParse(tripId);
8
8
  if (!result.success) {
9
9
  throw new TypeError('Invalid args', {
@@ -12,6 +12,8 @@ export const getInvoicesByTripId = async (client: Client, tripId: string): Promi
12
12
  }
13
13
 
14
14
  return client
15
- .get<Invoice[]>(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/trips/${result.data}/invoices`)
15
+ .get<InvoicesByTripIdResponse>(
16
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/trips/${result.data}/invoices`
17
+ )
16
18
  .then(({ data }) => data);
17
19
  };
package/src/types.ts CHANGED
@@ -135,6 +135,86 @@ export type RefundableAmount = {
135
135
  refundedPaymentReceipts: Receipt[];
136
136
  };
137
137
 
138
+ /** Billing line item returned by the trip invoices endpoint (nested in Billing array). */
139
+ export type TripBillingItem = {
140
+ trip?: unknown;
141
+ product?: unknown;
142
+ vehiculeModelName?: string;
143
+ vehiculePlate?: string;
144
+ modelId?: string;
145
+ userId?: string;
146
+ withoutTaxAmountForDriving?: number;
147
+ withoutTaxAmountForStopover?: number;
148
+ withoutTaxAmountForBooking?: number;
149
+ withoutTaxForOvermileage?: number;
150
+ withoutTaxAmountForStartZoneFee?: number;
151
+ withoutTaxAmountForEndZoneFee?: number;
152
+ withoutTaxAmountForCancellationFee?: number;
153
+ withoutTaxAmountForScheduleTripFee?: number;
154
+ withoutTaxAmountForTripSystemCredit?: number;
155
+ withoutTaxAmountForBillingGroupDiscount?: number | null;
156
+ withTaxAmountForDriving?: number;
157
+ withTaxAmountForStopover?: number;
158
+ withTaxAmountForBooking?: number;
159
+ withTaxForOvermileage?: number;
160
+ withTaxAmountForStartZoneFee?: number;
161
+ withTaxAmountForEndZoneFee?: number;
162
+ withTaxAmountForCancellationFee?: number;
163
+ withTaxAmountForScheduleTripFee?: number;
164
+ withTaxAmountForTripSystemCredit?: number;
165
+ withTaxAmountForBillingGroupDiscount?: number;
166
+ withoutTaxInitialTotalAmount?: number;
167
+ withTaxInitialTotalAmount?: number;
168
+ taxInitialTotalAmount?: number;
169
+ paymentMethodType?: string;
170
+ walletId?: string | null;
171
+ totalTaxAmount?: number;
172
+ totalWithTax?: number;
173
+ totalWithoutTax?: number;
174
+ taxRate?: number;
175
+ taxName?: string;
176
+ withoutTaxAmountRideCost?: number;
177
+ withTaxAmountRideCost?: number;
178
+ taxAmountRideCost?: number;
179
+ products?: unknown[];
180
+ taxesPerRate?: unknown;
181
+ serviceId?: string | null;
182
+ profileId?: string | null;
183
+ profileType?: string | null;
184
+ profileName?: string | null;
185
+ withoutTaxUnlockFee?: number;
186
+ withTaxUnlockFee?: number;
187
+ taxUnlockFee?: number;
188
+ withTaxRefundAmount?: number | null;
189
+ isRefunded?: boolean;
190
+ cityName?: string | null;
191
+ cityId?: string | null;
192
+ tripBillingBreakdown?: unknown;
193
+ pricingId?: string;
194
+ netJourney?: number;
195
+ taxJourney?: number;
196
+ grossJourney?: number;
197
+ durationJourney?: number;
198
+ taxRemainingToBePaid?: number;
199
+ grossRemainingToBePaid?: number;
200
+ netRemainingToBePaid?: number;
201
+ overriddenTripInfo?: unknown;
202
+ interrupted?: boolean;
203
+ interruptedReason?: string | null;
204
+ invoice?: unknown;
205
+ distanceUnit?: string;
206
+ isTaxIncluded?: boolean;
207
+ [key: string]: unknown;
208
+ };
209
+
210
+ /** Response shape of GET .../trips/:tripId/invoices */
211
+ export type InvoicesByTripIdResponse = {
212
+ balance: number;
213
+ userId: string;
214
+ entityId: string;
215
+ Billing: TripBillingItem[];
216
+ };
217
+
138
218
  export type Wallet = {
139
219
  initialAmount: number;
140
220
  validityStartDate: string;