@apptimate/core-lib 6.4.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
|
+
}
|
|
@@ -72,9 +72,14 @@ export const getAttendanceDays = async (employeeId: string | number, startDate:
|
|
|
72
72
|
if (workforceId) params.workforce_id = workforceId;
|
|
73
73
|
const queryParams = new URLSearchParams(params);
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
let url = '';
|
|
76
|
+
if (employeeId === 0 && (projectId || workforceId)) {
|
|
77
|
+
url = `${process.env.NEXT_PUBLIC_API_URL}/api/construction/workforce/attendance-days?${queryParams.toString()}`;
|
|
78
|
+
} else {
|
|
79
|
+
url = employeeId === 'me'
|
|
80
|
+
? `${BASE_URL}/ess/me/attendance/days?${queryParams.toString()}`
|
|
81
|
+
: `${BASE_URL}/attendance/days?${queryParams.toString()}`;
|
|
82
|
+
}
|
|
78
83
|
|
|
79
84
|
const response = await sendRequest({ url, method: "GET" });
|
|
80
85
|
return response.responseData as IApiResponse;
|
|
@@ -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";
|
package/src/utils/httpClient.ts
CHANGED
|
@@ -57,9 +57,18 @@ export function buildBrowserProxyUrl(rawUrl: string): string {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
|
+
// If rawUrl is undefined/api/... (due to missing process.env), fix it
|
|
61
|
+
if (rawUrl.startsWith('undefined/')) {
|
|
62
|
+
rawUrl = rawUrl.replace('undefined/', '/');
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
const parsedUrl = new URL(rawUrl, window.location.origin);
|
|
61
66
|
|
|
62
67
|
if (parsedUrl.origin === window.location.origin) {
|
|
68
|
+
if (parsedUrl.pathname.startsWith('/api/') && !parsedUrl.pathname.startsWith('/api/proxy') && !parsedUrl.pathname.startsWith('/api/session')) {
|
|
69
|
+
const proxyPath = parsedUrl.pathname.replace(/^\/+/, '');
|
|
70
|
+
return `/api/proxy/${proxyPath}${parsedUrl.search}`;
|
|
71
|
+
}
|
|
63
72
|
return parsedUrl.toString();
|
|
64
73
|
}
|
|
65
74
|
|