Merge branch 'schema/bulk-approve-marketings-expenses' into 'development'

Schema/bulk approve marketings expenses

See merge request mbugroup/lti-web-client!417
This commit is contained in:
Adnan Zahir
2026-04-22 10:36:38 +07:00
+39
View File
@@ -351,6 +351,45 @@ export class ExpenseApiService extends BaseApiService<
}
}
async bulkApprovals(
ids: number[],
status: BulkApproveExpensePayload['status'] | 'SELESAI',
date?: string,
notes?: string
): Promise<BaseApiResponse<Expense | Expense[]> | undefined> {
if (status === 'SELESAI') {
const responses = await Promise.all(ids.map((id) => this.complete(id)));
const failedResponse = responses.find(
(response) => response?.status !== 'success'
);
if (failedResponse) {
return failedResponse;
}
const completedExpenses = responses.flatMap((response) =>
response?.status === 'success' ? [response.data] : []
);
return {
code: 200,
status: 'success',
message:
completedExpenses.length === 1
? 'Submit expense approval successfully'
: 'Submit expense approvals successfully',
data: completedExpenses,
};
}
return this.bulkApproveToStatus({
approvable_ids: ids,
status,
date: date || undefined,
notes: notes || undefined,
});
}
async rejectHeadArea(
id: number,
notes?: string