@apptimate/core-lib 6.5.0 → 6.6.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/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { sendRequest, IApiResponse } from "../index";
|
|
2
|
+
|
|
3
|
+
const BASE = `${process.env.NEXT_PUBLIC_API_URL}/api/finance`;
|
|
4
|
+
|
|
5
|
+
function preparePayload(payload: any) {
|
|
6
|
+
if (payload.attachments && payload.attachments.length > 0) {
|
|
7
|
+
const formData = new FormData();
|
|
8
|
+
Object.keys(payload).forEach((key) => {
|
|
9
|
+
if (key === "attachments") {
|
|
10
|
+
payload.attachments.forEach((file: File) => formData.append("attachments[]", file));
|
|
11
|
+
} else if (key === "payments" && Array.isArray(payload.payments)) {
|
|
12
|
+
payload.payments.forEach((p: any, index: number) => {
|
|
13
|
+
formData.append(`payments[${index}][payment_method]`, p.payment_method);
|
|
14
|
+
formData.append(`payments[${index}][payment_amount]`, String(p.payment_amount));
|
|
15
|
+
if (p.bank_account_id) {
|
|
16
|
+
formData.append(`payments[${index}][bank_account_id]`, String(p.bank_account_id));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
if (payload[key] !== null && payload[key] !== undefined) {
|
|
21
|
+
formData.append(key, String(payload[key]));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return formData;
|
|
26
|
+
}
|
|
27
|
+
return payload;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function recordDirectExpenseShared(payload: any): Promise<IApiResponse> {
|
|
31
|
+
const url = `${BASE}/direct-transactions/expense`;
|
|
32
|
+
const response = await sendRequest({
|
|
33
|
+
url,
|
|
34
|
+
method: "POST",
|
|
35
|
+
data: preparePayload(payload),
|
|
36
|
+
});
|
|
37
|
+
return response.responseData as IApiResponse;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function getPaymentModesShared(): Promise<IApiResponse> {
|
|
41
|
+
const response = await sendRequest({ url: `${BASE}/payment-modes`, method: "GET" });
|
|
42
|
+
return response.responseData as IApiResponse;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function getBankAccountsLookupShared(): Promise<IApiResponse> {
|
|
46
|
+
const response = await sendRequest({ url: `${BASE}/bank-accounts/lookup`, method: "GET" });
|
|
47
|
+
return response.responseData as IApiResponse;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function getChartOfAccountsLookupShared(type?: string): Promise<IApiResponse> {
|
|
51
|
+
const params: any = {};
|
|
52
|
+
if (type) params.type = type;
|
|
53
|
+
const response = await sendRequest({ url: `${BASE}/chart-of-accounts/lookup`, method: "GET", params });
|
|
54
|
+
return response.responseData as IApiResponse;
|
|
55
|
+
}
|
|
@@ -8,7 +8,7 @@ export async function punchAttendance(data: any): Promise<IApiResponse> {
|
|
|
8
8
|
return response.responseData as IApiResponse;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export async function bulkPunchAttendance(data: { punches: any[] }): Promise<IApiResponse> {
|
|
11
|
+
export async function bulkPunchAttendance(data: { punches: any[], payment_account_id?: number }): Promise<IApiResponse> {
|
|
12
12
|
const response = await sendRequest({ url: `${BASE_URL}/punches/bulk`, method: "POST", data });
|
|
13
13
|
return response.responseData as IApiResponse;
|
|
14
14
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,3 +17,4 @@ export * from './api-services/hr-shift-templates.client';
|
|
|
17
17
|
export * from './api-services/hr-employees.client';
|
|
18
18
|
export * from './api-services/email-services.client';
|
|
19
19
|
export * from './api-services/email-templates.client';
|
|
20
|
+
export * from "./api-services/finance-shared.client";
|