@go-avro/avro-js 0.0.86 → 0.0.88
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/client/hooks/bills.js +3 -0
- package/dist/types/api/Bill.d.ts +1 -8
- package/dist/types/api/Bill.js +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -82,6 +82,7 @@ AvroQueryClient.prototype.useCreateBill = function () {
|
|
|
82
82
|
entityKey: 'bills',
|
|
83
83
|
id: result.id,
|
|
84
84
|
fetchPath: `/bill/${result.id}`,
|
|
85
|
+
construct: (d) => new Bill(d),
|
|
85
86
|
});
|
|
86
87
|
},
|
|
87
88
|
onError: (_err, _variables, context) => {
|
|
@@ -131,6 +132,7 @@ AvroQueryClient.prototype.useUpdateBill = function () {
|
|
|
131
132
|
entityKey: 'bills',
|
|
132
133
|
id: billId,
|
|
133
134
|
fetchPath: `/bill/${billId}`,
|
|
135
|
+
construct: (d) => new Bill(d),
|
|
134
136
|
});
|
|
135
137
|
},
|
|
136
138
|
onError: (err, variables, context) => {
|
|
@@ -162,6 +164,7 @@ AvroQueryClient.prototype.useUpdateBillLineItemStatus = function () {
|
|
|
162
164
|
entityKey: 'bills',
|
|
163
165
|
id: billId,
|
|
164
166
|
fetchPath: `/bill/${billId}`,
|
|
167
|
+
construct: (d) => new Bill(d),
|
|
165
168
|
});
|
|
166
169
|
// Item paid state also lives on the underlying events,
|
|
167
170
|
// service months and prepayments
|
package/dist/types/api/Bill.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ declare module '../../types/api/Bill' {
|
|
|
18
18
|
invoice_id: number;
|
|
19
19
|
intuit_id: string | null;
|
|
20
20
|
name: string;
|
|
21
|
-
amount: number;
|
|
22
21
|
billed_by: string;
|
|
23
22
|
customer_email: string | null;
|
|
24
23
|
manual_emails: string[][];
|
|
@@ -31,7 +30,6 @@ declare module '../../types/api/Bill' {
|
|
|
31
30
|
intent_created_at: number;
|
|
32
31
|
intent_last_created_at: number;
|
|
33
32
|
payments: BillPayment[];
|
|
34
|
-
/** Every billable item on the bill, discriminated by line_item_type. */
|
|
35
33
|
line_items: LineItem[];
|
|
36
34
|
prepayments: string[];
|
|
37
35
|
months: string[];
|
|
@@ -41,18 +39,13 @@ declare module '../../types/api/Bill' {
|
|
|
41
39
|
}
|
|
42
40
|
export declare class Bill {
|
|
43
41
|
constructor(init?: Partial<Bill>);
|
|
44
|
-
|
|
42
|
+
total: () => number;
|
|
45
43
|
labels: () => string[];
|
|
46
|
-
/** Custom (and fee) rows only — the classic pre-unified view. */
|
|
47
44
|
customItems: () => BillLineItem[];
|
|
48
|
-
/** Top-level rows (parent_id null), in server order. */
|
|
49
45
|
topLevelItems: () => LineItem[];
|
|
50
|
-
/** Child rows of one line item, e.g. an event's additional charges. */
|
|
51
46
|
childItems: (parentId: string) => LineItem[];
|
|
52
47
|
}
|
|
53
|
-
/** Line-item kinds addressable by PUT /bill/<id>/line-items/status. */
|
|
54
48
|
export type BillLineItemStatusKind = 'event' | 'service_month' | 'prepayment' | 'line_item';
|
|
55
|
-
/** One per-line-item paid/unpaid marking on a bill. */
|
|
56
49
|
export interface BillLineItemStatusUpdate {
|
|
57
50
|
type: BillLineItemStatusKind;
|
|
58
51
|
id: string;
|
package/dist/types/api/Bill.js
CHANGED
|
@@ -7,15 +7,15 @@ export const BillStatus = {
|
|
|
7
7
|
};
|
|
8
8
|
export class Bill {
|
|
9
9
|
constructor(init) {
|
|
10
|
-
|
|
10
|
+
this.total = () => (this.line_items ?? []).reduce((sum, item) => {
|
|
11
|
+
const cost = item.line_item_type === 'EVENT' ? Math.max(item.cost, 0) : item.cost;
|
|
12
|
+
return sum + cost * (item.amount ?? 1);
|
|
13
|
+
}, 0);
|
|
11
14
|
this.labels = () => [
|
|
12
15
|
...new Set((this.line_items ?? []).flatMap((item) => item.job_labels ?? [])),
|
|
13
16
|
];
|
|
14
|
-
/** Custom (and fee) rows only — the classic pre-unified view. */
|
|
15
17
|
this.customItems = () => (this.line_items ?? []).filter((item) => item.line_item_type === 'CUSTOM' || item.line_item_type === 'PROCESSING_FEE');
|
|
16
|
-
/** Top-level rows (parent_id null), in server order. */
|
|
17
18
|
this.topLevelItems = () => (this.line_items ?? []).filter((item) => !item.parent_id);
|
|
18
|
-
/** Child rows of one line item, e.g. an event's additional charges. */
|
|
19
19
|
this.childItems = (parentId) => (this.line_items ?? []).filter((item) => item.parent_id === parentId);
|
|
20
20
|
Object.assign(this, init);
|
|
21
21
|
if (init?.line_items) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.0.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.88";
|
package/dist/version.js
CHANGED