vsdc-zra-sdk 1.0.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 +195 -0
- package/dist/client.d.ts +51 -0
- package/dist/client.js +232 -0
- package/dist/constants.d.ts +64 -0
- package/dist/constants.js +79 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/schemas.d.ts +1194 -0
- package/dist/schemas.js +311 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# VSDC SDK
|
|
2
|
+
|
|
3
|
+
A plug-and-play TypeScript/Node.js SDK for the Zambia Revenue Authority (ZRA) Smart Invoice VSDC integration.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Typed Interfaces**: Full TypeScript support for all requests and responses.
|
|
8
|
+
- **Validation**: Runtime validation using Zod ensures you send correct data.
|
|
9
|
+
- **Constants**: Pre-defined enums for Tax Types, Product Types, Units, etc.
|
|
10
|
+
- **Helpers**: Automatic tax total calculation for sales.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install vsdc-zra
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### 1. Configuration
|
|
21
|
+
|
|
22
|
+
Initialize the client with your VSDC settings.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { VSDCClient } from "vsdc-zra";
|
|
26
|
+
|
|
27
|
+
const client = new VSDCClient({
|
|
28
|
+
baseUrl: "http://localhost:8080", // URL of your local VSDC
|
|
29
|
+
tpin: "1000000000",
|
|
30
|
+
bhfId: "000",
|
|
31
|
+
deviceSerialNo: "DVC12345678", // Optional, needed for initialization
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Device Initialization
|
|
36
|
+
|
|
37
|
+
Run this once when setting up the VSDC.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
try {
|
|
41
|
+
const result = await client.initializeDevice();
|
|
42
|
+
console.log("Device Initialized:", result);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error("Initialization failed:", error);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Register an Item
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { ProductType, PackagingUnit, QuantityUnit, TaxType } from "vsdc-zra";
|
|
52
|
+
|
|
53
|
+
const newItem = {
|
|
54
|
+
itemCd: "ITM001",
|
|
55
|
+
itemClsCd: "5059690800", // ZRA Item Class Code
|
|
56
|
+
itemTyCd: ProductType.FinishedProduct,
|
|
57
|
+
itemNm: "Sample Widget",
|
|
58
|
+
pkgUnitCd: PackagingUnit.Net,
|
|
59
|
+
qtyUnitCd: QuantityUnit.Piece,
|
|
60
|
+
taxTyCd: TaxType.StandardRated,
|
|
61
|
+
dftPrc: 100.00,
|
|
62
|
+
regrNm: "Admin",
|
|
63
|
+
regrId: "admin",
|
|
64
|
+
modrNm: "Admin",
|
|
65
|
+
modrId: "admin",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const response = await client.saveItem(newItem);
|
|
69
|
+
console.log("Item Saved:", response);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. Submit a Sale (Invoice)
|
|
73
|
+
|
|
74
|
+
The SDK automatically calculates tax totals if you use the simplified interface.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { TransactionType, ReceiptType, PaymentMethod, TaxType } from "vsdc-zra";
|
|
78
|
+
|
|
79
|
+
const sale = {
|
|
80
|
+
invcNo: 1001,
|
|
81
|
+
salesTyCd: TransactionType.Normal,
|
|
82
|
+
rcptTyCd: ReceiptType.Sale,
|
|
83
|
+
pmtTyCd: PaymentMethod.Cash,
|
|
84
|
+
salesSttsCd: "02", // Approved
|
|
85
|
+
cfmDt: "20231222100000",
|
|
86
|
+
salesDt: "20231222",
|
|
87
|
+
regrNm: "Cashier",
|
|
88
|
+
regrId: "CSH01",
|
|
89
|
+
modrNm: "Cashier",
|
|
90
|
+
modrId: "CSH01",
|
|
91
|
+
// List of items in the cart
|
|
92
|
+
items: [
|
|
93
|
+
{
|
|
94
|
+
itemSeq: 1,
|
|
95
|
+
itemCd: "ITM001",
|
|
96
|
+
itemClsCd: "5059690800",
|
|
97
|
+
itemNm: "Sample Widget",
|
|
98
|
+
pkgUnitCd: "NT",
|
|
99
|
+
pkg: 1,
|
|
100
|
+
qtyUnitCd: "U",
|
|
101
|
+
qty: 2,
|
|
102
|
+
prc: 100.00,
|
|
103
|
+
splyAmt: 200.00,
|
|
104
|
+
taxTyCd: TaxType.StandardRated, // 'A' (16%)
|
|
105
|
+
taxblAmt: 200.00,
|
|
106
|
+
taxAmt: 32.00,
|
|
107
|
+
totAmt: 232.00,
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// The SDK will calculate totTaxblAmt, totTaxAmt, totAmt, and breakdown by tax type
|
|
113
|
+
const invoiceResponse = await client.saveSales(sale);
|
|
114
|
+
console.log("Invoice Submitted:", invoiceResponse);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Managing Stock
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { StockIOSaveReq } from "vsdc-zra";
|
|
121
|
+
|
|
122
|
+
// Adjust stock (In/Out)
|
|
123
|
+
const stockAdjustment = {
|
|
124
|
+
sarNo: 2023001,
|
|
125
|
+
regTyCd: "M",
|
|
126
|
+
sarTyCd: "11", // Stock In
|
|
127
|
+
ocrnDt: "20231201",
|
|
128
|
+
totItemCnt: 1,
|
|
129
|
+
totTaxblAmt: 1000,
|
|
130
|
+
totTaxAmt: 160,
|
|
131
|
+
totAmt: 1160,
|
|
132
|
+
regrNm: "Admin",
|
|
133
|
+
regrId: "admin",
|
|
134
|
+
modrNm: "Admin",
|
|
135
|
+
modrId: "admin",
|
|
136
|
+
itemList: [
|
|
137
|
+
{
|
|
138
|
+
itemSeq: 1,
|
|
139
|
+
itemCd: "ITM001",
|
|
140
|
+
itemClsCd: "5059690800",
|
|
141
|
+
itemNm: "Widget",
|
|
142
|
+
pkgUnitCd: "NT",
|
|
143
|
+
pkg: 10,
|
|
144
|
+
qtyUnitCd: "U",
|
|
145
|
+
qty: 10,
|
|
146
|
+
prc: 100,
|
|
147
|
+
splyAmt: 1000,
|
|
148
|
+
taxblAmt: 1000,
|
|
149
|
+
taxTyCd: "A",
|
|
150
|
+
taxAmt: 160,
|
|
151
|
+
totAmt: 1160
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
await client.saveStockIO(stockAdjustment);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 6. Purchases
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const purchase = {
|
|
163
|
+
invcNo: 500,
|
|
164
|
+
pchsDt: "20231201",
|
|
165
|
+
totItemCnt: 1,
|
|
166
|
+
totTaxblAmt: 500,
|
|
167
|
+
totTaxAmt: 80,
|
|
168
|
+
totAmt: 580,
|
|
169
|
+
// ... other required fields mapping to TrnsPurchaseSaveReq
|
|
170
|
+
itemList: []
|
|
171
|
+
};
|
|
172
|
+
await client.savePurchase(purchase);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 7. Other Modules
|
|
176
|
+
|
|
177
|
+
The SDK supports all 8 VSDC modules:
|
|
178
|
+
- **Notices**: `getNotices()`
|
|
179
|
+
- **Branches**: `getBranches()`, `saveBranchCustomer()`, `saveBranchUser()`
|
|
180
|
+
- **Imports**: `getImportItems()`, `updateImportItem()`
|
|
181
|
+
- **Code Data**: `getCodes()`, `getItemClassifications()`
|
|
182
|
+
|
|
183
|
+
## Constants
|
|
184
|
+
|
|
185
|
+
The SDK exports enums for common VSDC codes:
|
|
186
|
+
|
|
187
|
+
- `TaxType`: StandardRated (A), Exempt (D), etc.
|
|
188
|
+
- `ProductType`: RawMaterial, FinishedProduct, Service.
|
|
189
|
+
- `PackagingUnit`: Net, Box, Bottle, etc.
|
|
190
|
+
- `QuantityUnit`: Piece, Kg, Litre.
|
|
191
|
+
- `PaymentMethod`: Cash, Card, MobileMoney.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ItemSaveReq, TrnsSalesSaveWrReq, SalesItem, BhfCustSaveReq, BhfUserSaveReq, ImptItemSaveReq, TrnsPurchaseSaveReq, StockIOSaveReq, StockMstSaveReq } from "./schemas";
|
|
2
|
+
export interface VSDCConfig {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
tpin: string;
|
|
5
|
+
bhfId: string;
|
|
6
|
+
deviceSerialNo?: string;
|
|
7
|
+
cmcKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class VSDCClient {
|
|
10
|
+
private client;
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: VSDCConfig);
|
|
13
|
+
private get basePayload();
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the device (Run this once per installation)
|
|
16
|
+
*/
|
|
17
|
+
initializeDevice(dvcSrlNo?: string): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Get Standard Codes (Units, Tax Types, etc.)
|
|
20
|
+
*/
|
|
21
|
+
getCodes(lastReqDt?: string): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Get Item Classifications (UNSPSC or ZRA specific)
|
|
24
|
+
*/
|
|
25
|
+
getItemClassifications(lastReqDt?: string): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Save (Register) an Item
|
|
28
|
+
*/
|
|
29
|
+
saveItem(item: Omit<ItemSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Submit a Sales Transaction (Invoice)
|
|
32
|
+
* This method automatically calculates totals if you provide a simplified input,
|
|
33
|
+
* or you can pass the full payload.
|
|
34
|
+
*/
|
|
35
|
+
saveSales(salesData: Omit<TrnsSalesSaveWrReq, "tpin" | "bhfId" | "totItemCnt" | "totTaxblAmt" | "totTaxAmt" | "totAmt" | "taxblAmtA" | "taxblAmtB" | "taxblAmtC1" | "taxblAmtC2" | "taxblAmtC3" | "taxblAmtD" | "taxAmtA" | "taxAmtB" | "taxAmtC1" | "taxAmtC2" | "taxAmtC3" | "taxAmtD"> & {
|
|
36
|
+
items: SalesItem[];
|
|
37
|
+
}): Promise<any>;
|
|
38
|
+
getNotices(lastReqDt?: string): Promise<any>;
|
|
39
|
+
getCustomers(custmTin?: string): Promise<any>;
|
|
40
|
+
getBranches(lastReqDt?: string): Promise<any>;
|
|
41
|
+
saveBranchCustomer(customer: Omit<BhfCustSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
42
|
+
saveBranchUser(user: Omit<BhfUserSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
43
|
+
getImportItems(lastReqDt?: string): Promise<any>;
|
|
44
|
+
updateImportItem(item: Omit<ImptItemSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
45
|
+
getPurchases(lastReqDt?: string): Promise<any>;
|
|
46
|
+
savePurchase(purchase: Omit<TrnsPurchaseSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
47
|
+
getStockItems(lastReqDt?: string): Promise<any>;
|
|
48
|
+
saveStockIO(stockIO: Omit<StockIOSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
49
|
+
saveStockMaster(stockMaster: Omit<StockMstSaveReq, "tpin" | "bhfId">): Promise<any>;
|
|
50
|
+
private calculateTotals;
|
|
51
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VSDCClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const schemas_1 = require("./schemas");
|
|
9
|
+
class VSDCClient {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.client = axios_1.default.create({
|
|
13
|
+
baseURL: config.baseUrl,
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
// header-based auth if needed in future
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
get basePayload() {
|
|
21
|
+
return {
|
|
22
|
+
tpin: this.config.tpin,
|
|
23
|
+
bhfId: this.config.bhfId,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initialize the device (Run this once per installation)
|
|
28
|
+
*/
|
|
29
|
+
async initializeDevice(dvcSrlNo) {
|
|
30
|
+
const payload = schemas_1.InitInfoReqSchema.parse({
|
|
31
|
+
...this.basePayload,
|
|
32
|
+
dvcSrlNo: dvcSrlNo || this.config.deviceSerialNo,
|
|
33
|
+
});
|
|
34
|
+
const response = await this.client.post("/initializer/selectInitInfo", payload);
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get Standard Codes (Units, Tax Types, etc.)
|
|
39
|
+
*/
|
|
40
|
+
async getCodes(lastReqDt = "20160101000000") {
|
|
41
|
+
const payload = {
|
|
42
|
+
...this.basePayload,
|
|
43
|
+
lastReqDt,
|
|
44
|
+
};
|
|
45
|
+
// Using z.parse would be good but omitting schema import for brevity in this replace call
|
|
46
|
+
// as strict typing isn't as critical for GET params compared to POST body validity.
|
|
47
|
+
const response = await this.client.post("/code/selectCodes", payload);
|
|
48
|
+
return response.data;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get Item Classifications (UNSPSC or ZRA specific)
|
|
52
|
+
*/
|
|
53
|
+
async getItemClassifications(lastReqDt = "20160101000000") {
|
|
54
|
+
const payload = {
|
|
55
|
+
...this.basePayload,
|
|
56
|
+
lastReqDt,
|
|
57
|
+
};
|
|
58
|
+
const response = await this.client.post("/itemClass/selectItemsClass", payload);
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Save (Register) an Item
|
|
63
|
+
*/
|
|
64
|
+
async saveItem(item) {
|
|
65
|
+
const payload = schemas_1.ItemSaveReqSchema.parse({
|
|
66
|
+
...this.basePayload,
|
|
67
|
+
...item,
|
|
68
|
+
});
|
|
69
|
+
const response = await this.client.post("/items/saveItems", payload);
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Submit a Sales Transaction (Invoice)
|
|
74
|
+
* This method automatically calculates totals if you provide a simplified input,
|
|
75
|
+
* or you can pass the full payload.
|
|
76
|
+
*/
|
|
77
|
+
async saveSales(salesData) {
|
|
78
|
+
// Auto-calculate totals
|
|
79
|
+
const totals = this.calculateTotals(salesData.items);
|
|
80
|
+
const fullPayload = {
|
|
81
|
+
...this.basePayload,
|
|
82
|
+
...salesData,
|
|
83
|
+
...totals,
|
|
84
|
+
};
|
|
85
|
+
const payload = schemas_1.TrnsSalesSaveWrReqSchema.parse(fullPayload);
|
|
86
|
+
const response = await this.client.post("/trnsSales/saveSales", payload);
|
|
87
|
+
return response.data;
|
|
88
|
+
}
|
|
89
|
+
// --- Notices ---
|
|
90
|
+
async getNotices(lastReqDt = "20160101000000") {
|
|
91
|
+
const payload = schemas_1.NoticeReqSchema.parse({
|
|
92
|
+
...this.basePayload,
|
|
93
|
+
lastReqDt,
|
|
94
|
+
});
|
|
95
|
+
const response = await this.client.post("/notices/selectNotices", payload);
|
|
96
|
+
return response.data;
|
|
97
|
+
}
|
|
98
|
+
// --- Branch & Customers ---
|
|
99
|
+
async getCustomers(custmTin) {
|
|
100
|
+
const payload = schemas_1.CustReqSchema.parse({
|
|
101
|
+
...this.basePayload,
|
|
102
|
+
custmTin: custmTin || undefined,
|
|
103
|
+
});
|
|
104
|
+
const response = await this.client.post("/customers/selectCustomer", payload);
|
|
105
|
+
return response.data;
|
|
106
|
+
}
|
|
107
|
+
async getBranches(lastReqDt = "20160101000000") {
|
|
108
|
+
const payload = schemas_1.BhfReqSchema.parse({
|
|
109
|
+
...this.basePayload,
|
|
110
|
+
lastReqDt,
|
|
111
|
+
});
|
|
112
|
+
const response = await this.client.post("/branches/selectBranches", payload);
|
|
113
|
+
return response.data;
|
|
114
|
+
}
|
|
115
|
+
async saveBranchCustomer(customer) {
|
|
116
|
+
const payload = schemas_1.BhfCustSaveReqSchema.parse({
|
|
117
|
+
...this.basePayload,
|
|
118
|
+
...customer,
|
|
119
|
+
});
|
|
120
|
+
const response = await this.client.post("/branches/saveBrancheCustomers", payload);
|
|
121
|
+
return response.data;
|
|
122
|
+
}
|
|
123
|
+
async saveBranchUser(user) {
|
|
124
|
+
const payload = schemas_1.BhfUserSaveReqSchema.parse({
|
|
125
|
+
...this.basePayload,
|
|
126
|
+
...user,
|
|
127
|
+
});
|
|
128
|
+
const response = await this.client.post("/branches/saveBrancheUsers", payload);
|
|
129
|
+
return response.data;
|
|
130
|
+
}
|
|
131
|
+
// --- Imports ---
|
|
132
|
+
async getImportItems(lastReqDt = "20160101000000") {
|
|
133
|
+
const payload = schemas_1.ImptItemReqSchema.parse({
|
|
134
|
+
...this.basePayload,
|
|
135
|
+
lastReqDt,
|
|
136
|
+
});
|
|
137
|
+
const response = await this.client.post("/imports/selectImportItems", payload);
|
|
138
|
+
return response.data;
|
|
139
|
+
}
|
|
140
|
+
async updateImportItem(item) {
|
|
141
|
+
const payload = schemas_1.ImptItemSaveReqSchema.parse({
|
|
142
|
+
...this.basePayload,
|
|
143
|
+
...item,
|
|
144
|
+
});
|
|
145
|
+
const response = await this.client.post("/imports/updateImportItems", payload);
|
|
146
|
+
return response.data;
|
|
147
|
+
}
|
|
148
|
+
// --- Purchases ---
|
|
149
|
+
async getPurchases(lastReqDt = "20160101000000") {
|
|
150
|
+
const payload = schemas_1.TrnsPurchaseSalesReqSchema.parse({
|
|
151
|
+
...this.basePayload,
|
|
152
|
+
lastReqDt,
|
|
153
|
+
});
|
|
154
|
+
const response = await this.client.post("/trnsPurchase/selectTrnsPurchaseSales", payload);
|
|
155
|
+
return response.data;
|
|
156
|
+
}
|
|
157
|
+
async savePurchase(purchase) {
|
|
158
|
+
const payload = schemas_1.TrnsPurchaseSaveReqSchema.parse({
|
|
159
|
+
...this.basePayload,
|
|
160
|
+
...purchase
|
|
161
|
+
});
|
|
162
|
+
const response = await this.client.post("/trnsPurchase/savePurchases", payload);
|
|
163
|
+
return response.data;
|
|
164
|
+
}
|
|
165
|
+
// --- Stock ---
|
|
166
|
+
async getStockItems(lastReqDt = "20160101000000") {
|
|
167
|
+
const payload = schemas_1.StockMoveReqSchema.parse({
|
|
168
|
+
...this.basePayload,
|
|
169
|
+
lastReqDt,
|
|
170
|
+
});
|
|
171
|
+
const response = await this.client.post("/stock/selectStockItems", payload);
|
|
172
|
+
return response.data;
|
|
173
|
+
}
|
|
174
|
+
async saveStockIO(stockIO) {
|
|
175
|
+
const payload = schemas_1.StockIOSaveReqSchema.parse({
|
|
176
|
+
...this.basePayload,
|
|
177
|
+
...stockIO
|
|
178
|
+
});
|
|
179
|
+
const response = await this.client.post("/stock/saveStockItems", payload);
|
|
180
|
+
return response.data;
|
|
181
|
+
}
|
|
182
|
+
async saveStockMaster(stockMaster) {
|
|
183
|
+
const payload = schemas_1.StockMstSaveReqSchema.parse({
|
|
184
|
+
...this.basePayload,
|
|
185
|
+
...stockMaster
|
|
186
|
+
});
|
|
187
|
+
const response = await this.client.post("/stockMaster/saveStockMaster", payload);
|
|
188
|
+
return response.data;
|
|
189
|
+
}
|
|
190
|
+
calculateTotals(items) {
|
|
191
|
+
let totTaxblAmt = 0;
|
|
192
|
+
let totTaxAmt = 0;
|
|
193
|
+
let totAmt = 0;
|
|
194
|
+
const taxes = {
|
|
195
|
+
A: { taxable: 0, tax: 0 },
|
|
196
|
+
B: { taxable: 0, tax: 0 },
|
|
197
|
+
C1: { taxable: 0, tax: 0 },
|
|
198
|
+
C2: { taxable: 0, tax: 0 },
|
|
199
|
+
C3: { taxable: 0, tax: 0 },
|
|
200
|
+
D: { taxable: 0, tax: 0 },
|
|
201
|
+
};
|
|
202
|
+
for (const item of items) {
|
|
203
|
+
totTaxblAmt += item.taxblAmt;
|
|
204
|
+
totTaxAmt += item.taxAmt;
|
|
205
|
+
totAmt += item.totAmt;
|
|
206
|
+
const type = item.taxTyCd;
|
|
207
|
+
if (taxes[type]) {
|
|
208
|
+
taxes[type].taxable += item.taxblAmt;
|
|
209
|
+
taxes[type].tax += item.taxAmt;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
totItemCnt: items.length,
|
|
214
|
+
totTaxblAmt,
|
|
215
|
+
totTaxAmt,
|
|
216
|
+
totAmt,
|
|
217
|
+
taxblAmtA: taxes.A.taxable,
|
|
218
|
+
taxAmtA: taxes.A.tax,
|
|
219
|
+
taxblAmtB: taxes.B.taxable,
|
|
220
|
+
taxAmtB: taxes.B.tax,
|
|
221
|
+
taxblAmtC1: taxes.C1.taxable,
|
|
222
|
+
taxAmtC1: taxes.C1.tax,
|
|
223
|
+
taxblAmtC2: taxes.C2.taxable,
|
|
224
|
+
taxAmtC2: taxes.C2.tax,
|
|
225
|
+
taxblAmtC3: taxes.C3.taxable,
|
|
226
|
+
taxAmtC3: taxes.C3.tax,
|
|
227
|
+
taxblAmtD: taxes.D.taxable,
|
|
228
|
+
taxAmtD: taxes.D.tax,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.VSDCClient = VSDCClient;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare enum TaxType {
|
|
2
|
+
StandardRated = "A",// 16%
|
|
3
|
+
MinimumTaxableValue = "B",// 16% on Retail Price
|
|
4
|
+
Exports = "C1",// 0%
|
|
5
|
+
ZeroRatedLocal = "C2",// 0%
|
|
6
|
+
ZeroRatedNature = "C3",// 0%
|
|
7
|
+
Exempt = "D",// No tax
|
|
8
|
+
TurnoverTax = "TOT"
|
|
9
|
+
}
|
|
10
|
+
export declare enum TaxpayerStatus {
|
|
11
|
+
Active = "A",
|
|
12
|
+
Deregistered = "D"
|
|
13
|
+
}
|
|
14
|
+
export declare enum ProductType {
|
|
15
|
+
RawMaterial = "1",
|
|
16
|
+
FinishedProduct = "2",
|
|
17
|
+
Service = "3"
|
|
18
|
+
}
|
|
19
|
+
export declare enum PackagingUnit {
|
|
20
|
+
Net = "NT",
|
|
21
|
+
Bag = "BG",
|
|
22
|
+
Barrel = "BA",
|
|
23
|
+
Bottle = "BO",// This wasn't in the snippet but implies Bottle
|
|
24
|
+
Box = "BX",
|
|
25
|
+
Can = "CA",
|
|
26
|
+
Carton = "CT",
|
|
27
|
+
Container = "CTN",
|
|
28
|
+
Dozen = "DZ",
|
|
29
|
+
Gram = "GRM",
|
|
30
|
+
Kilogram = "KG",
|
|
31
|
+
Litre = "LTR",
|
|
32
|
+
Meter = "MTR",
|
|
33
|
+
Number = "NO",
|
|
34
|
+
Piece = "U",// Checking mapping
|
|
35
|
+
Set = "SET"
|
|
36
|
+
}
|
|
37
|
+
export declare enum QuantityUnit {
|
|
38
|
+
Piece = "U",
|
|
39
|
+
Kilogram = "KG",
|
|
40
|
+
Litre = "L"
|
|
41
|
+
}
|
|
42
|
+
export declare enum TransactionProgress {
|
|
43
|
+
Wait = "01",
|
|
44
|
+
Approved = "02"
|
|
45
|
+
}
|
|
46
|
+
export declare enum TransactionType {
|
|
47
|
+
Normal = "N",
|
|
48
|
+
Copy = "C",
|
|
49
|
+
Proforma = "P",
|
|
50
|
+
Training = "T"
|
|
51
|
+
}
|
|
52
|
+
export declare enum ReceiptType {
|
|
53
|
+
Sale = "S",
|
|
54
|
+
Return = "R"
|
|
55
|
+
}
|
|
56
|
+
export declare enum PaymentMethod {
|
|
57
|
+
Cash = "01",
|
|
58
|
+
Cheque = "02",
|
|
59
|
+
Card = "03",
|
|
60
|
+
MobileMoney = "04",
|
|
61
|
+
BankTransfer = "05",
|
|
62
|
+
Credit = "06",
|
|
63
|
+
Other = "07"
|
|
64
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentMethod = exports.ReceiptType = exports.TransactionType = exports.TransactionProgress = exports.QuantityUnit = exports.PackagingUnit = exports.ProductType = exports.TaxpayerStatus = exports.TaxType = void 0;
|
|
4
|
+
var TaxType;
|
|
5
|
+
(function (TaxType) {
|
|
6
|
+
TaxType["StandardRated"] = "A";
|
|
7
|
+
TaxType["MinimumTaxableValue"] = "B";
|
|
8
|
+
TaxType["Exports"] = "C1";
|
|
9
|
+
TaxType["ZeroRatedLocal"] = "C2";
|
|
10
|
+
TaxType["ZeroRatedNature"] = "C3";
|
|
11
|
+
TaxType["Exempt"] = "D";
|
|
12
|
+
TaxType["TurnoverTax"] = "TOT";
|
|
13
|
+
})(TaxType || (exports.TaxType = TaxType = {}));
|
|
14
|
+
var TaxpayerStatus;
|
|
15
|
+
(function (TaxpayerStatus) {
|
|
16
|
+
TaxpayerStatus["Active"] = "A";
|
|
17
|
+
TaxpayerStatus["Deregistered"] = "D";
|
|
18
|
+
})(TaxpayerStatus || (exports.TaxpayerStatus = TaxpayerStatus = {}));
|
|
19
|
+
var ProductType;
|
|
20
|
+
(function (ProductType) {
|
|
21
|
+
ProductType["RawMaterial"] = "1";
|
|
22
|
+
ProductType["FinishedProduct"] = "2";
|
|
23
|
+
ProductType["Service"] = "3";
|
|
24
|
+
})(ProductType || (exports.ProductType = ProductType = {}));
|
|
25
|
+
var PackagingUnit;
|
|
26
|
+
(function (PackagingUnit) {
|
|
27
|
+
PackagingUnit["Net"] = "NT";
|
|
28
|
+
PackagingUnit["Bag"] = "BG";
|
|
29
|
+
PackagingUnit["Barrel"] = "BA";
|
|
30
|
+
PackagingUnit["Bottle"] = "BO";
|
|
31
|
+
PackagingUnit["Box"] = "BX";
|
|
32
|
+
PackagingUnit["Can"] = "CA";
|
|
33
|
+
PackagingUnit["Carton"] = "CT";
|
|
34
|
+
PackagingUnit["Container"] = "CTN";
|
|
35
|
+
PackagingUnit["Dozen"] = "DZ";
|
|
36
|
+
PackagingUnit["Gram"] = "GRM";
|
|
37
|
+
PackagingUnit["Kilogram"] = "KG";
|
|
38
|
+
PackagingUnit["Litre"] = "LTR";
|
|
39
|
+
PackagingUnit["Meter"] = "MTR";
|
|
40
|
+
PackagingUnit["Number"] = "NO";
|
|
41
|
+
PackagingUnit["Piece"] = "U";
|
|
42
|
+
PackagingUnit["Set"] = "SET";
|
|
43
|
+
// Add more as needed
|
|
44
|
+
})(PackagingUnit || (exports.PackagingUnit = PackagingUnit = {}));
|
|
45
|
+
var QuantityUnit;
|
|
46
|
+
(function (QuantityUnit) {
|
|
47
|
+
QuantityUnit["Piece"] = "U";
|
|
48
|
+
QuantityUnit["Kilogram"] = "KG";
|
|
49
|
+
QuantityUnit["Litre"] = "L";
|
|
50
|
+
// Add more as needed
|
|
51
|
+
})(QuantityUnit || (exports.QuantityUnit = QuantityUnit = {}));
|
|
52
|
+
var TransactionProgress;
|
|
53
|
+
(function (TransactionProgress) {
|
|
54
|
+
TransactionProgress["Wait"] = "01";
|
|
55
|
+
TransactionProgress["Approved"] = "02";
|
|
56
|
+
// Others from section 4.11
|
|
57
|
+
})(TransactionProgress || (exports.TransactionProgress = TransactionProgress = {}));
|
|
58
|
+
var TransactionType;
|
|
59
|
+
(function (TransactionType) {
|
|
60
|
+
TransactionType["Normal"] = "N";
|
|
61
|
+
TransactionType["Copy"] = "C";
|
|
62
|
+
TransactionType["Proforma"] = "P";
|
|
63
|
+
TransactionType["Training"] = "T";
|
|
64
|
+
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
65
|
+
var ReceiptType;
|
|
66
|
+
(function (ReceiptType) {
|
|
67
|
+
ReceiptType["Sale"] = "S";
|
|
68
|
+
ReceiptType["Return"] = "R";
|
|
69
|
+
})(ReceiptType || (exports.ReceiptType = ReceiptType = {}));
|
|
70
|
+
var PaymentMethod;
|
|
71
|
+
(function (PaymentMethod) {
|
|
72
|
+
PaymentMethod["Cash"] = "01";
|
|
73
|
+
PaymentMethod["Cheque"] = "02";
|
|
74
|
+
PaymentMethod["Card"] = "03";
|
|
75
|
+
PaymentMethod["MobileMoney"] = "04";
|
|
76
|
+
PaymentMethod["BankTransfer"] = "05";
|
|
77
|
+
PaymentMethod["Credit"] = "06";
|
|
78
|
+
PaymentMethod["Other"] = "07";
|
|
79
|
+
})(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
__exportStar(require("./schemas"), exports);
|