mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 06:45:46 +00:00
389 lines
9.5 KiB
TypeScript
389 lines
9.5 KiB
TypeScript
import { format } from 'date-fns';
|
|
import { Area } from '@/types/api/master-data/area';
|
|
import { Location } from '@/types/api/master-data/location';
|
|
import { Kandang } from '@/types/api/master-data/kandang';
|
|
import { Warehouse } from '@/types/api/master-data/warehouse';
|
|
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
|
import {
|
|
BaseMarketing,
|
|
Marketing,
|
|
BaseSalesOrder,
|
|
BaseDeliveryOrder,
|
|
BaseDelivery,
|
|
} from '@/types/api/marketing/marketing';
|
|
import {
|
|
CreatedUser,
|
|
BaseApproval,
|
|
BaseMetadata,
|
|
} from '@/types/api/api-general';
|
|
import { Product } from '@/types/api/master-data/product';
|
|
import { Customer } from '@/types/api/master-data/customer';
|
|
import { Uom } from '@/types/api/master-data/uom';
|
|
import { ProductCategory } from '@/types/api/master-data/product-category';
|
|
import { Supplier } from '@/types/api/master-data/supplier';
|
|
|
|
// Waktu saat ini untuk created_at/updated_at
|
|
const now = format(new Date(), 'yyyy-MM-dd HH:mm:ss');
|
|
const today = format(new Date(), 'yyyy-MM-dd');
|
|
const tomorrow = format(
|
|
new Date().setDate(new Date().getDate() + 1),
|
|
'yyyy-MM-dd'
|
|
);
|
|
|
|
// ======================
|
|
// 👤 Created User & Helper Data
|
|
// ======================
|
|
export const createdUser: CreatedUser = {
|
|
id: 1,
|
|
id_user: 1,
|
|
email: 'admin@example.com',
|
|
name: 'Admin Utama',
|
|
};
|
|
|
|
const dummyProductBase: Product = {
|
|
id: 101,
|
|
name: 'Pakan Ayam Premium',
|
|
brand: 'Brand Hebat',
|
|
sku: 'PAK-001',
|
|
product_price: 15000,
|
|
selling_price: 18000,
|
|
tax: 0.1,
|
|
expiry_period: 365,
|
|
uom: { id: 1, name: 'Sak' } as Uom,
|
|
product_category: { id: 1, name: 'Pakan' } as ProductCategory,
|
|
suppliers: [{ id: 1, name: 'Supplier A' } as Supplier],
|
|
flags: ['PAKAN'],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
};
|
|
|
|
// ======================
|
|
// 📍 Area Dummy
|
|
// ======================
|
|
export const dummyAreas: Area[] = [
|
|
{
|
|
id: 1,
|
|
name: 'Bandung Barat',
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'Cimahi Utara',
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
];
|
|
|
|
// ======================
|
|
// 🏢 Location Dummy
|
|
// ======================
|
|
export const dummyLocations: Location[] = [
|
|
{
|
|
id: 1,
|
|
name: 'Gudang A',
|
|
address: 'Jl. Sukajadi No. 12',
|
|
area: dummyAreas[0],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'Gudang B',
|
|
address: 'Jl. Setiabudi No. 45',
|
|
area: dummyAreas[1],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
];
|
|
|
|
// ======================
|
|
// 🐔 Kandang Dummy
|
|
// ======================
|
|
export const dummyKandangs: Kandang[] = [
|
|
{
|
|
id: 1,
|
|
name: 'Kandang Ayam Layer 1',
|
|
status: 'AKTIF',
|
|
capacity: 500,
|
|
location: dummyLocations[0],
|
|
pic: createdUser,
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'Kandang Ayam Broiler 2',
|
|
status: 'NONAKTIF',
|
|
capacity: 300,
|
|
location: dummyLocations[1],
|
|
pic: createdUser,
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
];
|
|
|
|
// ======================
|
|
// 🏭 Warehouse Dummy
|
|
// ======================
|
|
export const dummyWarehouses: Warehouse[] = [
|
|
{
|
|
id: 1,
|
|
type: 'AREA',
|
|
name: 'Gudang Wilayah Bandung Barat',
|
|
area: dummyAreas[0],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Warehouse,
|
|
{
|
|
id: 2,
|
|
type: 'LOKASI',
|
|
name: 'Gudang Produksi Sukajadi',
|
|
area: dummyAreas[0],
|
|
location: { ...dummyLocations[0], area: dummyAreas[0] },
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Warehouse,
|
|
{
|
|
id: 3,
|
|
type: 'KANDANG',
|
|
name: 'Gudang Kandang Layer 1',
|
|
area: dummyAreas[0],
|
|
location: { ...dummyLocations[0], area: dummyAreas[0] },
|
|
kandang: {
|
|
...dummyKandangs[0],
|
|
location: dummyLocations[0],
|
|
pic: createdUser,
|
|
},
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Warehouse,
|
|
];
|
|
|
|
// ======================
|
|
// 📦 Product Warehouse Dummy
|
|
// ======================
|
|
export const dummyProductWarehouses: ProductWarehouse[] = [
|
|
{
|
|
id: 1,
|
|
product_id: 101,
|
|
warehouse_id: 1,
|
|
quantity: 1000,
|
|
product: dummyProductBase,
|
|
warehouse: dummyWarehouses[0],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
{
|
|
id: 2,
|
|
product_id: 102,
|
|
warehouse_id: 2,
|
|
quantity: 500,
|
|
product: {
|
|
...dummyProductBase,
|
|
id: 102,
|
|
name: 'Vitamin Ayam Super',
|
|
sku: 'VIT-002',
|
|
flags: ['VITAMIN'],
|
|
selling_price: 25000,
|
|
},
|
|
warehouse: dummyWarehouses[1],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
},
|
|
];
|
|
|
|
// ======================
|
|
// 💼 Marketing Dummy
|
|
// ======================
|
|
|
|
// Helper untuk Sales Order (SO) Item
|
|
const soItem1: BaseSalesOrder = {
|
|
vehicle_number: 'B 1234 ABC',
|
|
id: 101,
|
|
marketing_id: 1,
|
|
product_warehouse_id: 1,
|
|
qty: 100,
|
|
unit_price: 18000, // Harga jual
|
|
avg_weight: 1.0,
|
|
total_weight: 100 * 1.0,
|
|
total_price: 100 * 18000,
|
|
product_warehouse: dummyProductWarehouses[0] as ProductWarehouse,
|
|
};
|
|
const soItem2: BaseSalesOrder = {
|
|
vehicle_number: 'D 5678 EFG',
|
|
id: 102,
|
|
marketing_id: 2,
|
|
product_warehouse_id: 2,
|
|
qty: 50,
|
|
unit_price: 25000,
|
|
avg_weight: 0.5,
|
|
total_weight: 50 * 0.5,
|
|
total_price: 50 * 25000,
|
|
product_warehouse: dummyProductWarehouses[1] as ProductWarehouse,
|
|
};
|
|
|
|
// Helper untuk Delivery Item (DO) Detail
|
|
const doDelivery1: BaseDelivery[] = [
|
|
{
|
|
product_warehouse: dummyProductWarehouses[0] as ProductWarehouse,
|
|
qty: soItem1.qty,
|
|
unit_price: soItem1.unit_price,
|
|
total_weight: soItem1.total_weight,
|
|
avg_weight: soItem1.avg_weight,
|
|
total_price: soItem1.total_price,
|
|
vehicle_number: 'B 1234 ABC',
|
|
},
|
|
];
|
|
|
|
const doDelivery2: BaseDelivery[] = [
|
|
{
|
|
product_warehouse: dummyProductWarehouses[1] as ProductWarehouse,
|
|
qty: soItem2.qty,
|
|
unit_price: soItem2.unit_price,
|
|
total_weight: soItem2.total_weight,
|
|
avg_weight: soItem2.avg_weight,
|
|
total_price: soItem2.total_price,
|
|
vehicle_number: 'D 5678 EFG',
|
|
},
|
|
];
|
|
|
|
// Helper untuk Delivery Order (DO) Header
|
|
const deliveryOrder1: BaseDeliveryOrder[] = [
|
|
{
|
|
id: 1,
|
|
marketing_id: 3,
|
|
do_number: 'DO-003-2025',
|
|
delivery_date: tomorrow,
|
|
warehouse: dummyWarehouses[0],
|
|
deliveries: doDelivery1,
|
|
},
|
|
];
|
|
|
|
export const dummyMarketings: Marketing[] = [
|
|
// 1. Pengajuan Order (Langkah Pertama/Awal)
|
|
{
|
|
id: 1,
|
|
status: 'DRAFT',
|
|
// name: 'SO-001-2025', // `name` is not part of BaseMarketing
|
|
so_number: 'SO-001-2025',
|
|
so_date: today,
|
|
customer: {
|
|
id: 1,
|
|
name: 'PT Maju Jaya',
|
|
pic_id: 1,
|
|
pic: createdUser,
|
|
type: 'Distributor',
|
|
address: 'Jl. Merdeka No. 1',
|
|
phone: '081212121212',
|
|
email: 'contact@majujaya.com',
|
|
account_number: '1234567890',
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Customer,
|
|
sales_person: createdUser,
|
|
notes: 'Pengajuan Order Awal, menunggu persetujuan harga.',
|
|
latest_approval: {
|
|
step_number: 1,
|
|
step_name: 'Pengajuan Order',
|
|
action: 'CREATED',
|
|
action_by: createdUser,
|
|
action_at: now,
|
|
} as BaseApproval,
|
|
sales_order: [soItem1],
|
|
delivery_order: [],
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Marketing,
|
|
|
|
// 2. Sales Order (Disetujui dan Siap DO)
|
|
{
|
|
id: 2,
|
|
status: 'APPROVED',
|
|
// name: 'SO-002-2025', // `name` is not part of BaseMarketing
|
|
so_number: 'SO-002-2025',
|
|
so_date: today,
|
|
customer: {
|
|
id: 2,
|
|
name: 'CV Sumber Sehat',
|
|
pic_id: 2,
|
|
pic: createdUser,
|
|
type: 'Retail',
|
|
address: 'Jl. Cihampelas No. 5',
|
|
phone: '082222222222',
|
|
email: 'info@sumbersehat.com',
|
|
account_number: '9876543210',
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Customer,
|
|
sales_person: createdUser,
|
|
notes: 'Sales Order telah disetujui oleh Supervisor.',
|
|
latest_approval: {
|
|
id: 2,
|
|
step_number: 2,
|
|
step_name: 'Sales Order',
|
|
action: 'APPROVED',
|
|
action_by: createdUser,
|
|
action_at: now,
|
|
} as BaseApproval,
|
|
sales_order: [soItem2],
|
|
delivery_order: [], // Belum ada pengiriman (DO) yang dibuat
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Marketing,
|
|
|
|
// 3. Delivery Order (Proses Pengiriman telah dibuat)
|
|
{
|
|
id: 3,
|
|
status: 'DELIVERED', // Asumsi status DELIVERED berarti DO sudah selesai/terbuat
|
|
// name: 'SO-003-2025', // `name` is not part of BaseMarketing
|
|
so_number: 'SO-003-2025',
|
|
so_date: today,
|
|
customer: {
|
|
id: 3,
|
|
name: 'UD Ternak Sejahtera',
|
|
pic_id: 3,
|
|
pic: createdUser,
|
|
type: 'Reseller',
|
|
address: 'Jl. Pasteur No. 88',
|
|
phone: '083333333333',
|
|
email: 'halo@ternaksejahtera.com',
|
|
account_number: '1122334455',
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Customer,
|
|
sales_person: createdUser,
|
|
notes: 'Pengiriman barang telah berhasil dilakukan.',
|
|
latest_approval: {
|
|
id: 3,
|
|
step_number: 3,
|
|
step_name: 'Delivery Order',
|
|
action: 'COMPLETED',
|
|
action_by: createdUser,
|
|
action_at: now,
|
|
} as BaseApproval,
|
|
sales_order: [soItem1, soItem2],
|
|
delivery_order: deliveryOrder1, // DO sudah terbuat
|
|
created_user: createdUser,
|
|
created_at: now,
|
|
updated_at: now,
|
|
} as Marketing,
|
|
];
|