fatoority 0.4.4 → 0.5.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.
@@ -0,0 +1,205 @@
1
+ // generated by diplomat-tool
2
+ import { BindingError } from "./BindingError.mjs"
3
+ import { TaxExemption } from "./TaxExemption.mjs"
4
+ import wasm from "./diplomat-wasm.mjs";
5
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
+
7
+ const VatBreakdown_box_destroy_registry = new FinalizationRegistry((ptr) => {
8
+ wasm.fatoora_VatBreakdown_destroy(ptr);
9
+ });
10
+
11
+ export class VatBreakdown {
12
+ // Internal ptr reference:
13
+ #ptr = null;
14
+
15
+ // Lifetimes are only to keep dependencies alive.
16
+ // Since JS won't garbage collect until there are no incoming edges.
17
+ #selfEdge = [];
18
+
19
+ #internalConstructor(symbol, ptr, selfEdge) {
20
+ if (symbol !== diplomatRuntime.internalConstructor) {
21
+ console.error("VatBreakdown is an Opaque type. You cannot call its constructor.");
22
+ return;
23
+ }
24
+ this.#ptr = ptr;
25
+ this.#selfEdge = selfEdge;
26
+
27
+ // Are we being borrowed? If not, we can register.
28
+ if (this.#selfEdge.length === 0) {
29
+ VatBreakdown_box_destroy_registry.register(this, this.#ptr);
30
+ }
31
+
32
+ return this;
33
+ }
34
+ /** @internal */
35
+ get ffiValue() {
36
+ return this.#ptr;
37
+ }
38
+
39
+
40
+ hasVatRate() {
41
+
42
+ const result = wasm.fatoora_VatBreakdown_has_vat_rate(this.ffiValue);
43
+
44
+ try {
45
+ return result;
46
+ }
47
+
48
+ finally {
49
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
50
+ }
51
+ }
52
+
53
+ withoutVatRate() {
54
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
55
+
56
+
57
+ const result = wasm.fatoora_VatBreakdown_without_vat_rate(diplomatReceive.buffer, this.ffiValue);
58
+
59
+ try {
60
+ if (!diplomatReceive.resultFlag) {
61
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
62
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
63
+ }
64
+ return new VatBreakdown(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
65
+ }
66
+
67
+ finally {
68
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
69
+ diplomatReceive.free();
70
+ }
71
+ }
72
+
73
+ static new_(category, rate, taxableAmount, taxAmount, exemption) {
74
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
75
+
76
+ const rateSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, rate)));
77
+ const taxableAmountSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, taxableAmount)));
78
+ const taxAmountSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, taxAmount)));
79
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
80
+
81
+
82
+ const result = wasm.fatoora_VatBreakdown_new(diplomatReceive.buffer, category, rateSlice.ptr, taxableAmountSlice.ptr, taxAmountSlice.ptr, exemption instanceof TaxExemption ? exemption.ffiValue : typeError('exemption', 'TaxExemption'));
83
+
84
+ try {
85
+ if (!diplomatReceive.resultFlag) {
86
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
87
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
88
+ }
89
+ return new VatBreakdown(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
90
+ }
91
+
92
+ finally {
93
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
94
+ functionCleanupArena.free();
95
+
96
+ diplomatReceive.free();
97
+ }
98
+ }
99
+
100
+ category() {
101
+
102
+ const result = wasm.fatoora_VatBreakdown_category(this.ffiValue);
103
+
104
+ try {
105
+ return result;
106
+ }
107
+
108
+ finally {
109
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
110
+ }
111
+ }
112
+
113
+ rate() {
114
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
115
+
116
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
117
+
118
+
119
+ const result = wasm.fatoora_VatBreakdown_rate(diplomatReceive.buffer, this.ffiValue, write.buffer);
120
+
121
+ try {
122
+ if (!diplomatReceive.resultFlag) {
123
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
124
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
125
+ }
126
+ return write.readString8();
127
+ }
128
+
129
+ finally {
130
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
131
+ diplomatReceive.free();
132
+ write.free();
133
+ }
134
+ }
135
+
136
+ taxableAmount() {
137
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
138
+
139
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
140
+
141
+
142
+ const result = wasm.fatoora_VatBreakdown_taxable_amount(diplomatReceive.buffer, this.ffiValue, write.buffer);
143
+
144
+ try {
145
+ if (!diplomatReceive.resultFlag) {
146
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
147
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
148
+ }
149
+ return write.readString8();
150
+ }
151
+
152
+ finally {
153
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
154
+ diplomatReceive.free();
155
+ write.free();
156
+ }
157
+ }
158
+
159
+ taxAmount() {
160
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
161
+
162
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
163
+
164
+
165
+ const result = wasm.fatoora_VatBreakdown_tax_amount(diplomatReceive.buffer, this.ffiValue, write.buffer);
166
+
167
+ try {
168
+ if (!diplomatReceive.resultFlag) {
169
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
170
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
171
+ }
172
+ return write.readString8();
173
+ }
174
+
175
+ finally {
176
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
177
+ diplomatReceive.free();
178
+ write.free();
179
+ }
180
+ }
181
+
182
+ exemption() {
183
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
184
+
185
+
186
+ const result = wasm.fatoora_VatBreakdown_exemption(diplomatReceive.buffer, this.ffiValue);
187
+
188
+ try {
189
+ if (!diplomatReceive.resultFlag) {
190
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
191
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
192
+ }
193
+ return new TaxExemption(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
194
+ }
195
+
196
+ finally {
197
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
198
+ diplomatReceive.free();
199
+ }
200
+ }
201
+
202
+ constructor(symbol, ptr, selfEdge) {
203
+ return this.#internalConstructor(...arguments)
204
+ }
205
+ }
@@ -40,6 +40,10 @@ export { SigningKey } from "./SigningKey.mjs"
40
40
 
41
41
  export { Address } from "./Address.mjs"
42
42
 
43
+ export { Adjustment } from "./Adjustment.mjs"
44
+
45
+ export { AllowanceCharge } from "./AllowanceCharge.mjs"
46
+
43
47
  export { FinalizedInvoice } from "./FinalizedInvoice.mjs"
44
48
 
45
49
  export { InvoiceBuilder } from "./InvoiceBuilder.mjs"
@@ -52,14 +56,22 @@ export { InvoiceNote } from "./InvoiceNote.mjs"
52
56
 
53
57
  export { InvoiceTotals } from "./InvoiceTotals.mjs"
54
58
 
59
+ export { LineItemBuilder } from "./LineItemBuilder.mjs"
60
+
55
61
  export { OriginalInvoiceRef } from "./OriginalInvoiceRef.mjs"
56
62
 
57
63
  export { OtherId } from "./OtherId.mjs"
58
64
 
59
65
  export { Party } from "./Party.mjs"
60
66
 
67
+ export { PaymentMeans } from "./PaymentMeans.mjs"
68
+
61
69
  export { SignedInvoice } from "./SignedInvoice.mjs"
62
70
 
71
+ export { TaxExemption } from "./TaxExemption.mjs"
72
+
73
+ export { VatBreakdown } from "./VatBreakdown.mjs"
74
+
63
75
  export { VatId } from "./VatId.mjs"
64
76
 
65
77
  export { Xml } from "./Xml.mjs"
@@ -38,6 +38,10 @@ export { SigningKey } from "./SigningKey.mjs"
38
38
 
39
39
  export { Address } from "./Address.mjs"
40
40
 
41
+ export { Adjustment } from "./Adjustment.mjs"
42
+
43
+ export { AllowanceCharge } from "./AllowanceCharge.mjs"
44
+
41
45
  export { FinalizedInvoice } from "./FinalizedInvoice.mjs"
42
46
 
43
47
  export { InvoiceBuilder } from "./InvoiceBuilder.mjs"
@@ -50,14 +54,22 @@ export { InvoiceNote } from "./InvoiceNote.mjs"
50
54
 
51
55
  export { InvoiceTotals } from "./InvoiceTotals.mjs"
52
56
 
57
+ export { LineItemBuilder } from "./LineItemBuilder.mjs"
58
+
53
59
  export { OriginalInvoiceRef } from "./OriginalInvoiceRef.mjs"
54
60
 
55
61
  export { OtherId } from "./OtherId.mjs"
56
62
 
57
63
  export { Party } from "./Party.mjs"
58
64
 
65
+ export { PaymentMeans } from "./PaymentMeans.mjs"
66
+
59
67
  export { SignedInvoice } from "./SignedInvoice.mjs"
60
68
 
69
+ export { TaxExemption } from "./TaxExemption.mjs"
70
+
71
+ export { VatBreakdown } from "./VatBreakdown.mjs"
72
+
61
73
  export { VatId } from "./VatId.mjs"
62
74
 
63
75
  export { Xml } from "./Xml.mjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fatoority",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "ZATCA invoice SDK with Diplomat WebAssembly bindings",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN THIRD_PARTY_NOTICES.md",