timber-node 0.0.1
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 +0 -0
- package/dist/billPayment.d.ts +115 -0
- package/dist/billPayment.js +144 -0
- package/dist/customer.d.ts +93 -0
- package/dist/customer.js +82 -0
- package/dist/employee.d.ts +120 -0
- package/dist/employee.js +99 -0
- package/dist/expense.d.ts +116 -0
- package/dist/expense.js +105 -0
- package/dist/expenseCategory.d.ts +95 -0
- package/dist/expenseCategory.js +87 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +50 -0
- package/dist/invoice.d.ts +109 -0
- package/dist/invoice.js +100 -0
- package/dist/invoicePayment.d.ts +119 -0
- package/dist/invoicePayment.js +113 -0
- package/dist/rawExpense.d.ts +87 -0
- package/dist/rawExpense.js +76 -0
- package/dist/salary.d.ts +121 -0
- package/dist/salary.js +101 -0
- package/dist/taxRate.d.ts +36 -0
- package/dist/taxRate.js +26 -0
- package/dist/vendorPayment.d.ts +195 -0
- package/dist/vendorPayment.js +236 -0
- package/package.json +46 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from "axios";
|
|
2
|
+
export interface CreateVendorPaymentRequest {
|
|
3
|
+
title: string;
|
|
4
|
+
customer: {
|
|
5
|
+
customer_id?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
email: string;
|
|
8
|
+
trn: string;
|
|
9
|
+
country_code: string;
|
|
10
|
+
mobile: string;
|
|
11
|
+
address: string;
|
|
12
|
+
};
|
|
13
|
+
biller: {
|
|
14
|
+
biller_id?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
email: string;
|
|
17
|
+
trn: string;
|
|
18
|
+
country_code: string;
|
|
19
|
+
mobile: string;
|
|
20
|
+
address: string;
|
|
21
|
+
};
|
|
22
|
+
invoice_number: string;
|
|
23
|
+
order_number: string;
|
|
24
|
+
invoice_date: string;
|
|
25
|
+
due_date: string;
|
|
26
|
+
currency: string;
|
|
27
|
+
items: [
|
|
28
|
+
{
|
|
29
|
+
title: string;
|
|
30
|
+
quantity: number;
|
|
31
|
+
rate: number;
|
|
32
|
+
vat: number;
|
|
33
|
+
discount: number;
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
terms: string;
|
|
38
|
+
notes: string;
|
|
39
|
+
sub_total: number;
|
|
40
|
+
vat_total: number;
|
|
41
|
+
discount_total: number;
|
|
42
|
+
shipping: number;
|
|
43
|
+
total: number;
|
|
44
|
+
amount_paid: number;
|
|
45
|
+
amount_due: number;
|
|
46
|
+
logo: File;
|
|
47
|
+
status: string;
|
|
48
|
+
}
|
|
49
|
+
export type UpdateVendorPaymentRequest = Partial<CreateVendorPaymentRequest>;
|
|
50
|
+
export interface VendorPayment {
|
|
51
|
+
_id: string;
|
|
52
|
+
user: string;
|
|
53
|
+
company: string;
|
|
54
|
+
wafeq: boolean;
|
|
55
|
+
zoho: boolean;
|
|
56
|
+
created_at: string;
|
|
57
|
+
updated_at: string;
|
|
58
|
+
}
|
|
59
|
+
export interface VendorPaymentQueryParams {
|
|
60
|
+
page: number;
|
|
61
|
+
limit: number;
|
|
62
|
+
sort: string;
|
|
63
|
+
filters: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Service for Vendor Payment
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
71
|
+
* const client = createClient('your-api-key');
|
|
72
|
+
* const vendorPayment = await client.vendorPayment.list({ page: 1, limit: 10 });
|
|
73
|
+
* console.log(vendorPayment.data);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare class VendorPaymentService {
|
|
77
|
+
private http;
|
|
78
|
+
constructor(http: AxiosInstance);
|
|
79
|
+
/**
|
|
80
|
+
* Fetch a paginated list of vendor payments.
|
|
81
|
+
*
|
|
82
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
83
|
+
* @returns List of vendor payments matching the query.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const vendorPayments = await client.vendorPayment.list({ page: 1, limit: 5 });
|
|
88
|
+
* console.log(vendorPayments.data);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
list(params: VendorPaymentQueryParams): Promise<AxiosResponse<VendorPayment[]>>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch a single vendor payment by ID.
|
|
94
|
+
*
|
|
95
|
+
* @param id - Vendor payment ID
|
|
96
|
+
* @returns Vendor payment object
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const vendorPayment = await client.vendorPayment.get('vendor_payment_id_here');
|
|
101
|
+
* console.log(vendorPayment.data);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
get(id: string): Promise<AxiosResponse<VendorPayment>>;
|
|
105
|
+
/**
|
|
106
|
+
* Create a new vendor payment.
|
|
107
|
+
*
|
|
108
|
+
* @param data - Vendor payment creation payload
|
|
109
|
+
* @returns The created vendor payment
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const newVendorPayment = {
|
|
114
|
+
* title: "Vendor Payment",
|
|
115
|
+
* customer: {
|
|
116
|
+
* customer_id: "123456789",
|
|
117
|
+
* name: "John Doe",
|
|
118
|
+
* email: "johndoe@example.com",
|
|
119
|
+
* trn: "123456789",
|
|
120
|
+
* country_code: "+1",
|
|
121
|
+
* mobile: "1234567890",
|
|
122
|
+
* address: "123 Main St, Anytown, USA",
|
|
123
|
+
* },
|
|
124
|
+
* biller: {
|
|
125
|
+
* biller_id: "123456789",
|
|
126
|
+
* name: "John Doe",
|
|
127
|
+
* email: "johndoe@example.com",
|
|
128
|
+
* country_code: "+1",
|
|
129
|
+
* mobile: "1234567890",
|
|
130
|
+
* address: "123 Main St, Anytown, USA",
|
|
131
|
+
* trn: "123456789",
|
|
132
|
+
* },
|
|
133
|
+
* invoice_number: "INV-1234",
|
|
134
|
+
* order_number: "123456789",
|
|
135
|
+
* invoice_date: "2025-06-23",
|
|
136
|
+
* due_date: "2025-06-23",
|
|
137
|
+
* currency: "USD",
|
|
138
|
+
* items: [
|
|
139
|
+
* {
|
|
140
|
+
* title: "Item 1",
|
|
141
|
+
* quantity: 1,
|
|
142
|
+
* rate: 100,
|
|
143
|
+
* vat: 0,
|
|
144
|
+
* discount: 0,
|
|
145
|
+
* total: 100,
|
|
146
|
+
* },
|
|
147
|
+
* ],
|
|
148
|
+
* terms: "Net 30",
|
|
149
|
+
* notes: "This is a note",
|
|
150
|
+
* sub_total: 100,
|
|
151
|
+
* vat_total: 0,
|
|
152
|
+
* discount_total: 0,
|
|
153
|
+
* shipping: 0,
|
|
154
|
+
* total: 100,
|
|
155
|
+
* amount_paid: 0,
|
|
156
|
+
* amount_due: 100,
|
|
157
|
+
* logo: "https://example.com/logo.png",
|
|
158
|
+
* status: "pending",
|
|
159
|
+
* };
|
|
160
|
+
* const response = await client.vendorPayment.create(newVendorPayment);
|
|
161
|
+
* console.log(response.data);
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
create(data: CreateVendorPaymentRequest): Promise<AxiosResponse<VendorPayment>>;
|
|
165
|
+
/**
|
|
166
|
+
* Update an existing vendor payment.
|
|
167
|
+
*
|
|
168
|
+
* @param id - Vendor payment ID
|
|
169
|
+
* @param data - Partial update data
|
|
170
|
+
* @returns Updated vendor payment
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const updates = { amount: 50.0 };
|
|
175
|
+
* const updated = await client.vendorPayment.update('vendor_payment_id_here', updates);
|
|
176
|
+
* console.log(updated.data);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
update(id: string, data: UpdateVendorPaymentRequest): Promise<AxiosResponse<VendorPayment>>;
|
|
180
|
+
/**
|
|
181
|
+
* Delete an vendor payment by ID.
|
|
182
|
+
*
|
|
183
|
+
* @param id - Vendor payment ID
|
|
184
|
+
* @returns Confirmation message
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* const response = await client.vendorPayment.delete('vendor_payment_id_here');
|
|
189
|
+
* console.log(response.data.message);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
delete(id: string): Promise<AxiosResponse<{
|
|
193
|
+
message: string;
|
|
194
|
+
}>>;
|
|
195
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
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.VendorPaymentService = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
/**
|
|
9
|
+
* Service for Vendor Payment
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
14
|
+
* const client = createClient('your-api-key');
|
|
15
|
+
* const vendorPayment = await client.vendorPayment.list({ page: 1, limit: 10 });
|
|
16
|
+
* console.log(vendorPayment.data);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class VendorPaymentService {
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch a paginated list of vendor payments.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
27
|
+
* @returns List of vendor payments matching the query.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const vendorPayments = await client.vendorPayment.list({ page: 1, limit: 5 });
|
|
32
|
+
* console.log(vendorPayments.data);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async list(params) {
|
|
36
|
+
return await this.http.get("/customer/purchase", {
|
|
37
|
+
params,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetch a single vendor payment by ID.
|
|
42
|
+
*
|
|
43
|
+
* @param id - Vendor payment ID
|
|
44
|
+
* @returns Vendor payment object
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const vendorPayment = await client.vendorPayment.get('vendor_payment_id_here');
|
|
49
|
+
* console.log(vendorPayment.data);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
async get(id) {
|
|
53
|
+
return await this.http.get(`/customer/purchase/${id}`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a new vendor payment.
|
|
57
|
+
*
|
|
58
|
+
* @param data - Vendor payment creation payload
|
|
59
|
+
* @returns The created vendor payment
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const newVendorPayment = {
|
|
64
|
+
* title: "Vendor Payment",
|
|
65
|
+
* customer: {
|
|
66
|
+
* customer_id: "123456789",
|
|
67
|
+
* name: "John Doe",
|
|
68
|
+
* email: "johndoe@example.com",
|
|
69
|
+
* trn: "123456789",
|
|
70
|
+
* country_code: "+1",
|
|
71
|
+
* mobile: "1234567890",
|
|
72
|
+
* address: "123 Main St, Anytown, USA",
|
|
73
|
+
* },
|
|
74
|
+
* biller: {
|
|
75
|
+
* biller_id: "123456789",
|
|
76
|
+
* name: "John Doe",
|
|
77
|
+
* email: "johndoe@example.com",
|
|
78
|
+
* country_code: "+1",
|
|
79
|
+
* mobile: "1234567890",
|
|
80
|
+
* address: "123 Main St, Anytown, USA",
|
|
81
|
+
* trn: "123456789",
|
|
82
|
+
* },
|
|
83
|
+
* invoice_number: "INV-1234",
|
|
84
|
+
* order_number: "123456789",
|
|
85
|
+
* invoice_date: "2025-06-23",
|
|
86
|
+
* due_date: "2025-06-23",
|
|
87
|
+
* currency: "USD",
|
|
88
|
+
* items: [
|
|
89
|
+
* {
|
|
90
|
+
* title: "Item 1",
|
|
91
|
+
* quantity: 1,
|
|
92
|
+
* rate: 100,
|
|
93
|
+
* vat: 0,
|
|
94
|
+
* discount: 0,
|
|
95
|
+
* total: 100,
|
|
96
|
+
* },
|
|
97
|
+
* ],
|
|
98
|
+
* terms: "Net 30",
|
|
99
|
+
* notes: "This is a note",
|
|
100
|
+
* sub_total: 100,
|
|
101
|
+
* vat_total: 0,
|
|
102
|
+
* discount_total: 0,
|
|
103
|
+
* shipping: 0,
|
|
104
|
+
* total: 100,
|
|
105
|
+
* amount_paid: 0,
|
|
106
|
+
* amount_due: 100,
|
|
107
|
+
* logo: "https://example.com/logo.png",
|
|
108
|
+
* status: "pending",
|
|
109
|
+
* };
|
|
110
|
+
* const response = await client.vendorPayment.create(newVendorPayment);
|
|
111
|
+
* console.log(response.data);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
async create(data) {
|
|
115
|
+
const formData = new form_data_1.default();
|
|
116
|
+
try {
|
|
117
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
118
|
+
if (key === "customer" || key === "biller") {
|
|
119
|
+
if (typeof value === "object" && value !== null) {
|
|
120
|
+
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
121
|
+
if (subValue) {
|
|
122
|
+
formData.append(`${key}[${subKey}]`, subValue);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (Array.isArray(value)) {
|
|
128
|
+
value.forEach((item, index) => {
|
|
129
|
+
if (typeof item === "object" && item !== null) {
|
|
130
|
+
Object.entries(item).forEach(([subKey, subValue]) => {
|
|
131
|
+
formData.append(`${key}[${index}][${subKey}]`, subValue);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (typeof item === "string" || item instanceof Blob) {
|
|
135
|
+
formData.append(key, item);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else if (value instanceof Date) {
|
|
140
|
+
formData.append(key, value.toISOString());
|
|
141
|
+
}
|
|
142
|
+
else if (typeof value === "string" || value instanceof Blob) {
|
|
143
|
+
formData.append(key, value);
|
|
144
|
+
}
|
|
145
|
+
else if (value) {
|
|
146
|
+
formData.append(key, value);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
return Promise.reject(error);
|
|
152
|
+
}
|
|
153
|
+
if (data.logo) {
|
|
154
|
+
formData.append("file", data.logo);
|
|
155
|
+
}
|
|
156
|
+
return await this.http.post("/customer/purchase", formData, {
|
|
157
|
+
headers: formData.getHeaders()
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Update an existing vendor payment.
|
|
162
|
+
*
|
|
163
|
+
* @param id - Vendor payment ID
|
|
164
|
+
* @param data - Partial update data
|
|
165
|
+
* @returns Updated vendor payment
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* const updates = { amount: 50.0 };
|
|
170
|
+
* const updated = await client.vendorPayment.update('vendor_payment_id_here', updates);
|
|
171
|
+
* console.log(updated.data);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
async update(id, data) {
|
|
175
|
+
const formData = new form_data_1.default();
|
|
176
|
+
try {
|
|
177
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
178
|
+
if (key === "customer" || key === "biller") {
|
|
179
|
+
if (typeof value === "object" && value !== null) {
|
|
180
|
+
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
181
|
+
if (subValue) {
|
|
182
|
+
formData.append(`${key}[${subKey}]`, subValue);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (Array.isArray(value)) {
|
|
188
|
+
value.forEach((item, index) => {
|
|
189
|
+
if (typeof item === "object" && item !== null) {
|
|
190
|
+
Object.entries(item).forEach(([subKey, subValue]) => {
|
|
191
|
+
formData.append(`${key}[${index}][${subKey}]`, subValue);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else if (typeof item === "string" || item instanceof Blob) {
|
|
195
|
+
formData.append(key, item);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else if (value instanceof Date) {
|
|
200
|
+
formData.append(key, value.toISOString());
|
|
201
|
+
}
|
|
202
|
+
else if (typeof value === "string" || value instanceof Blob) {
|
|
203
|
+
formData.append(key, value);
|
|
204
|
+
}
|
|
205
|
+
else if (value) {
|
|
206
|
+
formData.append(key, value);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
return Promise.reject(error);
|
|
212
|
+
}
|
|
213
|
+
if (data.logo) {
|
|
214
|
+
formData.append("file", data.logo);
|
|
215
|
+
}
|
|
216
|
+
return await this.http.put(`/customer/purchase/${id}`, formData, {
|
|
217
|
+
headers: formData.getHeaders()
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Delete an vendor payment by ID.
|
|
222
|
+
*
|
|
223
|
+
* @param id - Vendor payment ID
|
|
224
|
+
* @returns Confirmation message
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const response = await client.vendorPayment.delete('vendor_payment_id_here');
|
|
229
|
+
* console.log(response.data.message);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
async delete(id) {
|
|
233
|
+
return await this.http.patch(`/customer/purchase/${id}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.VendorPaymentService = VendorPaymentService;
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "timber-node",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Simplifying accounting and tax filing for businesses",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"timber"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/TImber-UAE/timber-be-sdk-s#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/TImber-UAE/timber-be-sdk-s/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/TImber-UAE/timber-be-sdk-s.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "timberaccounting",
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"require": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
28
|
+
"dev": "nodemon src/index.js",
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"docs": "typedoc"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"axios": "^1.10.0",
|
|
34
|
+
"dotenv": "^16.5.0",
|
|
35
|
+
"form-data": "^4.0.3",
|
|
36
|
+
"timber-sdk-dev": "^0.0.9"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/dotenv": "^6.1.1",
|
|
40
|
+
"@types/node": "^24.0.4",
|
|
41
|
+
"nodemon": "^3.1.10",
|
|
42
|
+
"typedoc": "^0.28.5",
|
|
43
|
+
"typedoc-plugin-markdown": "^4.7.0",
|
|
44
|
+
"typescript": "^5.8.3"
|
|
45
|
+
}
|
|
46
|
+
}
|