mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
fix: schema update for bulk approve
This commit is contained in:
@@ -144,9 +144,11 @@ export const DeliveryProductToFieldValues = (
|
|||||||
delivery: BaseDeliveryOrder
|
delivery: BaseDeliveryOrder
|
||||||
): DeliveryOrderProductFormValues[] => {
|
): DeliveryOrderProductFormValues[] => {
|
||||||
const data = delivery.deliveries.map((item) => {
|
const data = delivery.deliveries.map((item) => {
|
||||||
const salesOrder = salesOrders.find(
|
const salesOrder =
|
||||||
(so) => so.product_warehouse.id === item.product_warehouse.id
|
salesOrders.find((so) => so.id === item.marketing_product_id) ??
|
||||||
);
|
salesOrders.find(
|
||||||
|
(so) => so.product_warehouse.id === item.product_warehouse.id
|
||||||
|
);
|
||||||
const warehouseOption = {
|
const warehouseOption = {
|
||||||
value: item.product_warehouse.warehouse.id,
|
value: item.product_warehouse.warehouse.id,
|
||||||
label: item.product_warehouse.warehouse.name,
|
label: item.product_warehouse.warehouse.name,
|
||||||
@@ -180,7 +182,7 @@ export const DeliveryProductToFieldValues = (
|
|||||||
vehicle_number: item.vehicle_number,
|
vehicle_number: item.vehicle_number,
|
||||||
delivery_date: formatDate(delivery.delivery_date, 'yyyy-MM-DD'),
|
delivery_date: formatDate(delivery.delivery_date, 'yyyy-MM-DD'),
|
||||||
do_number: delivery.do_number,
|
do_number: delivery.do_number,
|
||||||
marketing_product_id: salesOrder?.id,
|
marketing_product_id: item.marketing_product_id ?? salesOrder?.id,
|
||||||
marketing_type: salesOrder?.marketing_type
|
marketing_type: salesOrder?.marketing_type
|
||||||
? {
|
? {
|
||||||
value: salesOrder?.marketing_type,
|
value: salesOrder?.marketing_type,
|
||||||
@@ -194,7 +196,7 @@ export const DeliveryProductToFieldValues = (
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
marketing_product: {
|
marketing_product: {
|
||||||
id: salesOrder?.id,
|
id: item.marketing_product_id ?? salesOrder?.id,
|
||||||
vehicle_number: item.vehicle_number,
|
vehicle_number: item.vehicle_number,
|
||||||
warehouse_id: item.product_warehouse.warehouse.id,
|
warehouse_id: item.product_warehouse.warehouse.id,
|
||||||
warehouse: warehouseOption,
|
warehouse: warehouseOption,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import axios from 'axios';
|
|||||||
import { BaseApiService } from '@/services/api/base';
|
import { BaseApiService } from '@/services/api/base';
|
||||||
import { BaseApiResponse, GroupedApprovals } from '@/types/api/api-general';
|
import { BaseApiResponse, GroupedApprovals } from '@/types/api/api-general';
|
||||||
import {
|
import {
|
||||||
|
BulkApproveExpensePayload,
|
||||||
CreateExpensePayload,
|
CreateExpensePayload,
|
||||||
CreateExpenseRealizationPayload,
|
CreateExpenseRealizationPayload,
|
||||||
Expense,
|
Expense,
|
||||||
@@ -330,6 +331,26 @@ export class ExpenseApiService extends BaseApiService<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async bulkApproveToStatus(
|
||||||
|
payload: BulkApproveExpensePayload
|
||||||
|
): Promise<BaseApiResponse<Expense | Expense[]> | undefined> {
|
||||||
|
try {
|
||||||
|
return await httpClient<BaseApiResponse<Expense | Expense[]>>(
|
||||||
|
`${this.basePath}/approvals/bulk`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: payload,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
if (axios.isAxiosError<BaseApiResponse<Expense | Expense[]>>(error)) {
|
||||||
|
return error.response?.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async rejectHeadArea(
|
async rejectHeadArea(
|
||||||
id: number,
|
id: number,
|
||||||
notes?: string
|
notes?: string
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import { isResponseError } from '@/lib/api-helper';
|
|||||||
import { BaseApiService } from '@/services/api/base';
|
import { BaseApiService } from '@/services/api/base';
|
||||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
import axios from 'axios';
|
||||||
import {
|
import {
|
||||||
|
BulkApproveMarketingPayload,
|
||||||
Marketing,
|
Marketing,
|
||||||
CreateSalesOrderPayload,
|
CreateSalesOrderPayload,
|
||||||
UpdateSalesOrderPayload,
|
UpdateSalesOrderPayload,
|
||||||
@@ -73,6 +75,26 @@ export class SalesOrderService extends BaseApiService<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async bulkApproveToStatus(
|
||||||
|
payload: BulkApproveMarketingPayload
|
||||||
|
): Promise<BaseApiResponse<Marketing | Marketing[]> | undefined> {
|
||||||
|
try {
|
||||||
|
return await httpClient<BaseApiResponse<Marketing | Marketing[]>>(
|
||||||
|
'/marketing/approvals/bulk',
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: payload,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
if (axios.isAxiosError<BaseApiResponse<Marketing | Marketing[]>>(error)) {
|
||||||
|
return error.response?.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delivery
|
* Delivery
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+13
@@ -99,3 +99,16 @@ export type CreateExpenseRealizationPayload = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateExpenseRealizationPayload = CreateExpenseRealizationPayload;
|
export type UpdateExpenseRealizationPayload = CreateExpenseRealizationPayload;
|
||||||
|
|
||||||
|
export type ExpenseBulkApprovalStatus =
|
||||||
|
| 'HEAD_AREA'
|
||||||
|
| 'UNIT_VICE_PRESIDENT'
|
||||||
|
| 'FINANCE'
|
||||||
|
| 'REALISASI';
|
||||||
|
|
||||||
|
export type BulkApproveExpensePayload = {
|
||||||
|
approvable_ids: number[];
|
||||||
|
status: ExpenseBulkApprovalStatus;
|
||||||
|
date?: string;
|
||||||
|
notes?: string;
|
||||||
|
};
|
||||||
|
|||||||
+10
@@ -54,6 +54,7 @@ export type BaseDeliveryOrder = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type BaseDelivery = {
|
export type BaseDelivery = {
|
||||||
|
marketing_product_id: number;
|
||||||
product_warehouse: ProductWarehouse;
|
product_warehouse: ProductWarehouse;
|
||||||
qty: number;
|
qty: number;
|
||||||
unit_price: number;
|
unit_price: number;
|
||||||
@@ -162,3 +163,12 @@ export type UpdateDeliveryOrderProductPayload =
|
|||||||
export type UpdateSalesOrderPayload = CreateSalesOrderPayload;
|
export type UpdateSalesOrderPayload = CreateSalesOrderPayload;
|
||||||
|
|
||||||
export type UpdateDeliveryOrderPayload = CreateDeliveryOrderPayload;
|
export type UpdateDeliveryOrderPayload = CreateDeliveryOrderPayload;
|
||||||
|
|
||||||
|
export type MarketingBulkApprovalStatus = 'SALES_ORDER' | 'DELIVERY';
|
||||||
|
|
||||||
|
export type BulkApproveMarketingPayload = {
|
||||||
|
approvable_ids: number[];
|
||||||
|
status: MarketingBulkApprovalStatus;
|
||||||
|
date?: string;
|
||||||
|
notes?: string;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user