mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
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:
@@ -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(
|
async rejectHeadArea(
|
||||||
id: number,
|
id: number,
|
||||||
notes?: string
|
notes?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user