@sdflc/backend-helpers 1.0.147 → 1.0.148
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
CHANGED
|
@@ -1399,7 +1399,7 @@ await qb.refreshTokens(refreshToken); // ⚠ returns a NEW refresh token — sto
|
|
|
1399
1399
|
await qb.revoke(refreshToken); // disconnect
|
|
1400
1400
|
```
|
|
1401
1401
|
|
|
1402
|
-
- Also `companyInfo`, `preferences`, `createCustomer
|
|
1402
|
+
- Also `companyInfo`, `preferences`, `createCustomer` (`currency?` — a multicurrency customer's, fixed once made), `createRefundReceipt`, `createPurchase` (a fee leaving an account), `createJournalEntry` (debits and credits on any accounts).
|
|
1403
1403
|
- **Every create takes a request id** (Intuit's `requestid`, 1–50 characters): Intuit answers a repeat with the first
|
|
1404
1404
|
result, so the base class's retries never book twice. Refused before sending without one.
|
|
1405
1405
|
- An expired access token comes back `UNAUTHORIZED` (not retried) — refresh and try once more. Intuit's faults (upper- or
|
|
@@ -94,6 +94,7 @@ declare class QuickBooksGw extends BaseExternalApiGateway<QuickBooksSettings> {
|
|
|
94
94
|
createCustomer(company: QuickBooksCompany, customer: {
|
|
95
95
|
displayName: string;
|
|
96
96
|
email?: string | null;
|
|
97
|
+
currency?: string | null;
|
|
97
98
|
}, requestId: string): Promise<OpResult>;
|
|
98
99
|
/** A sale paid at once (the body as Intuit takes it — `Line`, `DepositToAccountRef`, …). */
|
|
99
100
|
createSalesReceipt(company: QuickBooksCompany, receipt: Record<string, unknown>, requestId: string): Promise<OpResult>;
|
|
@@ -306,12 +306,18 @@ class QuickBooksGw extends BaseExternalApiGateway {
|
|
|
306
306
|
/** A customer by display name (unique in the company across customers, vendors and employees). */
|
|
307
307
|
createCustomer(company, customer, requestId) {
|
|
308
308
|
const displayName = quickBooksNameOf(customer?.displayName);
|
|
309
|
+
const currency = text(customer?.currency).toUpperCase();
|
|
309
310
|
if (!displayName) {
|
|
310
311
|
return Promise.resolve(OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, null, 'A customer needs a name'));
|
|
311
312
|
}
|
|
313
|
+
if (currency && !/^[A-Z]{3}$/.test(currency)) {
|
|
314
|
+
return Promise.resolve(OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, null, 'A customer currency is a three-letter code'));
|
|
315
|
+
}
|
|
312
316
|
return this.create(company, 'Customer', {
|
|
313
317
|
DisplayName: displayName,
|
|
314
318
|
...(text(customer.email).includes('@') ? { PrimaryEmailAddr: { Address: text(customer.email) } } : {}),
|
|
319
|
+
// ⓘ Multicurrency: a customer's currency is set when it is made and never changes (Intuit) — with none, the home one.
|
|
320
|
+
...(currency ? { CurrencyRef: { value: currency } } : {}),
|
|
315
321
|
}, requestId);
|
|
316
322
|
}
|
|
317
323
|
/** A sale paid at once (the body as Intuit takes it — `Line`, `DepositToAccountRef`, …). */
|
|
@@ -94,6 +94,7 @@ declare class QuickBooksGw extends BaseExternalApiGateway<QuickBooksSettings> {
|
|
|
94
94
|
createCustomer(company: QuickBooksCompany, customer: {
|
|
95
95
|
displayName: string;
|
|
96
96
|
email?: string | null;
|
|
97
|
+
currency?: string | null;
|
|
97
98
|
}, requestId: string): Promise<OpResult>;
|
|
98
99
|
/** A sale paid at once (the body as Intuit takes it — `Line`, `DepositToAccountRef`, …). */
|
|
99
100
|
createSalesReceipt(company: QuickBooksCompany, receipt: Record<string, unknown>, requestId: string): Promise<OpResult>;
|
|
@@ -311,12 +311,18 @@ class QuickBooksGw extends BaseExternalApiGateway_1.BaseExternalApiGateway {
|
|
|
311
311
|
/** A customer by display name (unique in the company across customers, vendors and employees). */
|
|
312
312
|
createCustomer(company, customer, requestId) {
|
|
313
313
|
const displayName = (0, exports.quickBooksNameOf)(customer?.displayName);
|
|
314
|
+
const currency = text(customer?.currency).toUpperCase();
|
|
314
315
|
if (!displayName) {
|
|
315
316
|
return Promise.resolve(api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'A customer needs a name'));
|
|
316
317
|
}
|
|
318
|
+
if (currency && !/^[A-Z]{3}$/.test(currency)) {
|
|
319
|
+
return Promise.resolve(api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'A customer currency is a three-letter code'));
|
|
320
|
+
}
|
|
317
321
|
return this.create(company, 'Customer', {
|
|
318
322
|
DisplayName: displayName,
|
|
319
323
|
...(text(customer.email).includes('@') ? { PrimaryEmailAddr: { Address: text(customer.email) } } : {}),
|
|
324
|
+
// ⓘ Multicurrency: a customer's currency is set when it is made and never changes (Intuit) — with none, the home one.
|
|
325
|
+
...(currency ? { CurrencyRef: { value: currency } } : {}),
|
|
320
326
|
}, requestId);
|
|
321
327
|
}
|
|
322
328
|
/** A sale paid at once (the body as Intuit takes it — `Line`, `DepositToAccountRef`, …). */
|