repzo 1.0.228 → 1.0.230
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 +34 -0
- package/changelog.md +5 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +78 -28
- package/lib/types/index.d.ts +321 -1
- package/package.json +1 -1
- package/src/index.ts +114 -28
- package/src/types/index.ts +383 -1
package/README.md
CHANGED
|
@@ -26,7 +26,21 @@ npm install repzo
|
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
28
|
import Repzo from "repzo";
|
|
29
|
+
|
|
30
|
+
// Basic initialization
|
|
29
31
|
const repzo = new Repzo("my-repzo-api-key");
|
|
32
|
+
|
|
33
|
+
// With options (staging environment, custom timeout, retry logic)
|
|
34
|
+
const repzoWithOptions = new Repzo("my-repzo-api-key", {
|
|
35
|
+
env: "staging", // 'production', 'staging', or 'local'
|
|
36
|
+
timeout: 60000, // Request timeout in milliseconds
|
|
37
|
+
retryAttempts: 3, // Number of retry attempts (default: 3)
|
|
38
|
+
headers: {
|
|
39
|
+
"Custom-Header": "value",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Find clients
|
|
30
44
|
let clients = repzo.client.find({ search: "Mecca" });
|
|
31
45
|
|
|
32
46
|
// Example usage with type safety
|
|
@@ -39,6 +53,26 @@ const params: Service.Client.Find.Params = {
|
|
|
39
53
|
// Your API implementation here
|
|
40
54
|
```
|
|
41
55
|
|
|
56
|
+
### Retry Logic
|
|
57
|
+
|
|
58
|
+
The SDK includes automatic retry logic for failed requests:
|
|
59
|
+
|
|
60
|
+
- **Default Behavior**: Automatically retries failed requests up to 3 times
|
|
61
|
+
- **Exponential Backoff**: Uses exponential backoff strategy (2^attempt seconds)
|
|
62
|
+
- **401 Protection**: Never retries on 401 (Unauthorized) errors
|
|
63
|
+
- **Configurable**: Set custom retry attempts via `retryAttempts` option
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// Default: 3 retry attempts
|
|
67
|
+
const repzo = new Repzo("api-key");
|
|
68
|
+
|
|
69
|
+
// Custom: 5 retry attempts
|
|
70
|
+
const repzoCustom = new Repzo("api-key", { retryAttempts: 5 });
|
|
71
|
+
|
|
72
|
+
// Disable retries: 1 attempt only
|
|
73
|
+
const repzoNoRetry = new Repzo("api-key", { retryAttempts: 1 });
|
|
74
|
+
```
|
|
75
|
+
|
|
42
76
|
## 📖 Documentation
|
|
43
77
|
|
|
44
78
|
This SDK provides **three levels of documentation**:
|
package/changelog.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
- add: Automatic retry logic for HTTP requests with exponential backoff (default: 3 attempts, configurable via `retryAttempts` option)
|
|
8
|
+
- add: `retryAttempts` option to SDK constructor for configuring retry behavior @mkhamis
|
|
9
|
+
- add: 401 error protection - authentication errors are never retried @mkhamis
|
|
7
10
|
- add: asset-part-type, asset-part, asset-part-unit, asset-part-transfer, asset-part-receival, return-asset-part-unit & store-asset-part-unit @maramalshen
|
|
8
11
|
- update adjustInventory @maramalshen
|
|
9
12
|
- update FullInvoice with ubl keys @maramalshen
|
|
@@ -14,6 +17,8 @@
|
|
|
14
17
|
|
|
15
18
|
### Changed
|
|
16
19
|
|
|
20
|
+
- All HTTP methods (\_fetch, \_create, \_update, \_patch, \_delete) now support automatic retry with exponential backoff @mkhamis
|
|
21
|
+
|
|
17
22
|
### Fixed
|
|
18
23
|
|
|
19
24
|
### Removed
|
package/lib/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const end_points: {
|
|
|
38
38
|
readonly VISIT: "visit";
|
|
39
39
|
readonly INVOICE: "fullinvoices";
|
|
40
40
|
readonly PROFORMA: "proforma";
|
|
41
|
+
readonly PRINT_SETTINGS: "print-settings";
|
|
41
42
|
readonly PAYMENT: "payments";
|
|
42
43
|
readonly REFUND: "refund";
|
|
43
44
|
readonly SETTLEMENT: "settlement";
|
|
@@ -123,6 +124,7 @@ export default class Repzo {
|
|
|
123
124
|
private svAPIEndpoint;
|
|
124
125
|
headers: Headers;
|
|
125
126
|
private timeout;
|
|
127
|
+
private retryAttempts;
|
|
126
128
|
constructor(apiKey: string, options?: Options);
|
|
127
129
|
private static _end_points;
|
|
128
130
|
static get END_POINTS(): {
|
|
@@ -164,6 +166,7 @@ export default class Repzo {
|
|
|
164
166
|
readonly VISIT: "visit";
|
|
165
167
|
readonly INVOICE: "fullinvoices";
|
|
166
168
|
readonly PROFORMA: "proforma";
|
|
169
|
+
readonly PRINT_SETTINGS: "print-settings";
|
|
167
170
|
readonly PAYMENT: "payments";
|
|
168
171
|
readonly REFUND: "refund";
|
|
169
172
|
readonly SETTLEMENT: "settlement";
|
|
@@ -242,6 +245,7 @@ export default class Repzo {
|
|
|
242
245
|
readonly PROMOTIONS: "promotions";
|
|
243
246
|
readonly COMPARE_INVOICE_TO_WAREHOUSE: "compare-invoice-to-warehouse";
|
|
244
247
|
};
|
|
248
|
+
private _retryRequest;
|
|
245
249
|
private _fetch;
|
|
246
250
|
private _create;
|
|
247
251
|
private _update;
|
|
@@ -1128,4 +1132,11 @@ export default class Repzo {
|
|
|
1128
1132
|
_path: "compare-invoice-to-warehouse";
|
|
1129
1133
|
find: (params?: Service.CompareInvoiceToWarehouse.Find.Params) => Promise<Service.CompareInvoiceToWarehouse.Find.Result>;
|
|
1130
1134
|
};
|
|
1135
|
+
printSettings: {
|
|
1136
|
+
_path: "print-settings";
|
|
1137
|
+
find: (params?: Service.PrintSetting.Find.Params) => Promise<Service.PrintSetting.Find.Result>;
|
|
1138
|
+
get: (id: Service.PrintSetting.Get.ID) => Promise<Service.PrintSetting.Get.Result>;
|
|
1139
|
+
create: (body: Service.PrintSetting.Create.Body) => Promise<Service.PrintSetting.Create.Result>;
|
|
1140
|
+
update: (id: Service.PrintSetting.Update.ID, body: Service.PrintSetting.Update.Body) => Promise<Service.PrintSetting.Update.Result>;
|
|
1141
|
+
};
|
|
1131
1142
|
}
|
package/lib/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export const end_points = {
|
|
|
39
39
|
VISIT: "visit",
|
|
40
40
|
INVOICE: "fullinvoices",
|
|
41
41
|
PROFORMA: "proforma",
|
|
42
|
+
PRINT_SETTINGS: "print-settings",
|
|
42
43
|
PAYMENT: "payments",
|
|
43
44
|
REFUND: "refund",
|
|
44
45
|
SETTLEMENT: "settlement",
|
|
@@ -2317,6 +2318,24 @@ class Repzo {
|
|
|
2317
2318
|
return res;
|
|
2318
2319
|
},
|
|
2319
2320
|
};
|
|
2321
|
+
this.printSettings = {
|
|
2322
|
+
_path: Repzo._end_points.PRINT_SETTINGS,
|
|
2323
|
+
find: async (params) => {
|
|
2324
|
+
let res = await this._fetch(this.svAPIEndpoint, this.printSettings._path, params);
|
|
2325
|
+
return res;
|
|
2326
|
+
},
|
|
2327
|
+
get: async (id) => {
|
|
2328
|
+
return await this._fetch(this.svAPIEndpoint, this.printSettings._path + `/${id}`);
|
|
2329
|
+
},
|
|
2330
|
+
create: async (body) => {
|
|
2331
|
+
let res = await this._create(this.svAPIEndpoint, this.printSettings._path, body);
|
|
2332
|
+
return res;
|
|
2333
|
+
},
|
|
2334
|
+
update: async (id, body) => {
|
|
2335
|
+
let res = await this._update(this.svAPIEndpoint, this.printSettings._path + `/${id}`, body);
|
|
2336
|
+
return res;
|
|
2337
|
+
},
|
|
2338
|
+
};
|
|
2320
2339
|
this.svAPIEndpoint =
|
|
2321
2340
|
!options?.env || options?.env == "production"
|
|
2322
2341
|
? "https://sv.api.repzo.me"
|
|
@@ -2338,52 +2357,83 @@ class Repzo {
|
|
|
2338
2357
|
else {
|
|
2339
2358
|
this.timeout = 180000;
|
|
2340
2359
|
}
|
|
2360
|
+
this.retryAttempts = options?.retryAttempts ?? 3;
|
|
2341
2361
|
}
|
|
2342
2362
|
static get END_POINTS() {
|
|
2343
2363
|
return Repzo._end_points;
|
|
2344
2364
|
}
|
|
2345
|
-
async
|
|
2346
|
-
|
|
2347
|
-
|
|
2365
|
+
async _retryRequest(requestFn, attempt = 1) {
|
|
2366
|
+
try {
|
|
2367
|
+
return await requestFn();
|
|
2368
|
+
}
|
|
2369
|
+
catch (error) {
|
|
2370
|
+
// Don't retry on 401 (Unauthorized) errors
|
|
2371
|
+
if (error?.response?.status === 401) {
|
|
2372
|
+
throw error;
|
|
2373
|
+
}
|
|
2374
|
+
// Retry if we haven't exceeded the retry attempts
|
|
2375
|
+
if (attempt < this.retryAttempts) {
|
|
2376
|
+
// Exponential backoff: wait 2^attempt seconds before retrying
|
|
2377
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
2378
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2379
|
+
return this._retryRequest(requestFn, attempt + 1);
|
|
2380
|
+
}
|
|
2381
|
+
// If all retries failed, throw the error
|
|
2382
|
+
throw error;
|
|
2348
2383
|
}
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2384
|
+
}
|
|
2385
|
+
async _fetch(baseUrl, path, params) {
|
|
2386
|
+
return this._retryRequest(async () => {
|
|
2387
|
+
if (params) {
|
|
2388
|
+
params = normalizeParams(params);
|
|
2389
|
+
}
|
|
2390
|
+
let res = await axios.get(`${baseUrl}/${path}`, {
|
|
2391
|
+
params,
|
|
2392
|
+
headers: this.headers,
|
|
2393
|
+
timeout: this.timeout,
|
|
2394
|
+
});
|
|
2395
|
+
return res.data;
|
|
2353
2396
|
});
|
|
2354
|
-
return res.data;
|
|
2355
2397
|
}
|
|
2356
2398
|
async _create(baseUrl, path, body, params) {
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2399
|
+
return this._retryRequest(async () => {
|
|
2400
|
+
let res = await axios.post(`${baseUrl}/${path}`, body, {
|
|
2401
|
+
params,
|
|
2402
|
+
headers: this.headers,
|
|
2403
|
+
timeout: this.timeout,
|
|
2404
|
+
});
|
|
2405
|
+
return res.data;
|
|
2361
2406
|
});
|
|
2362
|
-
return res.data;
|
|
2363
2407
|
}
|
|
2364
2408
|
async _update(baseUrl, path, body, params) {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2409
|
+
return this._retryRequest(async () => {
|
|
2410
|
+
let res = await axios.put(`${baseUrl}/${path}`, body, {
|
|
2411
|
+
params,
|
|
2412
|
+
headers: this.headers,
|
|
2413
|
+
timeout: this.timeout,
|
|
2414
|
+
});
|
|
2415
|
+
return res.data;
|
|
2369
2416
|
});
|
|
2370
|
-
return res.data;
|
|
2371
2417
|
}
|
|
2372
2418
|
async _patch(baseUrl, path, body, params) {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2419
|
+
return this._retryRequest(async () => {
|
|
2420
|
+
let res = await axios.put(`${baseUrl}/${path}`, body, {
|
|
2421
|
+
params,
|
|
2422
|
+
headers: this.headers,
|
|
2423
|
+
timeout: this.timeout,
|
|
2424
|
+
});
|
|
2425
|
+
return res.data;
|
|
2377
2426
|
});
|
|
2378
|
-
return res.data;
|
|
2379
2427
|
}
|
|
2380
2428
|
async _delete(baseUrl, path, params) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2429
|
+
return this._retryRequest(async () => {
|
|
2430
|
+
let res = await axios.delete(`${baseUrl}/${path}`, {
|
|
2431
|
+
params,
|
|
2432
|
+
headers: this.headers,
|
|
2433
|
+
timeout: this.timeout,
|
|
2434
|
+
});
|
|
2435
|
+
return res.data;
|
|
2385
2436
|
});
|
|
2386
|
-
return res.data;
|
|
2387
2437
|
}
|
|
2388
2438
|
}
|
|
2389
2439
|
Repzo._end_points = end_points;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface Options {
|
|
|
12
12
|
[key: string]: string;
|
|
13
13
|
};
|
|
14
14
|
timeout?: number | undefined;
|
|
15
|
+
retryAttempts?: number;
|
|
15
16
|
}
|
|
16
17
|
export interface Headers {
|
|
17
18
|
"api-key": string;
|
|
@@ -239,7 +240,8 @@ export interface CalendarWeeklyGroup {
|
|
|
239
240
|
}
|
|
240
241
|
export type Model = "quickConvertToPdf" | "warehouses" | "transfers" | "transactions" | "taxes" | "productvariations" | "products" | "pricelistsitems" | "pricelists" | "payments" | "ledger_payments" | "mslsales" | "mslproducts" | "measureunits" | "measureunitfamilies" | "invoicesitems" | "invoices" | "ledger_goods" | "fullinvoices" | "checks" | "clients" | "activities" | "bigReports" | "admins";
|
|
241
242
|
export type DocumentTypes = "form" | "quickConvertToPdf" | "clients" | "asset" | "assetUnit" | "workorder" | "clientLocation" | "clientContact" | "commentsThread" | "workorderRequest" | "workorderPortal" | "invoice" | "products" | "productvariations" | "representatives" | "productcategories" | "productSubCategory" | "speciality" | "line" | "banner" | "intgAvailableApps" | "availability_msl" | "reminders" | "audits" | "availability" | "photos" | "planogram" | "tasks" | "checks" | "notificationsCenter" | "admins" | "settings" | "printWorkorderPortalLink" | "bulkExport" | "generateRule" | "scheduleEmail" | "custom-list-item" | "days" | "bulkImport" | "sv.activitiesstorechecks" | "retailExecutionPreset" | "paymentMethod" | "approvalRequest" | "activityFormV2Result" | "formV2" | "payments" | "ocrInvoiceJob" | "contract" | "contractInstallment" | "form" | "paymentMethod" | "aiObjectDetectionModelVersion" | "aiObjectDetectionTask" | "assetPart" | "assetPartReceival" | "assetPartUnit" | "returnAssetPartUnit" | "storeAssetPartUnit" | "activityAiSalesOrder" | "ocrInvoiceJobGroup";
|
|
242
|
-
export type PrintTypes = "workorder" | "form" | "invoice" | "proforma";
|
|
243
|
+
export type PrintTypes = "workorder" | "form" | "invoice" | "proforma" | "settlement";
|
|
244
|
+
export type InvoiceFontStyles = "InvoiceHeaderTitle" | "InvoiceTaxNumber" | "InvoiceType" | "InvoiceInfo" | "ItemsHeader" | "ItemLabel" | "ItemValue" | "ItemVariant" | "TotalItemsQty" | "TotalAmount" | "RepReciver" | "Address" | "PrintTime" | "InvoiceHeader" | "ClientBalance";
|
|
243
245
|
type Granularity = "Year" | "Year Month" | "Year Week" | "Month" | "Year Month Day" | "Year Month Day Time" | "Year Month Day Time Offset";
|
|
244
246
|
export interface MediaDoc {
|
|
245
247
|
_id?: string;
|
|
@@ -17037,6 +17039,324 @@ export declare namespace Service {
|
|
|
17037
17039
|
}
|
|
17038
17040
|
}
|
|
17039
17041
|
}
|
|
17042
|
+
namespace PrintSetting {
|
|
17043
|
+
type ImageSize = "original" | "small" | "medium" | "large" | "extra";
|
|
17044
|
+
type QrCodeSize = "small" | "medium" | "large";
|
|
17045
|
+
type Alignment = "right" | "left" | "center";
|
|
17046
|
+
interface InvoiceFontsWithSizes {
|
|
17047
|
+
style_name: InvoiceFontStyles;
|
|
17048
|
+
size: number;
|
|
17049
|
+
}
|
|
17050
|
+
interface ItemImage {
|
|
17051
|
+
view_item_image?: boolean;
|
|
17052
|
+
item_image_source?: "variant" | "product";
|
|
17053
|
+
item_image_size?: ImageSize;
|
|
17054
|
+
}
|
|
17055
|
+
interface User {
|
|
17056
|
+
_id: string;
|
|
17057
|
+
type: "admin" | "rep";
|
|
17058
|
+
name?: string;
|
|
17059
|
+
admin?: string;
|
|
17060
|
+
}
|
|
17061
|
+
interface WorkorderBasicDetails {
|
|
17062
|
+
creator?: boolean;
|
|
17063
|
+
workorder_categories?: boolean;
|
|
17064
|
+
client_name?: boolean;
|
|
17065
|
+
description?: boolean;
|
|
17066
|
+
local_name?: boolean;
|
|
17067
|
+
client_location?: boolean;
|
|
17068
|
+
assigned_to?: boolean;
|
|
17069
|
+
media?: boolean;
|
|
17070
|
+
cover_photo?: boolean;
|
|
17071
|
+
status?: boolean;
|
|
17072
|
+
assets?: boolean;
|
|
17073
|
+
asset_units?: boolean;
|
|
17074
|
+
priority_human?: boolean;
|
|
17075
|
+
due_date?: boolean;
|
|
17076
|
+
start_date?: boolean;
|
|
17077
|
+
forms?: boolean;
|
|
17078
|
+
comments?: boolean;
|
|
17079
|
+
createdAt?: boolean;
|
|
17080
|
+
}
|
|
17081
|
+
interface WorkorderClientDetails {
|
|
17082
|
+
withClientDetails?: boolean;
|
|
17083
|
+
basicClientDetails?: {
|
|
17084
|
+
client_code?: boolean;
|
|
17085
|
+
client_local_name?: boolean;
|
|
17086
|
+
client_tags?: boolean;
|
|
17087
|
+
area_tags?: boolean;
|
|
17088
|
+
client_channel?: boolean;
|
|
17089
|
+
is_chain?: boolean;
|
|
17090
|
+
teams?: boolean;
|
|
17091
|
+
product_groups?: boolean;
|
|
17092
|
+
contacts?: boolean;
|
|
17093
|
+
createdAt?: boolean;
|
|
17094
|
+
customFields?: boolean;
|
|
17095
|
+
};
|
|
17096
|
+
sales?: {
|
|
17097
|
+
price_list?: boolean;
|
|
17098
|
+
payment_type?: boolean;
|
|
17099
|
+
credit_limit?: boolean;
|
|
17100
|
+
payment_term?: boolean;
|
|
17101
|
+
};
|
|
17102
|
+
contact_info?: {
|
|
17103
|
+
contact_name?: boolean;
|
|
17104
|
+
client_info?: boolean;
|
|
17105
|
+
email?: boolean;
|
|
17106
|
+
website?: boolean;
|
|
17107
|
+
};
|
|
17108
|
+
}
|
|
17109
|
+
interface WorkorderAssetDetails {
|
|
17110
|
+
withAssetsDetails?: boolean;
|
|
17111
|
+
media?: boolean;
|
|
17112
|
+
local_name?: boolean;
|
|
17113
|
+
description?: boolean;
|
|
17114
|
+
asset_types?: boolean;
|
|
17115
|
+
location?: boolean;
|
|
17116
|
+
model?: boolean;
|
|
17117
|
+
manufacturer?: boolean;
|
|
17118
|
+
year?: boolean;
|
|
17119
|
+
barcode?: boolean;
|
|
17120
|
+
customFields?: boolean;
|
|
17121
|
+
createdAt?: boolean;
|
|
17122
|
+
cover_photo?: boolean;
|
|
17123
|
+
}
|
|
17124
|
+
interface WorkorderAssetUnitDetails {
|
|
17125
|
+
withAssetUnitsDetails?: boolean;
|
|
17126
|
+
media?: boolean;
|
|
17127
|
+
local_name?: boolean;
|
|
17128
|
+
description?: boolean;
|
|
17129
|
+
serial_number?: boolean;
|
|
17130
|
+
asset?: boolean;
|
|
17131
|
+
location?: boolean;
|
|
17132
|
+
customFields?: boolean;
|
|
17133
|
+
createdAt?: boolean;
|
|
17134
|
+
cover_photo?: boolean;
|
|
17135
|
+
}
|
|
17136
|
+
interface WorkorderDetails {
|
|
17137
|
+
document_type: "workorder";
|
|
17138
|
+
number_of_comments?: number;
|
|
17139
|
+
compressed_media_size?: ImageSize;
|
|
17140
|
+
basicDetails?: WorkorderBasicDetails;
|
|
17141
|
+
clientDetails?: WorkorderClientDetails;
|
|
17142
|
+
assetDetails?: WorkorderAssetDetails;
|
|
17143
|
+
assetUnitDetails?: WorkorderAssetUnitDetails;
|
|
17144
|
+
}
|
|
17145
|
+
interface FormResultDetails {
|
|
17146
|
+
document_type: "form";
|
|
17147
|
+
compressed_media_size?: ImageSize;
|
|
17148
|
+
}
|
|
17149
|
+
interface InvoiceBasicDetails {
|
|
17150
|
+
created_at?: boolean;
|
|
17151
|
+
created_by?: boolean;
|
|
17152
|
+
tax_number?: boolean;
|
|
17153
|
+
name_on_invoice?: boolean;
|
|
17154
|
+
client_code?: boolean;
|
|
17155
|
+
client_name?: boolean;
|
|
17156
|
+
client_local_name?: boolean;
|
|
17157
|
+
client_address?: boolean;
|
|
17158
|
+
client_phone?: boolean;
|
|
17159
|
+
client_tax_number?: boolean;
|
|
17160
|
+
client_cell_phone?: boolean;
|
|
17161
|
+
issue_date?: boolean;
|
|
17162
|
+
due_date?: boolean;
|
|
17163
|
+
invoice_status?: boolean;
|
|
17164
|
+
company_logo?: boolean;
|
|
17165
|
+
serial_number?: boolean;
|
|
17166
|
+
advanced_serial_number?: boolean;
|
|
17167
|
+
external_serial_number?: boolean;
|
|
17168
|
+
comment?: boolean;
|
|
17169
|
+
qr_code?: boolean;
|
|
17170
|
+
custom_status?: boolean;
|
|
17171
|
+
payments_data?: boolean;
|
|
17172
|
+
media?: boolean;
|
|
17173
|
+
address?: boolean;
|
|
17174
|
+
remaining_balance?: boolean;
|
|
17175
|
+
invoice_header?: string;
|
|
17176
|
+
invoice_notes?: string;
|
|
17177
|
+
client_balance?: boolean;
|
|
17178
|
+
origin_serial_number?: boolean;
|
|
17179
|
+
origin_advanced_serial_number?: boolean;
|
|
17180
|
+
workorder_serial_number?: boolean;
|
|
17181
|
+
workorder_name?: boolean;
|
|
17182
|
+
workorder_local_name?: boolean;
|
|
17183
|
+
total_items_base_unit_qty?: boolean;
|
|
17184
|
+
total_items_qty?: boolean;
|
|
17185
|
+
total_return_items_base_unit_qty?: boolean;
|
|
17186
|
+
total_return_items_qty?: boolean;
|
|
17187
|
+
}
|
|
17188
|
+
interface InvoiceLineItemDetails {
|
|
17189
|
+
sku?: boolean;
|
|
17190
|
+
barcode?: boolean;
|
|
17191
|
+
product_name?: boolean;
|
|
17192
|
+
variant_name?: boolean;
|
|
17193
|
+
measureunit?: boolean;
|
|
17194
|
+
qty?: boolean;
|
|
17195
|
+
price?: boolean;
|
|
17196
|
+
discount_amount?: boolean;
|
|
17197
|
+
line_total?: boolean;
|
|
17198
|
+
return_reason?: boolean;
|
|
17199
|
+
base_unit_qty?: boolean;
|
|
17200
|
+
original_price?: boolean;
|
|
17201
|
+
total_original_price?: boolean;
|
|
17202
|
+
item_image?: ItemImage;
|
|
17203
|
+
batch_number?: boolean;
|
|
17204
|
+
batch_expiry?: boolean;
|
|
17205
|
+
batch_qty?: boolean;
|
|
17206
|
+
}
|
|
17207
|
+
interface InvoiceMobileDetails {
|
|
17208
|
+
logo_height?: number | string;
|
|
17209
|
+
logo_width?: number | string;
|
|
17210
|
+
align_logo?: Alignment;
|
|
17211
|
+
align_invoice_header?: Alignment;
|
|
17212
|
+
font_styles?: InvoiceFontsWithSizes[];
|
|
17213
|
+
hide_invoice_payment_type?: boolean;
|
|
17214
|
+
invoice_header?: string;
|
|
17215
|
+
client_balance?: boolean;
|
|
17216
|
+
}
|
|
17217
|
+
interface InvoiceDetails {
|
|
17218
|
+
document_type: "invoice";
|
|
17219
|
+
compressed_media_size?: ImageSize;
|
|
17220
|
+
logo_size?: ImageSize;
|
|
17221
|
+
qr_code_size?: QrCodeSize;
|
|
17222
|
+
basicDetails?: InvoiceBasicDetails;
|
|
17223
|
+
lineItemDetails?: InvoiceLineItemDetails;
|
|
17224
|
+
mobileDetails?: InvoiceMobileDetails;
|
|
17225
|
+
}
|
|
17226
|
+
interface ProformaBasicDetails {
|
|
17227
|
+
created_at?: boolean;
|
|
17228
|
+
created_by?: boolean;
|
|
17229
|
+
tax_number?: boolean;
|
|
17230
|
+
name_on_invoice?: boolean;
|
|
17231
|
+
client_code?: boolean;
|
|
17232
|
+
client_name?: boolean;
|
|
17233
|
+
client_local_name?: boolean;
|
|
17234
|
+
client_address?: boolean;
|
|
17235
|
+
client_phone?: boolean;
|
|
17236
|
+
client_tax_number?: boolean;
|
|
17237
|
+
client_cell_phone?: boolean;
|
|
17238
|
+
issue_date?: boolean;
|
|
17239
|
+
order_status?: boolean;
|
|
17240
|
+
company_logo?: boolean;
|
|
17241
|
+
serial_number?: boolean;
|
|
17242
|
+
external_serial_number?: boolean;
|
|
17243
|
+
comment?: boolean;
|
|
17244
|
+
custom_status?: boolean;
|
|
17245
|
+
media?: boolean;
|
|
17246
|
+
address?: boolean;
|
|
17247
|
+
invoice_header?: string;
|
|
17248
|
+
invoice_notes?: string;
|
|
17249
|
+
total_items_base_unit_qty?: boolean;
|
|
17250
|
+
total_items_qty?: boolean;
|
|
17251
|
+
total_return_items_base_unit_qty?: boolean;
|
|
17252
|
+
total_return_items_qty?: boolean;
|
|
17253
|
+
}
|
|
17254
|
+
interface ProformaLineItemDetails {
|
|
17255
|
+
product_name?: boolean;
|
|
17256
|
+
variant_name?: boolean;
|
|
17257
|
+
sku?: boolean;
|
|
17258
|
+
barcode?: boolean;
|
|
17259
|
+
measureunit?: boolean;
|
|
17260
|
+
qty?: boolean;
|
|
17261
|
+
price?: boolean;
|
|
17262
|
+
line_total?: boolean;
|
|
17263
|
+
note?: boolean;
|
|
17264
|
+
base_unit_qty?: boolean;
|
|
17265
|
+
item_image?: ItemImage;
|
|
17266
|
+
return_reason?: boolean;
|
|
17267
|
+
original_price?: boolean;
|
|
17268
|
+
total_original_price?: boolean;
|
|
17269
|
+
batch_number?: boolean;
|
|
17270
|
+
batch_expiry?: boolean;
|
|
17271
|
+
batch_qty?: boolean;
|
|
17272
|
+
}
|
|
17273
|
+
interface ProformaMobileDetails {
|
|
17274
|
+
logo_height?: number | string;
|
|
17275
|
+
logo_width?: number | string;
|
|
17276
|
+
align_logo?: Alignment;
|
|
17277
|
+
font_styles?: InvoiceFontsWithSizes[];
|
|
17278
|
+
align_invoice_header?: Alignment;
|
|
17279
|
+
hide_invoice_payment_type?: boolean;
|
|
17280
|
+
invoice_header?: string;
|
|
17281
|
+
}
|
|
17282
|
+
interface ProformaDetails {
|
|
17283
|
+
document_type: "proforma";
|
|
17284
|
+
compressed_media_size?: ImageSize;
|
|
17285
|
+
logo_size?: ImageSize;
|
|
17286
|
+
basicDetails?: ProformaBasicDetails;
|
|
17287
|
+
lineItemDetails?: ProformaLineItemDetails;
|
|
17288
|
+
mobileDetails?: ProformaMobileDetails;
|
|
17289
|
+
}
|
|
17290
|
+
interface SettlementBasicDetails {
|
|
17291
|
+
creator?: boolean;
|
|
17292
|
+
settlement_date?: boolean;
|
|
17293
|
+
company_logo?: boolean;
|
|
17294
|
+
serial_number?: boolean;
|
|
17295
|
+
note?: boolean;
|
|
17296
|
+
amount?: boolean;
|
|
17297
|
+
payment_type?: boolean;
|
|
17298
|
+
checks?: boolean;
|
|
17299
|
+
rep?: boolean;
|
|
17300
|
+
totals?: boolean;
|
|
17301
|
+
media?: boolean;
|
|
17302
|
+
}
|
|
17303
|
+
interface SettlementCheckDetails {
|
|
17304
|
+
bank_name?: boolean;
|
|
17305
|
+
branch_name?: boolean;
|
|
17306
|
+
drawer_name?: boolean;
|
|
17307
|
+
client_name?: boolean;
|
|
17308
|
+
check_number?: boolean;
|
|
17309
|
+
pay_time?: boolean;
|
|
17310
|
+
rep_name?: boolean;
|
|
17311
|
+
check_date?: boolean;
|
|
17312
|
+
}
|
|
17313
|
+
interface SettlementDetails {
|
|
17314
|
+
document_type: "settlement";
|
|
17315
|
+
compressed_media_size?: ImageSize;
|
|
17316
|
+
basicDetails?: SettlementBasicDetails;
|
|
17317
|
+
checkDetails?: SettlementCheckDetails;
|
|
17318
|
+
}
|
|
17319
|
+
type Details = WorkorderDetails | FormResultDetails | InvoiceDetails | ProformaDetails | SettlementDetails;
|
|
17320
|
+
interface Data {
|
|
17321
|
+
_id: string;
|
|
17322
|
+
creator: User;
|
|
17323
|
+
editor?: User;
|
|
17324
|
+
document_type: PrintTypes;
|
|
17325
|
+
details: Details;
|
|
17326
|
+
company_namespace: string[];
|
|
17327
|
+
createdAt: Date;
|
|
17328
|
+
updatedAt: Date;
|
|
17329
|
+
__v?: number;
|
|
17330
|
+
}
|
|
17331
|
+
interface CreateBody {
|
|
17332
|
+
document_type: PrintTypes;
|
|
17333
|
+
details: Details;
|
|
17334
|
+
}
|
|
17335
|
+
interface UpdateBody {
|
|
17336
|
+
details?: Partial<Details>;
|
|
17337
|
+
}
|
|
17338
|
+
namespace Find {
|
|
17339
|
+
type Params = DefaultPaginationQueryParams & {
|
|
17340
|
+
document_type?: PrintTypes | PrintTypes[];
|
|
17341
|
+
};
|
|
17342
|
+
interface Result extends DefaultPaginationResult {
|
|
17343
|
+
data: Data[];
|
|
17344
|
+
}
|
|
17345
|
+
}
|
|
17346
|
+
namespace Get {
|
|
17347
|
+
type ID = string;
|
|
17348
|
+
type Result = Data;
|
|
17349
|
+
}
|
|
17350
|
+
namespace Create {
|
|
17351
|
+
type Body = CreateBody;
|
|
17352
|
+
type Result = Data;
|
|
17353
|
+
}
|
|
17354
|
+
namespace Update {
|
|
17355
|
+
type ID = string;
|
|
17356
|
+
type Body = UpdateBody;
|
|
17357
|
+
type Result = Data;
|
|
17358
|
+
}
|
|
17359
|
+
}
|
|
17040
17360
|
}
|
|
17041
17361
|
export type StringId = string;
|
|
17042
17362
|
export type NameSpaces = string[];
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -49,6 +49,7 @@ export const end_points = {
|
|
|
49
49
|
VISIT: "visit",
|
|
50
50
|
INVOICE: "fullinvoices",
|
|
51
51
|
PROFORMA: "proforma",
|
|
52
|
+
PRINT_SETTINGS: "print-settings",
|
|
52
53
|
PAYMENT: "payments",
|
|
53
54
|
REFUND: "refund",
|
|
54
55
|
SETTLEMENT: "settlement",
|
|
@@ -230,6 +231,7 @@ export default class Repzo {
|
|
|
230
231
|
private svAPIEndpoint: string;
|
|
231
232
|
headers: Headers;
|
|
232
233
|
private timeout: number;
|
|
234
|
+
private retryAttempts: number;
|
|
233
235
|
constructor(apiKey: string, options?: Options) {
|
|
234
236
|
this.svAPIEndpoint =
|
|
235
237
|
!options?.env || options?.env == "production"
|
|
@@ -251,22 +253,51 @@ export default class Repzo {
|
|
|
251
253
|
} else {
|
|
252
254
|
this.timeout = 180000;
|
|
253
255
|
}
|
|
256
|
+
this.retryAttempts = options?.retryAttempts ?? 3;
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
private static _end_points = end_points;
|
|
257
260
|
public static get END_POINTS() {
|
|
258
261
|
return Repzo._end_points;
|
|
259
262
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
|
|
264
|
+
private async _retryRequest<T>(
|
|
265
|
+
requestFn: () => Promise<T>,
|
|
266
|
+
attempt: number = 1,
|
|
267
|
+
): Promise<T> {
|
|
268
|
+
try {
|
|
269
|
+
return await requestFn();
|
|
270
|
+
} catch (error: any) {
|
|
271
|
+
// Don't retry on 401 (Unauthorized) errors
|
|
272
|
+
if (error?.response?.status === 401) {
|
|
273
|
+
throw error;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Retry if we haven't exceeded the retry attempts
|
|
277
|
+
if (attempt < this.retryAttempts) {
|
|
278
|
+
// Exponential backoff: wait 2^attempt seconds before retrying
|
|
279
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
280
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
281
|
+
return this._retryRequest(requestFn, attempt + 1);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// If all retries failed, throw the error
|
|
285
|
+
throw error;
|
|
263
286
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private async _fetch(baseUrl: string, path: string, params?: Params) {
|
|
290
|
+
return this._retryRequest(async () => {
|
|
291
|
+
if (params) {
|
|
292
|
+
params = normalizeParams(params);
|
|
293
|
+
}
|
|
294
|
+
let res: any = await axios.get(`${baseUrl}/${path}`, {
|
|
295
|
+
params,
|
|
296
|
+
headers: this.headers,
|
|
297
|
+
timeout: this.timeout,
|
|
298
|
+
});
|
|
299
|
+
return res.data;
|
|
268
300
|
});
|
|
269
|
-
return res.data;
|
|
270
301
|
}
|
|
271
302
|
|
|
272
303
|
private async _create(
|
|
@@ -275,12 +306,14 @@ export default class Repzo {
|
|
|
275
306
|
body: Data,
|
|
276
307
|
params?: Params,
|
|
277
308
|
) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
309
|
+
return this._retryRequest(async () => {
|
|
310
|
+
let res: any = await axios.post(`${baseUrl}/${path}`, body, {
|
|
311
|
+
params,
|
|
312
|
+
headers: this.headers,
|
|
313
|
+
timeout: this.timeout,
|
|
314
|
+
});
|
|
315
|
+
return res.data;
|
|
282
316
|
});
|
|
283
|
-
return res.data;
|
|
284
317
|
}
|
|
285
318
|
|
|
286
319
|
private async _update(
|
|
@@ -289,12 +322,14 @@ export default class Repzo {
|
|
|
289
322
|
body: Data,
|
|
290
323
|
params?: Params,
|
|
291
324
|
) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
325
|
+
return this._retryRequest(async () => {
|
|
326
|
+
let res: any = await axios.put(`${baseUrl}/${path}`, body, {
|
|
327
|
+
params,
|
|
328
|
+
headers: this.headers,
|
|
329
|
+
timeout: this.timeout,
|
|
330
|
+
});
|
|
331
|
+
return res.data;
|
|
296
332
|
});
|
|
297
|
-
return res.data;
|
|
298
333
|
}
|
|
299
334
|
|
|
300
335
|
private async _patch(
|
|
@@ -303,21 +338,25 @@ export default class Repzo {
|
|
|
303
338
|
body: Data,
|
|
304
339
|
params?: Params,
|
|
305
340
|
) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
341
|
+
return this._retryRequest(async () => {
|
|
342
|
+
let res: any = await axios.put(`${baseUrl}/${path}`, body, {
|
|
343
|
+
params,
|
|
344
|
+
headers: this.headers,
|
|
345
|
+
timeout: this.timeout,
|
|
346
|
+
});
|
|
347
|
+
return res.data;
|
|
310
348
|
});
|
|
311
|
-
return res.data;
|
|
312
349
|
}
|
|
313
350
|
|
|
314
351
|
private async _delete(baseUrl: string, path: string, params?: Params) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
352
|
+
return this._retryRequest(async () => {
|
|
353
|
+
let res: any = await axios.delete(`${baseUrl}/${path}`, {
|
|
354
|
+
params,
|
|
355
|
+
headers: this.headers,
|
|
356
|
+
timeout: this.timeout,
|
|
357
|
+
});
|
|
358
|
+
return res.data;
|
|
319
359
|
});
|
|
320
|
-
return res.data;
|
|
321
360
|
}
|
|
322
361
|
|
|
323
362
|
available_services = availableService;
|
|
@@ -5858,6 +5897,53 @@ export default class Repzo {
|
|
|
5858
5897
|
return res;
|
|
5859
5898
|
},
|
|
5860
5899
|
};
|
|
5900
|
+
|
|
5901
|
+
printSettings = {
|
|
5902
|
+
_path: Repzo._end_points.PRINT_SETTINGS,
|
|
5903
|
+
|
|
5904
|
+
find: async (
|
|
5905
|
+
params?: Service.PrintSetting.Find.Params,
|
|
5906
|
+
): Promise<Service.PrintSetting.Find.Result> => {
|
|
5907
|
+
let res: Service.PrintSetting.Find.Result = await this._fetch(
|
|
5908
|
+
this.svAPIEndpoint,
|
|
5909
|
+
this.printSettings._path,
|
|
5910
|
+
params,
|
|
5911
|
+
);
|
|
5912
|
+
return res;
|
|
5913
|
+
},
|
|
5914
|
+
|
|
5915
|
+
get: async (
|
|
5916
|
+
id: Service.PrintSetting.Get.ID,
|
|
5917
|
+
): Promise<Service.PrintSetting.Get.Result> => {
|
|
5918
|
+
return await this._fetch(
|
|
5919
|
+
this.svAPIEndpoint,
|
|
5920
|
+
this.printSettings._path + `/${id}`,
|
|
5921
|
+
);
|
|
5922
|
+
},
|
|
5923
|
+
|
|
5924
|
+
create: async (
|
|
5925
|
+
body: Service.PrintSetting.Create.Body,
|
|
5926
|
+
): Promise<Service.PrintSetting.Create.Result> => {
|
|
5927
|
+
let res = await this._create(
|
|
5928
|
+
this.svAPIEndpoint,
|
|
5929
|
+
this.printSettings._path,
|
|
5930
|
+
body,
|
|
5931
|
+
);
|
|
5932
|
+
return res;
|
|
5933
|
+
},
|
|
5934
|
+
|
|
5935
|
+
update: async (
|
|
5936
|
+
id: Service.PrintSetting.Update.ID,
|
|
5937
|
+
body: Service.PrintSetting.Update.Body,
|
|
5938
|
+
): Promise<Service.PrintSetting.Update.Result> => {
|
|
5939
|
+
let res: Service.PrintSetting.Update.Result = await this._update(
|
|
5940
|
+
this.svAPIEndpoint,
|
|
5941
|
+
this.printSettings._path + `/${id}`,
|
|
5942
|
+
body,
|
|
5943
|
+
);
|
|
5944
|
+
return res;
|
|
5945
|
+
},
|
|
5946
|
+
};
|
|
5861
5947
|
}
|
|
5862
5948
|
|
|
5863
5949
|
function normalizeParams(params: Params): { [key: string]: any } {
|
package/src/types/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface Options {
|
|
|
11
11
|
env?: "staging" | "local" | "production";
|
|
12
12
|
headers?: { [key: string]: string };
|
|
13
13
|
timeout?: number | undefined;
|
|
14
|
+
retryAttempts?: number;
|
|
14
15
|
}
|
|
15
16
|
export interface Headers {
|
|
16
17
|
"api-key": string;
|
|
@@ -376,7 +377,29 @@ export type DocumentTypes =
|
|
|
376
377
|
| "activityAiSalesOrder"
|
|
377
378
|
| "ocrInvoiceJobGroup";
|
|
378
379
|
|
|
379
|
-
export type PrintTypes =
|
|
380
|
+
export type PrintTypes =
|
|
381
|
+
| "workorder"
|
|
382
|
+
| "form"
|
|
383
|
+
| "invoice"
|
|
384
|
+
| "proforma"
|
|
385
|
+
| "settlement";
|
|
386
|
+
|
|
387
|
+
export type InvoiceFontStyles =
|
|
388
|
+
| "InvoiceHeaderTitle"
|
|
389
|
+
| "InvoiceTaxNumber"
|
|
390
|
+
| "InvoiceType"
|
|
391
|
+
| "InvoiceInfo"
|
|
392
|
+
| "ItemsHeader"
|
|
393
|
+
| "ItemLabel"
|
|
394
|
+
| "ItemValue"
|
|
395
|
+
| "ItemVariant"
|
|
396
|
+
| "TotalItemsQty"
|
|
397
|
+
| "TotalAmount"
|
|
398
|
+
| "RepReciver"
|
|
399
|
+
| "Address"
|
|
400
|
+
| "PrintTime"
|
|
401
|
+
| "InvoiceHeader"
|
|
402
|
+
| "ClientBalance";
|
|
380
403
|
type Granularity =
|
|
381
404
|
| "Year"
|
|
382
405
|
| "Year Month"
|
|
@@ -19033,6 +19056,365 @@ export namespace Service {
|
|
|
19033
19056
|
}
|
|
19034
19057
|
}
|
|
19035
19058
|
}
|
|
19059
|
+
|
|
19060
|
+
export namespace PrintSetting {
|
|
19061
|
+
export type ImageSize = "original" | "small" | "medium" | "large" | "extra";
|
|
19062
|
+
export type QrCodeSize = "small" | "medium" | "large";
|
|
19063
|
+
export type Alignment = "right" | "left" | "center";
|
|
19064
|
+
|
|
19065
|
+
export interface InvoiceFontsWithSizes {
|
|
19066
|
+
style_name: InvoiceFontStyles;
|
|
19067
|
+
size: number;
|
|
19068
|
+
}
|
|
19069
|
+
|
|
19070
|
+
export interface ItemImage {
|
|
19071
|
+
view_item_image?: boolean;
|
|
19072
|
+
item_image_source?: "variant" | "product";
|
|
19073
|
+
item_image_size?: ImageSize;
|
|
19074
|
+
}
|
|
19075
|
+
|
|
19076
|
+
export interface User {
|
|
19077
|
+
_id: string;
|
|
19078
|
+
type: "admin" | "rep";
|
|
19079
|
+
name?: string;
|
|
19080
|
+
admin?: string;
|
|
19081
|
+
}
|
|
19082
|
+
|
|
19083
|
+
// Workorder Print Settings
|
|
19084
|
+
export interface WorkorderBasicDetails {
|
|
19085
|
+
creator?: boolean;
|
|
19086
|
+
workorder_categories?: boolean;
|
|
19087
|
+
client_name?: boolean;
|
|
19088
|
+
description?: boolean;
|
|
19089
|
+
local_name?: boolean;
|
|
19090
|
+
client_location?: boolean;
|
|
19091
|
+
assigned_to?: boolean;
|
|
19092
|
+
media?: boolean;
|
|
19093
|
+
cover_photo?: boolean;
|
|
19094
|
+
status?: boolean;
|
|
19095
|
+
assets?: boolean;
|
|
19096
|
+
asset_units?: boolean;
|
|
19097
|
+
priority_human?: boolean;
|
|
19098
|
+
due_date?: boolean;
|
|
19099
|
+
start_date?: boolean;
|
|
19100
|
+
forms?: boolean;
|
|
19101
|
+
comments?: boolean;
|
|
19102
|
+
createdAt?: boolean;
|
|
19103
|
+
}
|
|
19104
|
+
|
|
19105
|
+
export interface WorkorderClientDetails {
|
|
19106
|
+
withClientDetails?: boolean;
|
|
19107
|
+
basicClientDetails?: {
|
|
19108
|
+
client_code?: boolean;
|
|
19109
|
+
client_local_name?: boolean;
|
|
19110
|
+
client_tags?: boolean;
|
|
19111
|
+
area_tags?: boolean;
|
|
19112
|
+
client_channel?: boolean;
|
|
19113
|
+
is_chain?: boolean;
|
|
19114
|
+
teams?: boolean;
|
|
19115
|
+
product_groups?: boolean;
|
|
19116
|
+
contacts?: boolean;
|
|
19117
|
+
createdAt?: boolean;
|
|
19118
|
+
customFields?: boolean;
|
|
19119
|
+
};
|
|
19120
|
+
sales?: {
|
|
19121
|
+
price_list?: boolean;
|
|
19122
|
+
payment_type?: boolean;
|
|
19123
|
+
credit_limit?: boolean;
|
|
19124
|
+
payment_term?: boolean;
|
|
19125
|
+
};
|
|
19126
|
+
contact_info?: {
|
|
19127
|
+
contact_name?: boolean;
|
|
19128
|
+
client_info?: boolean;
|
|
19129
|
+
email?: boolean;
|
|
19130
|
+
website?: boolean;
|
|
19131
|
+
};
|
|
19132
|
+
}
|
|
19133
|
+
|
|
19134
|
+
export interface WorkorderAssetDetails {
|
|
19135
|
+
withAssetsDetails?: boolean;
|
|
19136
|
+
media?: boolean;
|
|
19137
|
+
local_name?: boolean;
|
|
19138
|
+
description?: boolean;
|
|
19139
|
+
asset_types?: boolean;
|
|
19140
|
+
location?: boolean;
|
|
19141
|
+
model?: boolean;
|
|
19142
|
+
manufacturer?: boolean;
|
|
19143
|
+
year?: boolean;
|
|
19144
|
+
barcode?: boolean;
|
|
19145
|
+
customFields?: boolean;
|
|
19146
|
+
createdAt?: boolean;
|
|
19147
|
+
cover_photo?: boolean;
|
|
19148
|
+
}
|
|
19149
|
+
|
|
19150
|
+
export interface WorkorderAssetUnitDetails {
|
|
19151
|
+
withAssetUnitsDetails?: boolean;
|
|
19152
|
+
media?: boolean;
|
|
19153
|
+
local_name?: boolean;
|
|
19154
|
+
description?: boolean;
|
|
19155
|
+
serial_number?: boolean;
|
|
19156
|
+
asset?: boolean;
|
|
19157
|
+
location?: boolean;
|
|
19158
|
+
customFields?: boolean;
|
|
19159
|
+
createdAt?: boolean;
|
|
19160
|
+
cover_photo?: boolean;
|
|
19161
|
+
}
|
|
19162
|
+
|
|
19163
|
+
export interface WorkorderDetails {
|
|
19164
|
+
document_type: "workorder";
|
|
19165
|
+
number_of_comments?: number;
|
|
19166
|
+
compressed_media_size?: ImageSize;
|
|
19167
|
+
basicDetails?: WorkorderBasicDetails;
|
|
19168
|
+
clientDetails?: WorkorderClientDetails;
|
|
19169
|
+
assetDetails?: WorkorderAssetDetails;
|
|
19170
|
+
assetUnitDetails?: WorkorderAssetUnitDetails;
|
|
19171
|
+
}
|
|
19172
|
+
|
|
19173
|
+
// Form Result Settings
|
|
19174
|
+
export interface FormResultDetails {
|
|
19175
|
+
document_type: "form";
|
|
19176
|
+
compressed_media_size?: ImageSize;
|
|
19177
|
+
}
|
|
19178
|
+
|
|
19179
|
+
// Invoice Print Settings
|
|
19180
|
+
export interface InvoiceBasicDetails {
|
|
19181
|
+
created_at?: boolean;
|
|
19182
|
+
created_by?: boolean;
|
|
19183
|
+
tax_number?: boolean;
|
|
19184
|
+
name_on_invoice?: boolean;
|
|
19185
|
+
client_code?: boolean;
|
|
19186
|
+
client_name?: boolean;
|
|
19187
|
+
client_local_name?: boolean;
|
|
19188
|
+
client_address?: boolean;
|
|
19189
|
+
client_phone?: boolean;
|
|
19190
|
+
client_tax_number?: boolean;
|
|
19191
|
+
client_cell_phone?: boolean;
|
|
19192
|
+
issue_date?: boolean;
|
|
19193
|
+
due_date?: boolean;
|
|
19194
|
+
invoice_status?: boolean;
|
|
19195
|
+
company_logo?: boolean;
|
|
19196
|
+
serial_number?: boolean;
|
|
19197
|
+
advanced_serial_number?: boolean;
|
|
19198
|
+
external_serial_number?: boolean;
|
|
19199
|
+
comment?: boolean;
|
|
19200
|
+
qr_code?: boolean;
|
|
19201
|
+
custom_status?: boolean;
|
|
19202
|
+
payments_data?: boolean;
|
|
19203
|
+
media?: boolean;
|
|
19204
|
+
address?: boolean;
|
|
19205
|
+
remaining_balance?: boolean;
|
|
19206
|
+
invoice_header?: string;
|
|
19207
|
+
invoice_notes?: string;
|
|
19208
|
+
client_balance?: boolean;
|
|
19209
|
+
origin_serial_number?: boolean;
|
|
19210
|
+
origin_advanced_serial_number?: boolean;
|
|
19211
|
+
workorder_serial_number?: boolean;
|
|
19212
|
+
workorder_name?: boolean;
|
|
19213
|
+
workorder_local_name?: boolean;
|
|
19214
|
+
total_items_base_unit_qty?: boolean;
|
|
19215
|
+
total_items_qty?: boolean;
|
|
19216
|
+
total_return_items_base_unit_qty?: boolean;
|
|
19217
|
+
total_return_items_qty?: boolean;
|
|
19218
|
+
}
|
|
19219
|
+
|
|
19220
|
+
export interface InvoiceLineItemDetails {
|
|
19221
|
+
sku?: boolean;
|
|
19222
|
+
barcode?: boolean;
|
|
19223
|
+
product_name?: boolean;
|
|
19224
|
+
variant_name?: boolean;
|
|
19225
|
+
measureunit?: boolean;
|
|
19226
|
+
qty?: boolean;
|
|
19227
|
+
price?: boolean;
|
|
19228
|
+
discount_amount?: boolean;
|
|
19229
|
+
line_total?: boolean;
|
|
19230
|
+
return_reason?: boolean;
|
|
19231
|
+
base_unit_qty?: boolean;
|
|
19232
|
+
original_price?: boolean;
|
|
19233
|
+
total_original_price?: boolean;
|
|
19234
|
+
item_image?: ItemImage;
|
|
19235
|
+
batch_number?: boolean;
|
|
19236
|
+
batch_expiry?: boolean;
|
|
19237
|
+
batch_qty?: boolean;
|
|
19238
|
+
}
|
|
19239
|
+
|
|
19240
|
+
export interface InvoiceMobileDetails {
|
|
19241
|
+
logo_height?: number | string;
|
|
19242
|
+
logo_width?: number | string;
|
|
19243
|
+
align_logo?: Alignment;
|
|
19244
|
+
align_invoice_header?: Alignment;
|
|
19245
|
+
font_styles?: InvoiceFontsWithSizes[];
|
|
19246
|
+
hide_invoice_payment_type?: boolean;
|
|
19247
|
+
invoice_header?: string;
|
|
19248
|
+
client_balance?: boolean;
|
|
19249
|
+
}
|
|
19250
|
+
|
|
19251
|
+
export interface InvoiceDetails {
|
|
19252
|
+
document_type: "invoice";
|
|
19253
|
+
compressed_media_size?: ImageSize;
|
|
19254
|
+
logo_size?: ImageSize;
|
|
19255
|
+
qr_code_size?: QrCodeSize;
|
|
19256
|
+
basicDetails?: InvoiceBasicDetails;
|
|
19257
|
+
lineItemDetails?: InvoiceLineItemDetails;
|
|
19258
|
+
mobileDetails?: InvoiceMobileDetails;
|
|
19259
|
+
}
|
|
19260
|
+
|
|
19261
|
+
// Proforma Print Settings
|
|
19262
|
+
export interface ProformaBasicDetails {
|
|
19263
|
+
created_at?: boolean;
|
|
19264
|
+
created_by?: boolean;
|
|
19265
|
+
tax_number?: boolean;
|
|
19266
|
+
name_on_invoice?: boolean;
|
|
19267
|
+
client_code?: boolean;
|
|
19268
|
+
client_name?: boolean;
|
|
19269
|
+
client_local_name?: boolean;
|
|
19270
|
+
client_address?: boolean;
|
|
19271
|
+
client_phone?: boolean;
|
|
19272
|
+
client_tax_number?: boolean;
|
|
19273
|
+
client_cell_phone?: boolean;
|
|
19274
|
+
issue_date?: boolean;
|
|
19275
|
+
order_status?: boolean;
|
|
19276
|
+
company_logo?: boolean;
|
|
19277
|
+
serial_number?: boolean;
|
|
19278
|
+
external_serial_number?: boolean;
|
|
19279
|
+
comment?: boolean;
|
|
19280
|
+
custom_status?: boolean;
|
|
19281
|
+
media?: boolean;
|
|
19282
|
+
address?: boolean;
|
|
19283
|
+
invoice_header?: string;
|
|
19284
|
+
invoice_notes?: string;
|
|
19285
|
+
total_items_base_unit_qty?: boolean;
|
|
19286
|
+
total_items_qty?: boolean;
|
|
19287
|
+
total_return_items_base_unit_qty?: boolean;
|
|
19288
|
+
total_return_items_qty?: boolean;
|
|
19289
|
+
}
|
|
19290
|
+
|
|
19291
|
+
export interface ProformaLineItemDetails {
|
|
19292
|
+
product_name?: boolean;
|
|
19293
|
+
variant_name?: boolean;
|
|
19294
|
+
sku?: boolean;
|
|
19295
|
+
barcode?: boolean;
|
|
19296
|
+
measureunit?: boolean;
|
|
19297
|
+
qty?: boolean;
|
|
19298
|
+
price?: boolean;
|
|
19299
|
+
line_total?: boolean;
|
|
19300
|
+
note?: boolean;
|
|
19301
|
+
base_unit_qty?: boolean;
|
|
19302
|
+
item_image?: ItemImage;
|
|
19303
|
+
return_reason?: boolean;
|
|
19304
|
+
original_price?: boolean;
|
|
19305
|
+
total_original_price?: boolean;
|
|
19306
|
+
batch_number?: boolean;
|
|
19307
|
+
batch_expiry?: boolean;
|
|
19308
|
+
batch_qty?: boolean;
|
|
19309
|
+
}
|
|
19310
|
+
|
|
19311
|
+
export interface ProformaMobileDetails {
|
|
19312
|
+
logo_height?: number | string;
|
|
19313
|
+
logo_width?: number | string;
|
|
19314
|
+
align_logo?: Alignment;
|
|
19315
|
+
font_styles?: InvoiceFontsWithSizes[];
|
|
19316
|
+
align_invoice_header?: Alignment;
|
|
19317
|
+
hide_invoice_payment_type?: boolean;
|
|
19318
|
+
invoice_header?: string;
|
|
19319
|
+
}
|
|
19320
|
+
|
|
19321
|
+
export interface ProformaDetails {
|
|
19322
|
+
document_type: "proforma";
|
|
19323
|
+
compressed_media_size?: ImageSize;
|
|
19324
|
+
logo_size?: ImageSize;
|
|
19325
|
+
basicDetails?: ProformaBasicDetails;
|
|
19326
|
+
lineItemDetails?: ProformaLineItemDetails;
|
|
19327
|
+
mobileDetails?: ProformaMobileDetails;
|
|
19328
|
+
}
|
|
19329
|
+
|
|
19330
|
+
// Settlement Print Settings
|
|
19331
|
+
export interface SettlementBasicDetails {
|
|
19332
|
+
creator?: boolean;
|
|
19333
|
+
settlement_date?: boolean;
|
|
19334
|
+
company_logo?: boolean;
|
|
19335
|
+
serial_number?: boolean;
|
|
19336
|
+
note?: boolean;
|
|
19337
|
+
amount?: boolean;
|
|
19338
|
+
payment_type?: boolean;
|
|
19339
|
+
checks?: boolean;
|
|
19340
|
+
rep?: boolean;
|
|
19341
|
+
totals?: boolean;
|
|
19342
|
+
media?: boolean;
|
|
19343
|
+
}
|
|
19344
|
+
|
|
19345
|
+
export interface SettlementCheckDetails {
|
|
19346
|
+
bank_name?: boolean;
|
|
19347
|
+
branch_name?: boolean;
|
|
19348
|
+
drawer_name?: boolean;
|
|
19349
|
+
client_name?: boolean;
|
|
19350
|
+
check_number?: boolean;
|
|
19351
|
+
pay_time?: boolean;
|
|
19352
|
+
rep_name?: boolean;
|
|
19353
|
+
check_date?: boolean;
|
|
19354
|
+
}
|
|
19355
|
+
|
|
19356
|
+
export interface SettlementDetails {
|
|
19357
|
+
document_type: "settlement";
|
|
19358
|
+
compressed_media_size?: ImageSize;
|
|
19359
|
+
basicDetails?: SettlementBasicDetails;
|
|
19360
|
+
checkDetails?: SettlementCheckDetails;
|
|
19361
|
+
}
|
|
19362
|
+
|
|
19363
|
+
// Union type for all details
|
|
19364
|
+
export type Details =
|
|
19365
|
+
| WorkorderDetails
|
|
19366
|
+
| FormResultDetails
|
|
19367
|
+
| InvoiceDetails
|
|
19368
|
+
| ProformaDetails
|
|
19369
|
+
| SettlementDetails;
|
|
19370
|
+
|
|
19371
|
+
// Main PrintSetting Schema
|
|
19372
|
+
export interface Data {
|
|
19373
|
+
_id: string;
|
|
19374
|
+
creator: User;
|
|
19375
|
+
editor?: User;
|
|
19376
|
+
document_type: PrintTypes;
|
|
19377
|
+
details: Details;
|
|
19378
|
+
company_namespace: string[];
|
|
19379
|
+
createdAt: Date;
|
|
19380
|
+
updatedAt: Date;
|
|
19381
|
+
__v?: number;
|
|
19382
|
+
}
|
|
19383
|
+
|
|
19384
|
+
export interface CreateBody {
|
|
19385
|
+
document_type: PrintTypes;
|
|
19386
|
+
details: Details;
|
|
19387
|
+
}
|
|
19388
|
+
|
|
19389
|
+
export interface UpdateBody {
|
|
19390
|
+
details?: Partial<Details>;
|
|
19391
|
+
}
|
|
19392
|
+
|
|
19393
|
+
export namespace Find {
|
|
19394
|
+
export type Params = DefaultPaginationQueryParams & {
|
|
19395
|
+
document_type?: PrintTypes | PrintTypes[];
|
|
19396
|
+
};
|
|
19397
|
+
export interface Result extends DefaultPaginationResult {
|
|
19398
|
+
data: Data[];
|
|
19399
|
+
}
|
|
19400
|
+
}
|
|
19401
|
+
|
|
19402
|
+
export namespace Get {
|
|
19403
|
+
export type ID = string;
|
|
19404
|
+
export type Result = Data;
|
|
19405
|
+
}
|
|
19406
|
+
|
|
19407
|
+
export namespace Create {
|
|
19408
|
+
export type Body = CreateBody;
|
|
19409
|
+
export type Result = Data;
|
|
19410
|
+
}
|
|
19411
|
+
|
|
19412
|
+
export namespace Update {
|
|
19413
|
+
export type ID = string;
|
|
19414
|
+
export type Body = UpdateBody;
|
|
19415
|
+
export type Result = Data;
|
|
19416
|
+
}
|
|
19417
|
+
}
|
|
19036
19418
|
}
|
|
19037
19419
|
|
|
19038
19420
|
export type StringId = string;
|