mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Refactor inventory adjustment form
This commit is contained in:
@@ -1,54 +1,101 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { OptionType } from '@/components/input/SelectInput';
|
|
||||||
|
|
||||||
export const InventoryAdjustmentFormSchema = Yup.object({
|
export type InventoryAdjustmentFormSchemaType = {
|
||||||
product_category: Yup.mixed<OptionType>()
|
location: {
|
||||||
.nullable()
|
value: number;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
location_id: number;
|
||||||
|
project_flock: {
|
||||||
|
value: number;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
project_flock_id: number;
|
||||||
|
kandang: {
|
||||||
|
value: number;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
kandang_id: number;
|
||||||
|
project_flock_kandang: {
|
||||||
|
value: number;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
project_flock_kandang_id: number;
|
||||||
|
product: {
|
||||||
|
value: number;
|
||||||
|
label: string;
|
||||||
|
} | null;
|
||||||
|
product_id: number;
|
||||||
|
transaction_type: string;
|
||||||
|
transaction_subtype: string;
|
||||||
|
qty: number | string;
|
||||||
|
price: number | string;
|
||||||
|
notes: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const InventoryAdjustmentFormSchema: Yup.ObjectSchema<InventoryAdjustmentFormSchemaType> =
|
||||||
|
Yup.object({
|
||||||
|
location: Yup.object({
|
||||||
|
value: Yup.number().min(1).required(),
|
||||||
|
label: Yup.string().required(),
|
||||||
|
}).nullable(),
|
||||||
|
location_id: Yup.number()
|
||||||
|
.min(1, 'Lokasi wajib diisi!')
|
||||||
|
.required('Lokasi wajib diisi!')
|
||||||
|
.typeError('Lokasi wajib diisi!'),
|
||||||
|
project_flock: Yup.object({
|
||||||
|
value: Yup.number().min(1).required(),
|
||||||
|
label: Yup.string().required(),
|
||||||
|
}).nullable(),
|
||||||
|
project_flock_id: Yup.number()
|
||||||
|
.min(1, 'Project flock wajib diisi!')
|
||||||
|
.required('Project flock wajib diisi!')
|
||||||
|
.typeError('Project flock wajib diisi!'),
|
||||||
|
kandang: Yup.object({
|
||||||
|
value: Yup.number().min(1).required(),
|
||||||
|
label: Yup.string().required(),
|
||||||
|
}).nullable(),
|
||||||
|
kandang_id: Yup.number()
|
||||||
|
.min(1, 'Kandang wajib diisi!')
|
||||||
|
.required('Kandang wajib diisi!')
|
||||||
|
.typeError('Kandang wajib diisi!'),
|
||||||
|
project_flock_kandang: Yup.object({
|
||||||
|
value: Yup.number().min(1).required(),
|
||||||
|
label: Yup.string().required(),
|
||||||
|
}).nullable(),
|
||||||
|
project_flock_kandang_id: Yup.number()
|
||||||
|
.default(0)
|
||||||
|
.typeError('Project Flock Kandang wajib diisi!')
|
||||||
.test(
|
.test(
|
||||||
'is-valid-option',
|
'is-valid-project-flock-kandang',
|
||||||
'Kategori Produk wajib diisi!',
|
'Project Flock Kandang wajib diisi!',
|
||||||
(value) => value !== null && value !== undefined
|
(value) => value !== undefined && value !== null && value > 0
|
||||||
),
|
)
|
||||||
|
.required('Project Flock Kandang wajib diisi!'),
|
||||||
product_category_id: Yup.number().nullable(),
|
product: Yup.object({
|
||||||
|
value: Yup.number().min(1).required(),
|
||||||
product: Yup.mixed<OptionType>()
|
label: Yup.string().required(),
|
||||||
.nullable()
|
}).nullable(),
|
||||||
.test(
|
|
||||||
'is-valid-option',
|
|
||||||
'Produk wajib diisi!',
|
|
||||||
(value) => value !== null && value !== undefined
|
|
||||||
),
|
|
||||||
|
|
||||||
product_id: Yup.number()
|
product_id: Yup.number()
|
||||||
.nullable()
|
.min(1, 'Produk wajib diisi!')
|
||||||
.required('Produk wajib diisi!')
|
.required('Produk wajib diisi!')
|
||||||
.min(1, 'Produk wajib diisi!'),
|
.typeError('Produk wajib diisi!'),
|
||||||
|
|
||||||
warehouse: Yup.mixed<OptionType>()
|
|
||||||
.nullable()
|
|
||||||
.test(
|
|
||||||
'is-valid-option',
|
|
||||||
'Warehouse wajib diisi!',
|
|
||||||
(value) => value !== null && value !== undefined
|
|
||||||
),
|
|
||||||
|
|
||||||
warehouse_id: Yup.number()
|
|
||||||
.nullable()
|
|
||||||
.required('Warehouse wajib diisi!')
|
|
||||||
.min(1, 'Warehouse wajib diisi!'),
|
|
||||||
|
|
||||||
transaction_type: Yup.string()
|
transaction_type: Yup.string()
|
||||||
.oneOf(['increase', 'decrease'], 'Tipe transaksi tidak valid')
|
.oneOf(
|
||||||
.nullable()
|
['PEMBELIAN', 'PENJUALAN', 'BIAYA', 'RECORDING'],
|
||||||
|
'Tipe transaksi tidak valid'
|
||||||
|
)
|
||||||
.required('Tipe transaksi wajib diisi'),
|
.required('Tipe transaksi wajib diisi'),
|
||||||
|
transaction_subtype: Yup.string().required('Sub tipe transaksi wajib diisi'),
|
||||||
quantity: Yup.number()
|
qty: Yup.number()
|
||||||
.typeError('Kuantitas harus berupa angka')
|
.typeError('Kuantitas harus berupa angka')
|
||||||
.min(1, 'Minimal kuantitas adalah 1')
|
.min(1, 'Minimal kuantitas adalah 1')
|
||||||
.required('Kuantitas wajib diisi'),
|
.required('Kuantitas wajib diisi'),
|
||||||
|
price: Yup.number()
|
||||||
note: Yup.string().required('Catatan wajib diisi!'),
|
.typeError('Harga harus berupa angka')
|
||||||
|
.min(0, 'Minimal harga adalah 0')
|
||||||
|
.required('Harga wajib diisi'),
|
||||||
|
notes: Yup.string().required('Catatan wajib diisi!'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type InventoryAdjustmentFormValues = Yup.InferType<
|
export type InventoryAdjustmentFormValues = Yup.InferType<
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -549,12 +549,12 @@ export const MARKETING_DATE_FILTER_TYPE_OPTIONS = [
|
|||||||
export const TRANSACTION_TYPE_OPTIONS = [
|
export const TRANSACTION_TYPE_OPTIONS = [
|
||||||
{ label: 'Pembelian', value: 'PEMBELIAN' },
|
{ label: 'Pembelian', value: 'PEMBELIAN' },
|
||||||
{ label: 'Penjualan', value: 'PENJUALAN' },
|
{ label: 'Penjualan', value: 'PENJUALAN' },
|
||||||
{ label: 'Biaya', value: 'BIAYA' },
|
{ label: 'Recording', value: 'RECORDING' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const TRANSACTION_SUBTYPE_OPTIONS = {
|
export const TRANSACTION_SUBTYPE_OPTIONS = {
|
||||||
PEMBELIAN: [{ label: 'Pembelian', value: 'PURCHASE_IN' }],
|
PEMBELIAN: { label: 'Pembelian', value: 'PURCHASE_IN' },
|
||||||
PENJUALAN: [{ label: 'Penjualan', value: 'MARKETING_OUT' }],
|
PENJUALAN: { label: 'Penjualan', value: 'MARKETING_OUT' },
|
||||||
RECORDING: [
|
RECORDING: [
|
||||||
{ label: 'Recording Stock Out', value: 'RECORDING_STOCK_OUT' },
|
{ label: 'Recording Stock Out', value: 'RECORDING_STOCK_OUT' },
|
||||||
{ label: 'Recording Depletion Out', value: 'RECORDING_DEPLETION_OUT' },
|
{ label: 'Recording Depletion Out', value: 'RECORDING_DEPLETION_OUT' },
|
||||||
|
|||||||
+19
-15
@@ -1,31 +1,35 @@
|
|||||||
import { Product } from '@/types/api/master-data/product';
|
|
||||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
|
||||||
import { BaseMetadata } from '@/types/api/api-general';
|
import { BaseMetadata } from '@/types/api/api-general';
|
||||||
|
import { Location } from '@/types/api/master-data/location';
|
||||||
|
import { ProjectFlock } from '@/types/api/project-flock';
|
||||||
|
|
||||||
export type BaseInventoryAdjustment = {
|
export type BaseInventoryAdjustment = {
|
||||||
id: number;
|
id: number;
|
||||||
|
adj_number: string;
|
||||||
|
transaction_type: string;
|
||||||
|
transaction_subtype: string;
|
||||||
|
function_code: string;
|
||||||
|
qty: number;
|
||||||
|
price: number;
|
||||||
|
grand_total: number;
|
||||||
increase: number;
|
increase: number;
|
||||||
decrease: number;
|
decrease: number;
|
||||||
note: string;
|
notes: string;
|
||||||
|
location: Location;
|
||||||
|
project_flock: ProjectFlock;
|
||||||
product_warehouse_id: number;
|
product_warehouse_id: number;
|
||||||
product_warehouse: {
|
product_warehouse: ProductWarehouse;
|
||||||
id: number;
|
project_flock_kandang_id?: number;
|
||||||
quantity: number;
|
|
||||||
product_id: number;
|
|
||||||
warehouse_id: number;
|
|
||||||
product: Product;
|
|
||||||
warehouse: Warehouse;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InventoryAdjustment = BaseMetadata & BaseInventoryAdjustment;
|
export type InventoryAdjustment = BaseMetadata & BaseInventoryAdjustment;
|
||||||
|
|
||||||
export type CreateInventoryAdjustmentPayload = {
|
export type CreateInventoryAdjustmentPayload = {
|
||||||
|
project_flock_kandang_id: number;
|
||||||
product_id: number;
|
product_id: number;
|
||||||
warehouse_id: number;
|
transaction_subtype: string;
|
||||||
transaction_type: string;
|
qty: number;
|
||||||
quantity: number;
|
price: number;
|
||||||
note: string;
|
notes: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateInventoryAdjustmentPayload =
|
export type UpdateInventoryAdjustmentPayload =
|
||||||
|
|||||||
Reference in New Issue
Block a user