timber-node 0.0.1 → 0.0.3
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/bankStatement.d.ts +57 -0
- package/dist/bankStatement.js +67 -0
- package/dist/billPayment.d.ts +2 -2
- package/dist/billPayment.js +20 -20
- package/dist/cheque.d.ts +57 -0
- package/dist/cheque.js +67 -0
- package/dist/customer.d.ts +1 -1
- package/dist/customer.js +2 -2
- package/dist/employee.d.ts +23 -23
- package/dist/employee.js +24 -24
- package/dist/expense.d.ts +1 -1
- package/dist/expense.js +2 -2
- package/dist/expenseCategory.d.ts +1 -1
- package/dist/expenseCategory.js +2 -2
- package/dist/index.d.ts +15 -11
- package/dist/index.js +7 -5
- package/dist/invoice.d.ts +15 -2
- package/dist/invoice.js +25 -8
- package/dist/invoicePayment.d.ts +1 -1
- package/dist/invoicePayment.js +3 -3
- package/dist/rawExpense.d.ts +1 -1
- package/dist/rawExpense.js +4 -4
- package/dist/salary.d.ts +11 -11
- package/dist/salary.js +12 -12
- package/dist/taxRate.d.ts +11 -11
- package/dist/taxRate.js +11 -11
- package/dist/vendorPayment.d.ts +14 -1
- package/dist/vendorPayment.js +33 -16
- package/package.json +62 -46
package/README.md
CHANGED
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
export interface BankStatementData {
|
|
3
|
+
file: File | string;
|
|
4
|
+
}
|
|
5
|
+
export interface BankStatement extends BankStatementData {
|
|
6
|
+
_id: string;
|
|
7
|
+
created_at?: string;
|
|
8
|
+
updated_at?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BankStatementQueryParams {
|
|
11
|
+
page?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Service for BankStatement
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
20
|
+
* const client = createClient('your-api-key');
|
|
21
|
+
* const bankStatement = await client.bankStatement.list({ page: 1, limit: 10 });
|
|
22
|
+
* console.log(bankStatement.data);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class BankStatementService {
|
|
26
|
+
private http;
|
|
27
|
+
constructor(http: AxiosInstance);
|
|
28
|
+
/**
|
|
29
|
+
* Fetch a paginated list of bank statements.
|
|
30
|
+
*
|
|
31
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
32
|
+
* @returns List of bank statements matching the query.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const bankStatements = await client.bankStatement.list({ page: 1, limit: 5 });
|
|
37
|
+
* console.log(bankStatements.data);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
list(params?: BankStatementQueryParams): Promise<AxiosResponse<BankStatement[]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a new bank statement.
|
|
43
|
+
*
|
|
44
|
+
* @param data - Bank statement creation payload
|
|
45
|
+
* @returns The created bank statement
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const newBankStatement = {
|
|
50
|
+
* file: File,
|
|
51
|
+
* };
|
|
52
|
+
* const response = await client.bankStatement.create(newBankStatement);
|
|
53
|
+
* console.log(response.data);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
create(data: BankStatementData): Promise<AxiosResponse<BankStatement>>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.BankStatementService = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
/**
|
|
9
|
+
* Service for BankStatement
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
14
|
+
* const client = createClient('your-api-key');
|
|
15
|
+
* const bankStatement = await client.bankStatement.list({ page: 1, limit: 10 });
|
|
16
|
+
* console.log(bankStatement.data);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class BankStatementService {
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch a paginated list of bank statements.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
27
|
+
* @returns List of bank statements matching the query.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const bankStatements = await client.bankStatement.list({ page: 1, limit: 5 });
|
|
32
|
+
* console.log(bankStatements.data);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async list(params = {}) {
|
|
36
|
+
return await this.http.get('/customer/reconcile/bank-statement', { params });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a new bank statement.
|
|
40
|
+
*
|
|
41
|
+
* @param data - Bank statement creation payload
|
|
42
|
+
* @returns The created bank statement
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const newBankStatement = {
|
|
47
|
+
* file: File,
|
|
48
|
+
* };
|
|
49
|
+
* const response = await client.bankStatement.create(newBankStatement);
|
|
50
|
+
* console.log(response.data);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async create(data) {
|
|
54
|
+
const formData = new form_data_1.default();
|
|
55
|
+
if (data === null || data === void 0 ? void 0 : data.file) {
|
|
56
|
+
formData.append('file', data.file);
|
|
57
|
+
formData.append('company', '6777a90c5cd5d327209fa239');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new Error('File is required');
|
|
61
|
+
}
|
|
62
|
+
return await this.http.post('/customer/reconcile/bank-statement', formData, {
|
|
63
|
+
headers: formData.getHeaders(),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.BankStatementService = BankStatementService;
|
package/dist/billPayment.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export interface CreateBillPaymentRequest {
|
|
3
3
|
invoice: string;
|
|
4
4
|
date: string;
|
|
5
|
-
payment_method:
|
|
5
|
+
payment_method: 'cash' | 'bank' | 'card' | 'cheque' | 'net_banking' | 'other';
|
|
6
6
|
cheque_no?: string;
|
|
7
7
|
cheque_date?: string;
|
|
8
8
|
cheque_due_date?: string;
|
package/dist/billPayment.js
CHANGED
|
@@ -33,7 +33,7 @@ class BillPaymentService {
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
async list(params) {
|
|
36
|
-
return await this.http.get(
|
|
36
|
+
return await this.http.get('/customer/purchase/payment-record', {
|
|
37
37
|
params,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -63,26 +63,26 @@ class BillPaymentService {
|
|
|
63
63
|
*/
|
|
64
64
|
async create(data) {
|
|
65
65
|
const formData = new form_data_1.default();
|
|
66
|
-
formData.append(
|
|
67
|
-
formData.append(
|
|
68
|
-
formData.append(
|
|
66
|
+
formData.append('invoice', data.invoice);
|
|
67
|
+
formData.append('date', data.date);
|
|
68
|
+
formData.append('payment_method', data.payment_method);
|
|
69
69
|
if (data.cheque_no) {
|
|
70
|
-
formData.append(
|
|
70
|
+
formData.append('cheque_no', data.cheque_no);
|
|
71
71
|
}
|
|
72
72
|
if (data.cheque_date) {
|
|
73
|
-
formData.append(
|
|
73
|
+
formData.append('cheque_date', data.cheque_date);
|
|
74
74
|
}
|
|
75
75
|
if (data.cheque_due_date) {
|
|
76
|
-
formData.append(
|
|
76
|
+
formData.append('cheque_due_date', data.cheque_due_date);
|
|
77
77
|
}
|
|
78
78
|
if (data.bank_name) {
|
|
79
|
-
formData.append(
|
|
79
|
+
formData.append('bank_name', data.bank_name);
|
|
80
80
|
}
|
|
81
|
-
formData.append(
|
|
81
|
+
formData.append('amount', data.amount.toString());
|
|
82
82
|
if (data.file) {
|
|
83
|
-
formData.append(
|
|
83
|
+
formData.append('file', data.file[0]);
|
|
84
84
|
}
|
|
85
|
-
return await this.http.post(
|
|
85
|
+
return await this.http.post('/customer/purchase/payment-record', formData, {
|
|
86
86
|
headers: formData.getHeaders(),
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -102,24 +102,24 @@ class BillPaymentService {
|
|
|
102
102
|
*/
|
|
103
103
|
async update(id, data) {
|
|
104
104
|
const formData = new form_data_1.default();
|
|
105
|
-
formData.append(
|
|
106
|
-
formData.append(
|
|
107
|
-
formData.append(
|
|
105
|
+
formData.append('invoice', data.invoice);
|
|
106
|
+
formData.append('date', data.date);
|
|
107
|
+
formData.append('payment_method', data.payment_method);
|
|
108
108
|
if (data.cheque_no) {
|
|
109
|
-
formData.append(
|
|
109
|
+
formData.append('cheque_no', data.cheque_no);
|
|
110
110
|
}
|
|
111
111
|
if (data.cheque_date) {
|
|
112
|
-
formData.append(
|
|
112
|
+
formData.append('cheque_date', data.cheque_date);
|
|
113
113
|
}
|
|
114
114
|
if (data.cheque_due_date) {
|
|
115
|
-
formData.append(
|
|
115
|
+
formData.append('cheque_due_date', data.cheque_due_date);
|
|
116
116
|
}
|
|
117
117
|
if (data.bank_name) {
|
|
118
|
-
formData.append(
|
|
118
|
+
formData.append('bank_name', data.bank_name);
|
|
119
119
|
}
|
|
120
|
-
formData.append(
|
|
120
|
+
formData.append('amount', data.amount.toString());
|
|
121
121
|
if (data.file) {
|
|
122
|
-
formData.append(
|
|
122
|
+
formData.append('file', data.file[0]);
|
|
123
123
|
}
|
|
124
124
|
return await this.http.put(`/customer/purchase/payment-record/${id}`, formData, {
|
|
125
125
|
headers: formData.getHeaders(),
|
package/dist/cheque.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
export interface ChequeData {
|
|
3
|
+
file: File | string;
|
|
4
|
+
}
|
|
5
|
+
export interface Cheque extends ChequeData {
|
|
6
|
+
_id: string;
|
|
7
|
+
created_at?: string;
|
|
8
|
+
updated_at?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ChequeQueryParams {
|
|
11
|
+
page?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Service for Cheque
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
20
|
+
* const client = createClient('your-api-key');
|
|
21
|
+
* const cheque = await client.cheque.list({ page: 1, limit: 10 });
|
|
22
|
+
* console.log(cheque.data);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class ChequeService {
|
|
26
|
+
private http;
|
|
27
|
+
constructor(http: AxiosInstance);
|
|
28
|
+
/**
|
|
29
|
+
* Fetch a paginated list of cheques.
|
|
30
|
+
*
|
|
31
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
32
|
+
* @returns List of cheques matching the query.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const cheques = await client.cheque.list({ page: 1, limit: 5 });
|
|
37
|
+
* console.log(cheques.data);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
list(params?: ChequeQueryParams): Promise<AxiosResponse<Cheque[]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a new cheque.
|
|
43
|
+
*
|
|
44
|
+
* @param data - Cheque creation payload
|
|
45
|
+
* @returns The created cheque
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const newCheque = {
|
|
50
|
+
* file: File,
|
|
51
|
+
* };
|
|
52
|
+
* const response = await client.cheque.create(newCheque);
|
|
53
|
+
* console.log(response.data);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
create(data: ChequeData): Promise<AxiosResponse<Cheque>>;
|
|
57
|
+
}
|
package/dist/cheque.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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.ChequeService = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
/**
|
|
9
|
+
* Service for Cheque
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
14
|
+
* const client = createClient('your-api-key');
|
|
15
|
+
* const cheque = await client.cheque.list({ page: 1, limit: 10 });
|
|
16
|
+
* console.log(cheque.data);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class ChequeService {
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch a paginated list of cheques.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Query options like page, limit, filters, sort.
|
|
27
|
+
* @returns List of cheques matching the query.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const cheques = await client.cheque.list({ page: 1, limit: 5 });
|
|
32
|
+
* console.log(cheques.data);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async list(params = {}) {
|
|
36
|
+
return await this.http.get('/customer/reconcile/cheque', { params });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a new cheque.
|
|
40
|
+
*
|
|
41
|
+
* @param data - Cheque creation payload
|
|
42
|
+
* @returns The created cheque
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const newCheque = {
|
|
47
|
+
* file: File,
|
|
48
|
+
* };
|
|
49
|
+
* const response = await client.cheque.create(newCheque);
|
|
50
|
+
* console.log(response.data);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async create(data) {
|
|
54
|
+
const formData = new form_data_1.default();
|
|
55
|
+
if (data === null || data === void 0 ? void 0 : data.file) {
|
|
56
|
+
formData.append('file', data.file);
|
|
57
|
+
formData.append('company', '6777a90c5cd5d327209fa239');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new Error('File is required');
|
|
61
|
+
}
|
|
62
|
+
return await this.http.post('/customer/reconcile/cheque', formData, {
|
|
63
|
+
headers: formData.getHeaders(),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ChequeService = ChequeService;
|
package/dist/customer.d.ts
CHANGED
package/dist/customer.js
CHANGED
|
@@ -29,7 +29,7 @@ class CustomerService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params = {}) {
|
|
32
|
-
return await this.http.get(
|
|
32
|
+
return await this.http.get('/customer/customer', { params });
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Fetch a single customer by ID.
|
|
@@ -44,7 +44,7 @@ class CustomerService {
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
async create(data) {
|
|
47
|
-
return await this.http.post(
|
|
47
|
+
return await this.http.post('/customer/customer', data);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Update an existing customer.
|
package/dist/employee.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export interface CreateEmployeeRequest {
|
|
3
3
|
employee_id: string;
|
|
4
4
|
name: string;
|
|
@@ -51,28 +51,28 @@ export declare class EmployeeService {
|
|
|
51
51
|
*/
|
|
52
52
|
list(params: EmployeeQueryParams): Promise<AxiosResponse<Employee[]>>;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
* Create a new employee.
|
|
55
|
+
*
|
|
56
|
+
* @param data - Employee creation payload
|
|
57
|
+
* @returns The created employee
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const newEmployee = {
|
|
62
|
+
* employee_id: "123456789",
|
|
63
|
+
* name: "John Doe",
|
|
64
|
+
* designation: "CEO",
|
|
65
|
+
* mobile: "1234567890",
|
|
66
|
+
* country_code: "+1",
|
|
67
|
+
* basic_salary: 50000,
|
|
68
|
+
* allowance: 10000,
|
|
69
|
+
* joining_date: "2025-06-23",
|
|
70
|
+
* is_active: true,
|
|
71
|
+
* };
|
|
72
|
+
* const response = await client.employee.create(newEmployee);
|
|
73
|
+
* console.log(response.data);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
76
|
create(data: CreateEmployeeRequest): Promise<AxiosResponse<Employee>>;
|
|
77
77
|
/**
|
|
78
78
|
* Fetch an employee by ID.
|
package/dist/employee.js
CHANGED
|
@@ -18,35 +18,35 @@ class EmployeeService {
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
async list(params) {
|
|
21
|
-
return await this.http.get(
|
|
21
|
+
return await this.http.get('/customer/employee', {
|
|
22
22
|
params,
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
* Create a new employee.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Employee creation payload
|
|
29
|
+
* @returns The created employee
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const newEmployee = {
|
|
34
|
+
* employee_id: "123456789",
|
|
35
|
+
* name: "John Doe",
|
|
36
|
+
* designation: "CEO",
|
|
37
|
+
* mobile: "1234567890",
|
|
38
|
+
* country_code: "+1",
|
|
39
|
+
* basic_salary: 50000,
|
|
40
|
+
* allowance: 10000,
|
|
41
|
+
* joining_date: "2025-06-23",
|
|
42
|
+
* is_active: true,
|
|
43
|
+
* };
|
|
44
|
+
* const response = await client.employee.create(newEmployee);
|
|
45
|
+
* console.log(response.data);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
48
|
async create(data) {
|
|
49
|
-
return await this.http.post(
|
|
49
|
+
return await this.http.post('/customer/employee', data);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Fetch an employee by ID.
|
package/dist/expense.d.ts
CHANGED
package/dist/expense.js
CHANGED
|
@@ -29,7 +29,7 @@ class ExpenseService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params) {
|
|
32
|
-
return await this.http.get(
|
|
32
|
+
return await this.http.get('/customer/expense', { params });
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Fetch a single expense by ID.
|
|
@@ -67,7 +67,7 @@ class ExpenseService {
|
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
69
|
async create(data) {
|
|
70
|
-
return await this.http.post(
|
|
70
|
+
return await this.http.post('/customer/expense', data);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Update an existing expense.
|
package/dist/expenseCategory.js
CHANGED
|
@@ -29,7 +29,7 @@ class ExpenseCategoryService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params) {
|
|
32
|
-
return await this.http.get(
|
|
32
|
+
return await this.http.get('/customer/expense/category', {
|
|
33
33
|
params,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -49,7 +49,7 @@ class ExpenseCategoryService {
|
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
51
|
async create(data) {
|
|
52
|
-
return await this.http.post(
|
|
52
|
+
return await this.http.post('/customer/expense/category', data);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Update an existing expense category.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ExpenseService } from
|
|
2
|
-
import { RawExpenseService } from
|
|
3
|
-
import { VendorPaymentService } from
|
|
4
|
-
import { ExpenseCategoryService } from
|
|
5
|
-
import { BillPaymentService } from
|
|
6
|
-
import { InvoiceService } from
|
|
7
|
-
import { InvoicePaymentService } from
|
|
8
|
-
import { CustomerService } from
|
|
9
|
-
import { TaxRateService } from
|
|
10
|
-
import { SalaryService } from
|
|
11
|
-
import { EmployeeService } from
|
|
1
|
+
import { ExpenseService } from './expense';
|
|
2
|
+
import { RawExpenseService } from './rawExpense';
|
|
3
|
+
import { VendorPaymentService } from './vendorPayment';
|
|
4
|
+
import { ExpenseCategoryService } from './expenseCategory';
|
|
5
|
+
import { BillPaymentService } from './billPayment';
|
|
6
|
+
import { InvoiceService } from './invoice';
|
|
7
|
+
import { InvoicePaymentService } from './invoicePayment';
|
|
8
|
+
import { CustomerService } from './customer';
|
|
9
|
+
import { TaxRateService } from './taxRate';
|
|
10
|
+
import { SalaryService } from './salary';
|
|
11
|
+
import { EmployeeService } from './employee';
|
|
12
|
+
import { ChequeService } from './cheque';
|
|
13
|
+
import { BankStatementService } from './bankStatement';
|
|
12
14
|
declare class TimberClient {
|
|
13
15
|
expense: ExpenseService;
|
|
14
16
|
expenseCategory: ExpenseCategoryService;
|
|
@@ -21,6 +23,8 @@ declare class TimberClient {
|
|
|
21
23
|
taxRate: TaxRateService;
|
|
22
24
|
salary: SalaryService;
|
|
23
25
|
employee: EmployeeService;
|
|
26
|
+
cheque: ChequeService;
|
|
27
|
+
bankStatement: BankStatementService;
|
|
24
28
|
constructor(apiKey: string, options?: {
|
|
25
29
|
baseURL?: string;
|
|
26
30
|
});
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createClient = void 0;
|
|
7
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
-
dotenv_1.default.config();
|
|
9
7
|
const axios_1 = __importDefault(require("axios"));
|
|
10
8
|
const expense_1 = require("./expense");
|
|
11
9
|
const rawExpense_1 = require("./rawExpense");
|
|
@@ -18,14 +16,16 @@ const customer_1 = require("./customer");
|
|
|
18
16
|
const taxRate_1 = require("./taxRate");
|
|
19
17
|
const salary_1 = require("./salary");
|
|
20
18
|
const employee_1 = require("./employee");
|
|
19
|
+
const cheque_1 = require("./cheque");
|
|
20
|
+
const bankStatement_1 = require("./bankStatement");
|
|
21
21
|
class TimberClient {
|
|
22
22
|
constructor(apiKey, options = {}) {
|
|
23
|
-
const baseURL = `${options.baseURL ||
|
|
23
|
+
const baseURL = `${options.baseURL || 'http://localhost:4010'}/api/v1/user/sdk`;
|
|
24
24
|
const http = axios_1.default.create({
|
|
25
25
|
baseURL: baseURL,
|
|
26
26
|
headers: {
|
|
27
27
|
Authorization: `ApiKey ${apiKey}`,
|
|
28
|
-
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
this.expense = new expense_1.ExpenseService(http);
|
|
@@ -39,11 +39,13 @@ class TimberClient {
|
|
|
39
39
|
this.taxRate = new taxRate_1.TaxRateService(http);
|
|
40
40
|
this.salary = new salary_1.SalaryService(http);
|
|
41
41
|
this.employee = new employee_1.EmployeeService(http);
|
|
42
|
+
this.cheque = new cheque_1.ChequeService(http);
|
|
43
|
+
this.bankStatement = new bankStatement_1.BankStatementService(http);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
const createClient = (apiKey, options = {}) => {
|
|
45
47
|
if (!apiKey) {
|
|
46
|
-
throw new Error(
|
|
48
|
+
throw new Error('API key is required');
|
|
47
49
|
}
|
|
48
50
|
return new TimberClient(apiKey, options);
|
|
49
51
|
};
|
package/dist/invoice.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export type NewInvoiceItem = {
|
|
3
3
|
id: string;
|
|
4
4
|
title: string;
|
|
@@ -9,7 +9,7 @@ export type NewInvoiceItem = {
|
|
|
9
9
|
total: number;
|
|
10
10
|
};
|
|
11
11
|
export interface InvoiceData {
|
|
12
|
-
mode:
|
|
12
|
+
mode: 'create' | 'edit';
|
|
13
13
|
payment_method: string;
|
|
14
14
|
title: string;
|
|
15
15
|
company: string;
|
|
@@ -106,4 +106,17 @@ export declare class InvoiceService {
|
|
|
106
106
|
}): Promise<AxiosResponse<{
|
|
107
107
|
message: string;
|
|
108
108
|
}>>;
|
|
109
|
+
/**
|
|
110
|
+
* Download an invoice PDF by ID.
|
|
111
|
+
*
|
|
112
|
+
* @param id - The ID of the invoice to download.
|
|
113
|
+
* @returns A Buffer (Node.js) or Blob (browser) containing the PDF.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const pdfBuffer = await client.invoice.download('invoice_id');
|
|
118
|
+
* fs.writeFileSync('invoice.pdf', pdfBuffer); // In Node.js
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
download(id: string): Promise<AxiosResponse<ArrayBuffer>>;
|
|
109
122
|
}
|
package/dist/invoice.js
CHANGED
|
@@ -33,18 +33,18 @@ class InvoiceService {
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
async list(params = {}) {
|
|
36
|
-
return await this.http.get(
|
|
36
|
+
return await this.http.get('/customer/invoice', { params });
|
|
37
37
|
}
|
|
38
38
|
async create(data) {
|
|
39
39
|
const formData = new form_data_1.default();
|
|
40
40
|
for (const key in data) {
|
|
41
41
|
const value = data[key];
|
|
42
|
-
if (key ===
|
|
42
|
+
if (key === 'items' || key === 'customer' || key === 'biller') {
|
|
43
43
|
formData.append(key, JSON.stringify(value));
|
|
44
44
|
}
|
|
45
|
-
else if (key ===
|
|
45
|
+
else if (key === 'logo' && value && typeof value.pipe === 'function') {
|
|
46
46
|
// This is a ReadStream
|
|
47
|
-
formData.append(
|
|
47
|
+
formData.append('logo', value);
|
|
48
48
|
}
|
|
49
49
|
else if (value instanceof Date) {
|
|
50
50
|
formData.append(key, value.toISOString());
|
|
@@ -53,7 +53,7 @@ class InvoiceService {
|
|
|
53
53
|
formData.append(key, value.toString());
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
return await this.http.post(
|
|
56
|
+
return await this.http.post('/customer/invoice', formData, {
|
|
57
57
|
headers: formData.getHeaders(),
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -61,12 +61,12 @@ class InvoiceService {
|
|
|
61
61
|
const formData = new form_data_1.default();
|
|
62
62
|
for (const key in data) {
|
|
63
63
|
const value = data[key];
|
|
64
|
-
if (key ===
|
|
64
|
+
if (key === 'items' || key === 'customer' || key === 'biller') {
|
|
65
65
|
formData.append(key, JSON.stringify(value));
|
|
66
66
|
}
|
|
67
|
-
else if (key ===
|
|
67
|
+
else if (key === 'logo' && value && typeof value.pipe === 'function') {
|
|
68
68
|
// This is a ReadStream
|
|
69
|
-
formData.append(
|
|
69
|
+
formData.append('logo', value);
|
|
70
70
|
}
|
|
71
71
|
else if (value instanceof Date) {
|
|
72
72
|
formData.append(key, value.toISOString());
|
|
@@ -96,5 +96,22 @@ class InvoiceService {
|
|
|
96
96
|
data,
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Download an invoice PDF by ID.
|
|
101
|
+
*
|
|
102
|
+
* @param id - The ID of the invoice to download.
|
|
103
|
+
* @returns A Buffer (Node.js) or Blob (browser) containing the PDF.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const pdfBuffer = await client.invoice.download('invoice_id');
|
|
108
|
+
* fs.writeFileSync('invoice.pdf', pdfBuffer); // In Node.js
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
async download(id) {
|
|
112
|
+
return await this.http.get(`/customer/invoice/download/${id}`, {
|
|
113
|
+
responseType: 'arraybuffer', // Important: tells Axios to treat the response as binary
|
|
114
|
+
});
|
|
115
|
+
}
|
|
99
116
|
}
|
|
100
117
|
exports.InvoiceService = InvoiceService;
|
package/dist/invoicePayment.d.ts
CHANGED
package/dist/invoicePayment.js
CHANGED
|
@@ -29,9 +29,9 @@ class InvoicePaymentService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params = {
|
|
32
|
-
invoice:
|
|
32
|
+
invoice: '',
|
|
33
33
|
}) {
|
|
34
|
-
return await this.http.get(
|
|
34
|
+
return await this.http.get('/customer/invoice/payment-records', { params });
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Create a new invoice payment.
|
|
@@ -58,7 +58,7 @@ class InvoicePaymentService {
|
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
60
|
async create(data) {
|
|
61
|
-
return await this.http.post(
|
|
61
|
+
return await this.http.post('/customer/invoice/payment-records', data);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Update an existing invoice payment.
|
package/dist/rawExpense.d.ts
CHANGED
package/dist/rawExpense.js
CHANGED
|
@@ -29,7 +29,7 @@ class RawExpenseService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params) {
|
|
32
|
-
return await this.http.get(
|
|
32
|
+
return await this.http.get('/customer/expense/raw', {
|
|
33
33
|
params,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -50,10 +50,10 @@ class RawExpenseService {
|
|
|
50
50
|
*/
|
|
51
51
|
async create(data) {
|
|
52
52
|
const formData = new FormData();
|
|
53
|
-
formData.append(
|
|
54
|
-
return await this.http.post(
|
|
53
|
+
formData.append('file', data.file);
|
|
54
|
+
return await this.http.post('/customer/expense/raw', formData, {
|
|
55
55
|
headers: {
|
|
56
|
-
|
|
56
|
+
'Content-Type': 'multipart/form-data',
|
|
57
57
|
},
|
|
58
58
|
});
|
|
59
59
|
}
|
package/dist/salary.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export interface CreateSalaryData {
|
|
3
3
|
month: number;
|
|
4
4
|
year: number;
|
|
@@ -34,16 +34,16 @@ export interface SalaryQueryParams {
|
|
|
34
34
|
filters: string;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Service for Salary
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* const { createClient } = require('timber-sdk-dev');
|
|
42
|
-
* const client = createClient('your-api-key');
|
|
43
|
-
* const salary = await client.salary.list({ page: 1, limit: 10 });
|
|
44
|
-
* console.log(salary.data);
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
37
|
+
* Service for Salary
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
42
|
+
* const client = createClient('your-api-key');
|
|
43
|
+
* const salary = await client.salary.list({ page: 1, limit: 10 });
|
|
44
|
+
* console.log(salary.data);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
47
|
export declare class SalaryService {
|
|
48
48
|
private http;
|
|
49
49
|
constructor(http: AxiosInstance);
|
package/dist/salary.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SalaryService = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Service for Salary
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
-
* const client = createClient('your-api-key');
|
|
11
|
-
* const salary = await client.salary.list({ page: 1, limit: 10 });
|
|
12
|
-
* console.log(salary.data);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
5
|
+
* Service for Salary
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
+
* const client = createClient('your-api-key');
|
|
11
|
+
* const salary = await client.salary.list({ page: 1, limit: 10 });
|
|
12
|
+
* console.log(salary.data);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
15
|
class SalaryService {
|
|
16
16
|
constructor(http) {
|
|
17
17
|
this.http = http;
|
|
@@ -29,7 +29,7 @@ class SalaryService {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
async list(params) {
|
|
32
|
-
return await this.http.get(
|
|
32
|
+
return await this.http.get('/customer/salary', {
|
|
33
33
|
params,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -78,7 +78,7 @@ class SalaryService {
|
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
async create(data) {
|
|
81
|
-
return await this.http.post(
|
|
81
|
+
return await this.http.post('/customer/salary', data);
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Update an existing salary.
|
package/dist/taxRate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export interface TaxRateData {
|
|
3
3
|
name: string;
|
|
4
4
|
percentage: number;
|
|
@@ -18,16 +18,16 @@ export interface TaxRateQueryParams {
|
|
|
18
18
|
limit?: number;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Service for Tax Rate
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const { createClient } = require('timber-sdk-dev');
|
|
26
|
-
* const client = createClient('your-api-key');
|
|
27
|
-
* const taxRate = await client.taxRate.list({ page: 1, limit: 10 });
|
|
28
|
-
* console.log(taxRate.data);
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
21
|
+
* Service for Tax Rate
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
26
|
+
* const client = createClient('your-api-key');
|
|
27
|
+
* const taxRate = await client.taxRate.list({ page: 1, limit: 10 });
|
|
28
|
+
* console.log(taxRate.data);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
31
|
export declare class TaxRateService {
|
|
32
32
|
private http;
|
|
33
33
|
constructor(http: AxiosInstance);
|
package/dist/taxRate.js
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaxRateService = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Service for Tax Rate
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
-
* const client = createClient('your-api-key');
|
|
11
|
-
* const taxRate = await client.taxRate.list({ page: 1, limit: 10 });
|
|
12
|
-
* console.log(taxRate.data);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
5
|
+
* Service for Tax Rate
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
+
* const client = createClient('your-api-key');
|
|
11
|
+
* const taxRate = await client.taxRate.list({ page: 1, limit: 10 });
|
|
12
|
+
* console.log(taxRate.data);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
15
|
class TaxRateService {
|
|
16
16
|
constructor(http) {
|
|
17
17
|
this.http = http;
|
|
18
18
|
}
|
|
19
19
|
async list(params = {}) {
|
|
20
|
-
return await this.http.get(
|
|
20
|
+
return await this.http.get('/customer/tax-rate', { params });
|
|
21
21
|
}
|
|
22
22
|
async get(id) {
|
|
23
23
|
return await this.http.get(`/customer/tax-rate/${id}`);
|
package/dist/vendorPayment.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
export interface CreateVendorPaymentRequest {
|
|
3
3
|
title: string;
|
|
4
4
|
customer: {
|
|
@@ -192,4 +192,17 @@ export declare class VendorPaymentService {
|
|
|
192
192
|
delete(id: string): Promise<AxiosResponse<{
|
|
193
193
|
message: string;
|
|
194
194
|
}>>;
|
|
195
|
+
/**
|
|
196
|
+
* Download a vendor payment PDF by ID.
|
|
197
|
+
*
|
|
198
|
+
* @param id - The ID of the vendor payment to download.
|
|
199
|
+
* @returns A Buffer (Node.js) or Blob (browser) containing the PDF.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const pdfBuffer = await client.vendorPayment.download('vendor_payment_id');
|
|
204
|
+
* fs.writeFileSync('vendor_payment.pdf', pdfBuffer); // In Node.js
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
download(id: string): Promise<AxiosResponse<ArrayBuffer>>;
|
|
195
208
|
}
|
package/dist/vendorPayment.js
CHANGED
|
@@ -33,7 +33,7 @@ class VendorPaymentService {
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
async list(params) {
|
|
36
|
-
return await this.http.get(
|
|
36
|
+
return await this.http.get('/customer/purchase', {
|
|
37
37
|
params,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -115,8 +115,8 @@ class VendorPaymentService {
|
|
|
115
115
|
const formData = new form_data_1.default();
|
|
116
116
|
try {
|
|
117
117
|
Object.entries(data).forEach(([key, value]) => {
|
|
118
|
-
if (key ===
|
|
119
|
-
if (typeof value ===
|
|
118
|
+
if (key === 'customer' || key === 'biller') {
|
|
119
|
+
if (typeof value === 'object' && value !== null) {
|
|
120
120
|
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
121
121
|
if (subValue) {
|
|
122
122
|
formData.append(`${key}[${subKey}]`, subValue);
|
|
@@ -126,12 +126,12 @@ class VendorPaymentService {
|
|
|
126
126
|
}
|
|
127
127
|
else if (Array.isArray(value)) {
|
|
128
128
|
value.forEach((item, index) => {
|
|
129
|
-
if (typeof item ===
|
|
129
|
+
if (typeof item === 'object' && item !== null) {
|
|
130
130
|
Object.entries(item).forEach(([subKey, subValue]) => {
|
|
131
131
|
formData.append(`${key}[${index}][${subKey}]`, subValue);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
else if (typeof item ===
|
|
134
|
+
else if (typeof item === 'string' || item instanceof Blob) {
|
|
135
135
|
formData.append(key, item);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -139,7 +139,7 @@ class VendorPaymentService {
|
|
|
139
139
|
else if (value instanceof Date) {
|
|
140
140
|
formData.append(key, value.toISOString());
|
|
141
141
|
}
|
|
142
|
-
else if (typeof value ===
|
|
142
|
+
else if (typeof value === 'string' || value instanceof Blob) {
|
|
143
143
|
formData.append(key, value);
|
|
144
144
|
}
|
|
145
145
|
else if (value) {
|
|
@@ -151,10 +151,10 @@ class VendorPaymentService {
|
|
|
151
151
|
return Promise.reject(error);
|
|
152
152
|
}
|
|
153
153
|
if (data.logo) {
|
|
154
|
-
formData.append(
|
|
154
|
+
formData.append('file', data.logo);
|
|
155
155
|
}
|
|
156
|
-
return await this.http.post(
|
|
157
|
-
headers: formData.getHeaders()
|
|
156
|
+
return await this.http.post('/customer/purchase', formData, {
|
|
157
|
+
headers: formData.getHeaders(),
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -175,8 +175,8 @@ class VendorPaymentService {
|
|
|
175
175
|
const formData = new form_data_1.default();
|
|
176
176
|
try {
|
|
177
177
|
Object.entries(data).forEach(([key, value]) => {
|
|
178
|
-
if (key ===
|
|
179
|
-
if (typeof value ===
|
|
178
|
+
if (key === 'customer' || key === 'biller') {
|
|
179
|
+
if (typeof value === 'object' && value !== null) {
|
|
180
180
|
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
181
181
|
if (subValue) {
|
|
182
182
|
formData.append(`${key}[${subKey}]`, subValue);
|
|
@@ -186,12 +186,12 @@ class VendorPaymentService {
|
|
|
186
186
|
}
|
|
187
187
|
else if (Array.isArray(value)) {
|
|
188
188
|
value.forEach((item, index) => {
|
|
189
|
-
if (typeof item ===
|
|
189
|
+
if (typeof item === 'object' && item !== null) {
|
|
190
190
|
Object.entries(item).forEach(([subKey, subValue]) => {
|
|
191
191
|
formData.append(`${key}[${index}][${subKey}]`, subValue);
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
else if (typeof item ===
|
|
194
|
+
else if (typeof item === 'string' || item instanceof Blob) {
|
|
195
195
|
formData.append(key, item);
|
|
196
196
|
}
|
|
197
197
|
});
|
|
@@ -199,7 +199,7 @@ class VendorPaymentService {
|
|
|
199
199
|
else if (value instanceof Date) {
|
|
200
200
|
formData.append(key, value.toISOString());
|
|
201
201
|
}
|
|
202
|
-
else if (typeof value ===
|
|
202
|
+
else if (typeof value === 'string' || value instanceof Blob) {
|
|
203
203
|
formData.append(key, value);
|
|
204
204
|
}
|
|
205
205
|
else if (value) {
|
|
@@ -211,10 +211,10 @@ class VendorPaymentService {
|
|
|
211
211
|
return Promise.reject(error);
|
|
212
212
|
}
|
|
213
213
|
if (data.logo) {
|
|
214
|
-
formData.append(
|
|
214
|
+
formData.append('file', data.logo);
|
|
215
215
|
}
|
|
216
216
|
return await this.http.put(`/customer/purchase/${id}`, formData, {
|
|
217
|
-
headers: formData.getHeaders()
|
|
217
|
+
headers: formData.getHeaders(),
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
@@ -232,5 +232,22 @@ class VendorPaymentService {
|
|
|
232
232
|
async delete(id) {
|
|
233
233
|
return await this.http.patch(`/customer/purchase/${id}`);
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Download a vendor payment PDF by ID.
|
|
237
|
+
*
|
|
238
|
+
* @param id - The ID of the vendor payment to download.
|
|
239
|
+
* @returns A Buffer (Node.js) or Blob (browser) containing the PDF.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* const pdfBuffer = await client.vendorPayment.download('vendor_payment_id');
|
|
244
|
+
* fs.writeFileSync('vendor_payment.pdf', pdfBuffer); // In Node.js
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
async download(id) {
|
|
248
|
+
return await this.http.get(`/customer/purchase/download/${id}`, {
|
|
249
|
+
responseType: 'arraybuffer', // Important: tells Axios to treat the response as binary
|
|
250
|
+
});
|
|
251
|
+
}
|
|
235
252
|
}
|
|
236
253
|
exports.VendorPaymentService = VendorPaymentService;
|
package/package.json
CHANGED
|
@@ -1,46 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "timber-node",
|
|
3
|
-
"version": "0.0.
|
|
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
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "timber-node",
|
|
3
|
+
"version": "0.0.3",
|
|
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
|
+
"dev": "nodemon src/index.js",
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"docs": "typedoc",
|
|
30
|
+
"prepare": "husky",
|
|
31
|
+
"lint": "eslint . --ext .ts,.js",
|
|
32
|
+
"lint:fix": "eslint . --ext .ts,.js --fix"
|
|
33
|
+
},
|
|
34
|
+
"lint-staged": {
|
|
35
|
+
"*.{js,ts,json,md}": [
|
|
36
|
+
"prettier --write",
|
|
37
|
+
"eslint --fix"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"axios": "^1.10.0",
|
|
42
|
+
"form-data": "^4.0.3",
|
|
43
|
+
"typescript-eslint": "^8.35.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@commitlint/cli": "^19.8.1",
|
|
47
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
48
|
+
"@types/node": "^24.0.4",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.35.0",
|
|
51
|
+
"eslint": "^9.29.0",
|
|
52
|
+
"eslint-config-prettier": "^10.1.5",
|
|
53
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
54
|
+
"globals": "^16.2.0",
|
|
55
|
+
"husky": "^8.0.3",
|
|
56
|
+
"nodemon": "^3.1.10",
|
|
57
|
+
"prettier": "^3.6.2",
|
|
58
|
+
"typedoc": "^0.28.5",
|
|
59
|
+
"typedoc-plugin-markdown": "^4.7.0",
|
|
60
|
+
"typescript": "^5.8.3"
|
|
61
|
+
}
|
|
62
|
+
}
|