@go-avro/avro-js 0.0.2-beta.19 → 0.0.2-beta.20
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,4 +1,5 @@
|
|
|
1
1
|
import { AuthManager } from '../auth/AuthManager';
|
|
2
|
+
import { LineItem } from '../types/api';
|
|
2
3
|
import { CancelToken, RetryStrategy } from '../types/client';
|
|
3
4
|
export interface AvroQueryClientConfig {
|
|
4
5
|
baseUrl: string;
|
|
@@ -27,4 +28,10 @@ export declare class AvroQueryClient {
|
|
|
27
28
|
fetchMonths(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, offset?: number, unbilled?: boolean, billed?: boolean, paid?: boolean, jobId?: string | null, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
28
29
|
fetchBills(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, offset?: number, paid?: boolean, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
29
30
|
sendEmail(emailId: string, formData: FormData): Promise<void>;
|
|
31
|
+
createBill(companyGuid: string, data: {
|
|
32
|
+
line_items: LineItem[];
|
|
33
|
+
due_date: number;
|
|
34
|
+
users: string[];
|
|
35
|
+
custom_emails: [string, string][];
|
|
36
|
+
}): Promise<any>;
|
|
30
37
|
}
|
|
@@ -301,4 +301,28 @@ export class AvroQueryClient {
|
|
|
301
301
|
throw error;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
+
createBill(companyGuid, data) {
|
|
305
|
+
if (!companyGuid) {
|
|
306
|
+
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
307
|
+
}
|
|
308
|
+
const body = {
|
|
309
|
+
events: data.line_items.filter(item => item.line_item_type === 'EVENT').map(item => item.id),
|
|
310
|
+
months: data.line_items.filter(item => item.line_item_type === 'SERVICE_MONTH').map(item => item.id),
|
|
311
|
+
line_items: data.line_items.filter(item => item.line_item_type === 'CUSTOM'),
|
|
312
|
+
manual_emails: data.custom_emails,
|
|
313
|
+
users: data.users,
|
|
314
|
+
due_date: data.due_date,
|
|
315
|
+
};
|
|
316
|
+
return this._fetch('POST', `/company/${companyGuid}/bills`, body)
|
|
317
|
+
.then(response => {
|
|
318
|
+
if (!response || !Array.isArray(response)) {
|
|
319
|
+
throw new StandardError(400, 'Invalid bills response');
|
|
320
|
+
}
|
|
321
|
+
return response;
|
|
322
|
+
})
|
|
323
|
+
.catch(err => {
|
|
324
|
+
console.error('Failed to create bill:', err);
|
|
325
|
+
throw new StandardError(500, 'Failed to create bill');
|
|
326
|
+
});
|
|
327
|
+
}
|
|
304
328
|
}
|