@company-six/qbosync 0.3.1 → 0.6.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.
- package/README.md +325 -275
- package/dist/client.d.ts +20 -0
- package/dist/client.js +39 -1
- package/dist/contract/answers.d.ts +5 -2
- package/dist/contract/bill.d.ts +271 -0
- package/dist/contract/bill.js +130 -0
- package/dist/contract/codes.d.ts +64 -0
- package/dist/contract/codes.js +74 -0
- package/dist/contract/index.d.ts +182 -2
- package/dist/contract/index.js +5 -2
- package/dist/contract/protocol.d.ts +2 -2
- package/dist/contract/protocol.js +2 -2
- package/dist/contract/statusReport.d.ts +2 -0
- package/package.json +44 -44
- package/sql/002_daily_report.sql +4 -4
- package/sql/003_daily_report_bills.sql +25 -0
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type BillDTO, type VendorCreditDTO } from "./bill.ts";
|
|
2
3
|
import { type CreditMemoDTO } from "./creditMemo.ts";
|
|
3
4
|
import { type InvoiceDTO } from "./invoice.ts";
|
|
4
5
|
/**
|
|
@@ -9,10 +10,12 @@ import { type InvoiceDTO } from "./invoice.ts";
|
|
|
9
10
|
export * from "./common.ts";
|
|
10
11
|
export * from "./invoice.ts";
|
|
11
12
|
export * from "./creditMemo.ts";
|
|
13
|
+
export * from "./bill.ts";
|
|
14
|
+
export * from "./codes.ts";
|
|
12
15
|
export * from "./statusReport.ts";
|
|
13
16
|
export * from "./protocol.ts";
|
|
14
17
|
export * from "./answers.ts";
|
|
15
|
-
/** An invoice or a credit
|
|
18
|
+
/** An invoice, a credit memo, a bill or a vendor credit: what an app may send. */
|
|
16
19
|
export declare const appDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
17
20
|
type: z.ZodLiteral<"invoice">;
|
|
18
21
|
number: z.ZodPipe<z.ZodString, z.ZodString>;
|
|
@@ -126,8 +129,185 @@ export declare const appDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
126
129
|
active: "active";
|
|
127
130
|
voided: "voided";
|
|
128
131
|
}>;
|
|
132
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
133
|
+
type: z.ZodLiteral<"bill">;
|
|
134
|
+
due_date: z.ZodOptional<z.ZodString>;
|
|
135
|
+
terms_code: z.ZodOptional<z.ZodString>;
|
|
136
|
+
number: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
|
|
137
|
+
issue_date: z.ZodString;
|
|
138
|
+
currency: z.ZodString;
|
|
139
|
+
vendor: z.ZodObject<{
|
|
140
|
+
ref: z.ZodString;
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
company: z.ZodOptional<z.ZodString>;
|
|
143
|
+
email: z.ZodOptional<z.ZodString>;
|
|
144
|
+
address: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
146
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
147
|
+
city: z.ZodOptional<z.ZodString>;
|
|
148
|
+
region: z.ZodOptional<z.ZodString>;
|
|
149
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
150
|
+
country: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strict>>;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
154
|
+
ref: z.ZodString;
|
|
155
|
+
name: z.ZodString;
|
|
156
|
+
company: z.ZodOptional<z.ZodString>;
|
|
157
|
+
email: z.ZodOptional<z.ZodString>;
|
|
158
|
+
bill_to: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
160
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
161
|
+
city: z.ZodOptional<z.ZodString>;
|
|
162
|
+
region: z.ZodOptional<z.ZodString>;
|
|
163
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
164
|
+
country: z.ZodOptional<z.ZodString>;
|
|
165
|
+
}, z.core.$strict>>;
|
|
166
|
+
ship_to: z.ZodOptional<z.ZodObject<{
|
|
167
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
168
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
169
|
+
city: z.ZodOptional<z.ZodString>;
|
|
170
|
+
region: z.ZodOptional<z.ZodString>;
|
|
171
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
172
|
+
country: z.ZodOptional<z.ZodString>;
|
|
173
|
+
}, z.core.$strict>>;
|
|
174
|
+
}, z.core.$strict>>;
|
|
175
|
+
order_ref: z.ZodOptional<z.ZodString>;
|
|
176
|
+
references: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
+
label: z.ZodString;
|
|
178
|
+
value: z.ZodString;
|
|
179
|
+
}, z.core.$strict>>>;
|
|
180
|
+
class_key: z.ZodOptional<z.ZodString>;
|
|
181
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
182
|
+
description: z.ZodString;
|
|
183
|
+
amount_cents: z.ZodInt;
|
|
184
|
+
cost_code: z.ZodOptional<z.ZodString>;
|
|
185
|
+
item_code: z.ZodOptional<z.ZodString>;
|
|
186
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
187
|
+
unit_cost_cents: z.ZodOptional<z.ZodNumber>;
|
|
188
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
189
|
+
ref: z.ZodString;
|
|
190
|
+
name: z.ZodString;
|
|
191
|
+
company: z.ZodOptional<z.ZodString>;
|
|
192
|
+
email: z.ZodOptional<z.ZodString>;
|
|
193
|
+
bill_to: z.ZodOptional<z.ZodObject<{
|
|
194
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
195
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
196
|
+
city: z.ZodOptional<z.ZodString>;
|
|
197
|
+
region: z.ZodOptional<z.ZodString>;
|
|
198
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
199
|
+
country: z.ZodOptional<z.ZodString>;
|
|
200
|
+
}, z.core.$strict>>;
|
|
201
|
+
ship_to: z.ZodOptional<z.ZodObject<{
|
|
202
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
203
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
204
|
+
city: z.ZodOptional<z.ZodString>;
|
|
205
|
+
region: z.ZodOptional<z.ZodString>;
|
|
206
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
207
|
+
country: z.ZodOptional<z.ZodString>;
|
|
208
|
+
}, z.core.$strict>>;
|
|
209
|
+
}, z.core.$strict>>;
|
|
210
|
+
class_key: z.ZodOptional<z.ZodString>;
|
|
211
|
+
}, z.core.$strict>>;
|
|
212
|
+
total_cents: z.ZodInt;
|
|
213
|
+
schema_version: z.ZodLiteral<"1">;
|
|
214
|
+
source_ref: z.ZodString;
|
|
215
|
+
company_key: z.ZodString;
|
|
216
|
+
version: z.ZodInt;
|
|
217
|
+
status: z.ZodEnum<{
|
|
218
|
+
active: "active";
|
|
219
|
+
voided: "voided";
|
|
220
|
+
}>;
|
|
221
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
222
|
+
type: z.ZodLiteral<"vendor_credit">;
|
|
223
|
+
applies_to_bill_ref: z.ZodOptional<z.ZodString>;
|
|
224
|
+
number: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
|
|
225
|
+
issue_date: z.ZodString;
|
|
226
|
+
currency: z.ZodString;
|
|
227
|
+
vendor: z.ZodObject<{
|
|
228
|
+
ref: z.ZodString;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
company: z.ZodOptional<z.ZodString>;
|
|
231
|
+
email: z.ZodOptional<z.ZodString>;
|
|
232
|
+
address: z.ZodOptional<z.ZodObject<{
|
|
233
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
234
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
235
|
+
city: z.ZodOptional<z.ZodString>;
|
|
236
|
+
region: z.ZodOptional<z.ZodString>;
|
|
237
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
238
|
+
country: z.ZodOptional<z.ZodString>;
|
|
239
|
+
}, z.core.$strict>>;
|
|
240
|
+
}, z.core.$strict>;
|
|
241
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
242
|
+
ref: z.ZodString;
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
company: z.ZodOptional<z.ZodString>;
|
|
245
|
+
email: z.ZodOptional<z.ZodString>;
|
|
246
|
+
bill_to: z.ZodOptional<z.ZodObject<{
|
|
247
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
248
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
249
|
+
city: z.ZodOptional<z.ZodString>;
|
|
250
|
+
region: z.ZodOptional<z.ZodString>;
|
|
251
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
252
|
+
country: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, z.core.$strict>>;
|
|
254
|
+
ship_to: z.ZodOptional<z.ZodObject<{
|
|
255
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
256
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
257
|
+
city: z.ZodOptional<z.ZodString>;
|
|
258
|
+
region: z.ZodOptional<z.ZodString>;
|
|
259
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
260
|
+
country: z.ZodOptional<z.ZodString>;
|
|
261
|
+
}, z.core.$strict>>;
|
|
262
|
+
}, z.core.$strict>>;
|
|
263
|
+
order_ref: z.ZodOptional<z.ZodString>;
|
|
264
|
+
references: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
265
|
+
label: z.ZodString;
|
|
266
|
+
value: z.ZodString;
|
|
267
|
+
}, z.core.$strict>>>;
|
|
268
|
+
class_key: z.ZodOptional<z.ZodString>;
|
|
269
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
270
|
+
description: z.ZodString;
|
|
271
|
+
amount_cents: z.ZodInt;
|
|
272
|
+
cost_code: z.ZodOptional<z.ZodString>;
|
|
273
|
+
item_code: z.ZodOptional<z.ZodString>;
|
|
274
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
275
|
+
unit_cost_cents: z.ZodOptional<z.ZodNumber>;
|
|
276
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
277
|
+
ref: z.ZodString;
|
|
278
|
+
name: z.ZodString;
|
|
279
|
+
company: z.ZodOptional<z.ZodString>;
|
|
280
|
+
email: z.ZodOptional<z.ZodString>;
|
|
281
|
+
bill_to: z.ZodOptional<z.ZodObject<{
|
|
282
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
283
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
284
|
+
city: z.ZodOptional<z.ZodString>;
|
|
285
|
+
region: z.ZodOptional<z.ZodString>;
|
|
286
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
287
|
+
country: z.ZodOptional<z.ZodString>;
|
|
288
|
+
}, z.core.$strict>>;
|
|
289
|
+
ship_to: z.ZodOptional<z.ZodObject<{
|
|
290
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
291
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
292
|
+
city: z.ZodOptional<z.ZodString>;
|
|
293
|
+
region: z.ZodOptional<z.ZodString>;
|
|
294
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
295
|
+
country: z.ZodOptional<z.ZodString>;
|
|
296
|
+
}, z.core.$strict>>;
|
|
297
|
+
}, z.core.$strict>>;
|
|
298
|
+
class_key: z.ZodOptional<z.ZodString>;
|
|
299
|
+
}, z.core.$strict>>;
|
|
300
|
+
total_cents: z.ZodInt;
|
|
301
|
+
schema_version: z.ZodLiteral<"1">;
|
|
302
|
+
source_ref: z.ZodString;
|
|
303
|
+
company_key: z.ZodString;
|
|
304
|
+
version: z.ZodInt;
|
|
305
|
+
status: z.ZodEnum<{
|
|
306
|
+
active: "active";
|
|
307
|
+
voided: "voided";
|
|
308
|
+
}>;
|
|
129
309
|
}, z.core.$strict>], "type">;
|
|
130
|
-
export type AppDocument = InvoiceDTO | CreditMemoDTO;
|
|
310
|
+
export type AppDocument = InvoiceDTO | CreditMemoDTO | BillDTO | VendorCreditDTO;
|
|
131
311
|
export type CheckedDocument = {
|
|
132
312
|
ok: true;
|
|
133
313
|
document: AppDocument;
|
package/dist/contract/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { billSchema, vendorCreditSchema } from "./bill.js";
|
|
2
3
|
import { creditMemoSchema } from "./creditMemo.js";
|
|
3
4
|
import { invoiceSchema } from "./invoice.js";
|
|
4
5
|
import { APP_DOCUMENT_TYPES } from "./protocol.js";
|
|
@@ -10,11 +11,13 @@ import { APP_DOCUMENT_TYPES } from "./protocol.js";
|
|
|
10
11
|
export * from "./common.js";
|
|
11
12
|
export * from "./invoice.js";
|
|
12
13
|
export * from "./creditMemo.js";
|
|
14
|
+
export * from "./bill.js";
|
|
15
|
+
export * from "./codes.js";
|
|
13
16
|
export * from "./statusReport.js";
|
|
14
17
|
export * from "./protocol.js";
|
|
15
18
|
export * from "./answers.js";
|
|
16
|
-
/** An invoice or a credit
|
|
17
|
-
export const appDocumentSchema = z.discriminatedUnion("type", [invoiceSchema, creditMemoSchema], {
|
|
19
|
+
/** An invoice, a credit memo, a bill or a vendor credit: what an app may send. */
|
|
20
|
+
export const appDocumentSchema = z.discriminatedUnion("type", [invoiceSchema, creditMemoSchema, billSchema, vendorCreditSchema], {
|
|
18
21
|
error: `type must be one of ${APP_DOCUMENT_TYPES.join(", ")}`,
|
|
19
22
|
});
|
|
20
23
|
/** One problem with a document as a readable line naming the field: `lines.0.amount_cents: must equal …`. */
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* against the code that enforces it, so these cannot drift from what QBO Sync does.
|
|
4
4
|
*/
|
|
5
5
|
/** Every document type there is. Apps send only `APP_DOCUMENT_TYPES`; status reports may name any of them. */
|
|
6
|
-
export declare const DOCUMENT_TYPES: readonly ["invoice", "credit_memo", "payment", "refund", "payout"];
|
|
6
|
+
export declare const DOCUMENT_TYPES: readonly ["invoice", "credit_memo", "bill", "vendor_credit", "payment", "refund", "payout"];
|
|
7
7
|
export type DocumentType = (typeof DOCUMENT_TYPES)[number];
|
|
8
8
|
/** What an app sends. Payments, refunds and payouts reach QBO Sync through its own connectors, never from an app. */
|
|
9
|
-
export declare const APP_DOCUMENT_TYPES: readonly ["invoice", "credit_memo"];
|
|
9
|
+
export declare const APP_DOCUMENT_TYPES: readonly ["invoice", "credit_memo", "bill", "vendor_credit"];
|
|
10
10
|
/** The most documents one request may carry. */
|
|
11
11
|
export declare const MAX_DOCUMENTS_PER_REQUEST = 100;
|
|
12
12
|
/** The most document refs one report request may name. */
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* against the code that enforces it, so these cannot drift from what QBO Sync does.
|
|
4
4
|
*/
|
|
5
5
|
/** Every document type there is. Apps send only `APP_DOCUMENT_TYPES`; status reports may name any of them. */
|
|
6
|
-
export const DOCUMENT_TYPES = ["invoice", "credit_memo", "payment", "refund", "payout"];
|
|
6
|
+
export const DOCUMENT_TYPES = ["invoice", "credit_memo", "bill", "vendor_credit", "payment", "refund", "payout"];
|
|
7
7
|
/** What an app sends. Payments, refunds and payouts reach QBO Sync through its own connectors, never from an app. */
|
|
8
|
-
export const APP_DOCUMENT_TYPES = ["invoice", "credit_memo"];
|
|
8
|
+
export const APP_DOCUMENT_TYPES = ["invoice", "credit_memo", "bill", "vendor_credit"];
|
|
9
9
|
/** The most documents one request may carry. */
|
|
10
10
|
export const MAX_DOCUMENTS_PER_REQUEST = 100;
|
|
11
11
|
/** The most document refs one report request may name. */
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@company-six/qbosync",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Connect an app to QBO Sync: send invoices
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"engines": {
|
|
9
|
-
"node": ">=20"
|
|
10
|
-
},
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./contract": {
|
|
17
|
-
"types": "./dist/contract/index.d.ts",
|
|
18
|
-
"default": "./dist/contract/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./supabase": {
|
|
21
|
-
"types": "./dist/supabase.d.ts",
|
|
22
|
-
"default": "./dist/supabase.js"
|
|
23
|
-
},
|
|
24
|
-
"./testing": {
|
|
25
|
-
"types": "./dist/testing.d.ts",
|
|
26
|
-
"default": "./dist/testing.js"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"sql/*.sql",
|
|
32
|
-
"README.md"
|
|
33
|
-
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsc -p tsconfig.json",
|
|
36
|
-
"prepublishOnly": "npm run build"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"zod": "^4.1.13"
|
|
40
|
-
},
|
|
41
|
-
"publishConfig": {
|
|
42
|
-
"access": "public"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@company-six/qbosync",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Connect an app to QBO Sync: send invoices, credit memos, bills and vendor credits to QuickBooks, and hear back what happened to them.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./contract": {
|
|
17
|
+
"types": "./dist/contract/index.d.ts",
|
|
18
|
+
"default": "./dist/contract/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./supabase": {
|
|
21
|
+
"types": "./dist/supabase.d.ts",
|
|
22
|
+
"default": "./dist/supabase.js"
|
|
23
|
+
},
|
|
24
|
+
"./testing": {
|
|
25
|
+
"types": "./dist/testing.d.ts",
|
|
26
|
+
"default": "./dist/testing.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"sql/*.sql",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"prepublishOnly": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"zod": "^4.1.13"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/sql/002_daily_report.sql
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
-- An app's daily report: each morning, the invoices
|
|
2
|
-
-- QBO Sync did with them. Optional; run this once in the app's own Postgres database (the Supabase
|
|
3
|
-
-- instance) if the app keeps one. One transaction; re-running it is a no-op. It does not need 001_connection.sql.
|
|
1
|
+
-- An app's daily report: each morning, the invoices, credit memos, bills and vendor credits the app created the day
|
|
2
|
+
-- before, set beside what QBO Sync did with them. Optional; run this once in the app's own Postgres database (the Supabase
|
|
3
|
+
-- SQL editor, for instance) if the app keeps one. One transaction; re-running it is a no-op. It does not need 001_connection.sql.
|
|
4
4
|
--
|
|
5
5
|
-- qbosync_report_runs one row per run of the report: the day it covers, whether it is running, finished or failed,
|
|
6
6
|
-- and a finished day's totals by result, for the page that lists the days.
|
|
@@ -109,7 +109,7 @@ create table if not exists public.qbosync_report_rows (
|
|
|
109
109
|
-- Optional: your own record of sending it (shown beside "not_received").
|
|
110
110
|
send_status text,
|
|
111
111
|
created_at timestamptz not null default now(),
|
|
112
|
-
constraint qbosync_report_rows_type_check check (document_type in ('invoice', 'credit_memo')),
|
|
112
|
+
constraint qbosync_report_rows_type_check check (document_type in ('invoice', 'credit_memo', 'bill', 'vendor_credit')),
|
|
113
113
|
constraint qbosync_report_rows_ref_check check (length(btrim(source_ref)) > 0),
|
|
114
114
|
constraint qbosync_report_rows_company_check check (length(btrim(company_key)) > 0),
|
|
115
115
|
constraint qbosync_report_rows_result_check check (result in
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- The daily report keeps rows for bills and vendor credits too (SDK 0.5.1).
|
|
2
|
+
--
|
|
3
|
+
-- Run this once if your app ran sql/002_daily_report.sql before 0.5.1 and sends bills or vendor credits. Until then,
|
|
4
|
+
-- 002's check allowed only 'invoice' and 'credit_memo', so the first morning with a bill failed whole ("new row for
|
|
5
|
+
-- relation qbosync_report_rows violates check constraint qbosync_report_rows_type_check") and every later morning with
|
|
6
|
+
-- one did too. 002 itself now allows all four types, so an app that runs 002 from 0.5.1 on does not need this file;
|
|
7
|
+
-- running it anyway changes nothing. One transaction; re-running it is a no-op.
|
|
8
|
+
--
|
|
9
|
+
-- Found by Aztec's end-to-end run on 2026-11-16, the first app to send bills.
|
|
10
|
+
--
|
|
11
|
+
-- Undo (only while no bill or vendor credit row exists):
|
|
12
|
+
-- alter table public.qbosync_report_rows drop constraint qbosync_report_rows_type_check;
|
|
13
|
+
-- alter table public.qbosync_report_rows add constraint qbosync_report_rows_type_check
|
|
14
|
+
-- check (document_type in ('invoice', 'credit_memo'));
|
|
15
|
+
|
|
16
|
+
begin;
|
|
17
|
+
|
|
18
|
+
alter table public.qbosync_report_rows
|
|
19
|
+
drop constraint if exists qbosync_report_rows_type_check;
|
|
20
|
+
|
|
21
|
+
alter table public.qbosync_report_rows
|
|
22
|
+
add constraint qbosync_report_rows_type_check
|
|
23
|
+
check (document_type in ('invoice', 'credit_memo', 'bill', 'vendor_credit'));
|
|
24
|
+
|
|
25
|
+
commit;
|