mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'feat/FE/US-335/production-data-report' into 'development'
[FEAT/FE][US#335] Production Data Report See merge request mbugroup/lti-web-client!106
This commit is contained in:
@@ -165,8 +165,6 @@ deploy:staging:
|
||||
environment:
|
||||
name: staging
|
||||
url: https://stg-lti-erp.mbugroup.id
|
||||
|
||||
|
||||
# ====== PRODUCTION ======
|
||||
# build:production:
|
||||
# <<: *build_template
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from '@/types/api/closing';
|
||||
import ClosingSapronakCalculationTabContent from '@/components/pages/closing/ClosingSapronakCalculationTabContent';
|
||||
import ClosingOverheadTabContent from '@/components/pages/closing/ClosingOverheadTabContent';
|
||||
import SalesReportTable from './sale/SalesReportTable';
|
||||
import SalesReportTable from '@/components/pages/closing/sale/SalesReportTable';
|
||||
|
||||
interface ClosingDetailProps {
|
||||
id: number;
|
||||
|
||||
@@ -33,7 +33,7 @@ const ClosingProductionDataTabContent = ({
|
||||
);
|
||||
}
|
||||
|
||||
const { purchase, sales, performance, variance } = productionData.data;
|
||||
const { purchase, sales, performance } = productionData.data;
|
||||
|
||||
// Helper for consistent row styling
|
||||
const DataRow = ({
|
||||
@@ -58,39 +58,6 @@ const ClosingProductionDataTabContent = ({
|
||||
</div>
|
||||
);
|
||||
|
||||
// Helper for rows with two values (e.g., Deplesi: Ekor & %)
|
||||
const DoubleDataRow = ({
|
||||
label,
|
||||
value1,
|
||||
unit1,
|
||||
value2,
|
||||
unit2,
|
||||
value1ClassName = 'font-bold text-gray-800',
|
||||
value2ClassName = 'font-bold text-blue-500',
|
||||
}: {
|
||||
label: string;
|
||||
value1: string | number;
|
||||
unit1: string;
|
||||
value2: string | number;
|
||||
unit2: string;
|
||||
value1ClassName?: string;
|
||||
value2ClassName?: string;
|
||||
}) => (
|
||||
<div className='flex justify-between items-center py-1'>
|
||||
<span className='text-gray-500 text-sm font-medium w-1/2'>{label}</span>
|
||||
<div className='flex gap-2 w-1/2 justify-end items-center'>
|
||||
<div className='flex gap-2 items-center min-w-[5rem] justify-end'>
|
||||
<span className={value1ClassName}>{value1}</span>
|
||||
<span className='text-gray-500 w-8 text-right'>{unit1}</span>
|
||||
</div>
|
||||
<div className='flex gap-2 items-center min-w-[4rem] justify-end ml-2'>
|
||||
<span className={value2ClassName}>{value2}</span>
|
||||
<span className='text-gray-500 w-4 text-right'>{unit2}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='w-full rounded-xl p-8 shadow-sm'>
|
||||
<h2 className='text-lg font-bold mb-8 text-gray-800'>Data Produksi</h2>
|
||||
@@ -121,17 +88,17 @@ const ClosingProductionDataTabContent = ({
|
||||
/>
|
||||
<DataRow
|
||||
label='Pakan Masuk'
|
||||
value={formatNumber(purchase.feed_in_kg)}
|
||||
value={formatNumber(purchase.feed_in)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Pakan Terpakai'
|
||||
value={formatNumber(purchase.feed_used_kg)}
|
||||
value={formatNumber(purchase.feed_used)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Pakan Terpakai per Ekor'
|
||||
value={formatNumber(purchase.feed_used_per_head_kg)}
|
||||
value={formatNumber(purchase.feed_used_per_head)}
|
||||
unit='Kg'
|
||||
/>
|
||||
</div>
|
||||
@@ -142,27 +109,61 @@ const ClosingProductionDataTabContent = ({
|
||||
<h3 className='font-bold text-gray-700 mb-4 text-base'>
|
||||
Penjualan
|
||||
</h3>
|
||||
<div className='space-y-1'>
|
||||
<DataRow
|
||||
label='Penjualan (Kg)'
|
||||
value={formatNumber(sales.sales_kg)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Penjualan (Ekor)'
|
||||
value={formatNumber(sales.sales_head)}
|
||||
unit='Ekor'
|
||||
/>
|
||||
<DataRow
|
||||
label='Bobot Rata-Rata'
|
||||
value={formatNumber(sales.average_weight_kg)}
|
||||
unit='Kg/Ekor'
|
||||
/>
|
||||
<DataRow
|
||||
label='Harga Jual Rata-Rata'
|
||||
value={formatNumber(sales.average_price_per_kg)}
|
||||
unit='Rupiah'
|
||||
/>
|
||||
<div className='space-y-4'>
|
||||
{/* Chicken Sales */}
|
||||
<div className='space-y-1'>
|
||||
<DataRow
|
||||
label='Penjualan (Ekor)'
|
||||
value={formatNumber(sales.chicken.sales_population)}
|
||||
unit='Ekor'
|
||||
/>
|
||||
<DataRow
|
||||
label='Penjualan (Kg)'
|
||||
value={formatNumber(sales.chicken.sales_weight)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Bobot Rata-Rata'
|
||||
value={formatNumber(sales.chicken.average_weight)}
|
||||
unit='Kg/Ekor'
|
||||
/>
|
||||
<DataRow
|
||||
label='Harga Jual Rata-Rata'
|
||||
value={formatNumber(
|
||||
sales.chicken.chicken_average_selling_price
|
||||
)}
|
||||
unit='Rupiah'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Egg Sales (if available) */}
|
||||
{sales.egg && (
|
||||
<>
|
||||
<div className='h-px bg-gray-100 my-2' />
|
||||
<div className='space-y-1'>
|
||||
<DataRow
|
||||
label='Telur (Butir)'
|
||||
value={formatNumber(sales.egg.egg_pieces)}
|
||||
unit='Butir'
|
||||
/>
|
||||
<DataRow
|
||||
label='Telur (Kg)'
|
||||
value={formatNumber(sales.egg.egg_mass_kg)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Berat Telur Rata-Rata'
|
||||
value={formatNumber(sales.egg.average_egg_weight_kg)}
|
||||
unit='Kg'
|
||||
/>
|
||||
<DataRow
|
||||
label='Harga Jual Telur Rata-Rata'
|
||||
value={formatNumber(sales.egg.egg_average_selling_price)}
|
||||
unit='Rupiah'
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -178,24 +179,20 @@ const ClosingProductionDataTabContent = ({
|
||||
Performance
|
||||
</h3>
|
||||
<div className='space-y-1'>
|
||||
<DoubleDataRow
|
||||
<DataRow
|
||||
label='Deplesi'
|
||||
value1={formatNumber(performance.depletion_head)}
|
||||
unit1='Ekor'
|
||||
value2={formatNumber(performance.depletion_percentage)}
|
||||
unit2='%'
|
||||
value={formatNumber(performance.depletion)}
|
||||
unit='Ekor'
|
||||
/>
|
||||
<DataRow
|
||||
label='Umur'
|
||||
value={formatNumber(performance.age_days)}
|
||||
value={formatNumber(performance.age_day)}
|
||||
unit='Hari'
|
||||
// Aligning 'Hari' with the first unit column of double row
|
||||
unitClassName='text-gray-500 w-8 text-right mr-[4.5rem]'
|
||||
/>
|
||||
<DataRow
|
||||
label='Mortalitas Std'
|
||||
value={formatNumber(performance.mortality_std)}
|
||||
unitClassName='hidden' // No unit shown in screenshot
|
||||
unitClassName='hidden'
|
||||
/>
|
||||
<DataRow
|
||||
label='Mortalitas Act'
|
||||
@@ -223,40 +220,10 @@ const ClosingProductionDataTabContent = ({
|
||||
unitClassName='hidden'
|
||||
/>
|
||||
<DataRow
|
||||
label='ADG'
|
||||
value={formatNumber(performance.adg)}
|
||||
label='AWG'
|
||||
value={formatNumber(performance.awg)}
|
||||
unit='Gr/Hari'
|
||||
/>
|
||||
<DataRow
|
||||
label='IP'
|
||||
value={formatNumber(performance.ip)}
|
||||
unitClassName='hidden'
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Variance Section (Pushed to bottom) */}
|
||||
<section className='mt-auto pt-4'>
|
||||
<h3 className='font-bold text-gray-700 mb-4 text-base'>Selisih</h3>
|
||||
<div className='space-y-1'>
|
||||
<DataRow
|
||||
label='Selisih Ayam'
|
||||
value={formatNumber(variance.variance_head)}
|
||||
unit='Ekor'
|
||||
valueClassName='font-bold text-red-500'
|
||||
/>
|
||||
<DataRow
|
||||
label='% Selisih Ayam'
|
||||
value={formatNumber(variance.variance_head_percentage)}
|
||||
unit='%'
|
||||
valueClassName='font-bold text-red-500'
|
||||
/>
|
||||
<DataRow
|
||||
label='Selisih Pakan'
|
||||
value={formatNumber(variance.variance_feed_kg)}
|
||||
unit='Kg'
|
||||
valueClassName='font-bold text-red-500'
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -83,6 +83,7 @@ import {
|
||||
ClosingIncomingSapronak,
|
||||
ClosingOutgoingSapronak,
|
||||
ClosingOverhead,
|
||||
ClosingProductionData,
|
||||
ClosingSapronakCalculation,
|
||||
} from '@/types/api/closing';
|
||||
import { CreatedUser, BaseApiResponse } from '@/types/api/api-general';
|
||||
@@ -1134,3 +1135,41 @@ export const dummyGetOverhead = async (
|
||||
data: dummyOverhead,
|
||||
};
|
||||
};
|
||||
|
||||
export const dummyClosingProductionData: ClosingProductionData = {
|
||||
purchase: {
|
||||
initial_population: 12000,
|
||||
claim_culling: 150,
|
||||
final_population: 11850,
|
||||
feed_in: 24000,
|
||||
feed_used: 22500,
|
||||
feed_used_per_head: 1.9,
|
||||
},
|
||||
|
||||
sales: {
|
||||
chicken: {
|
||||
sales_population: 10500,
|
||||
sales_weight: 21000,
|
||||
average_weight: 2.0,
|
||||
chicken_average_selling_price: 28500,
|
||||
},
|
||||
egg: {
|
||||
egg_pieces: 185000,
|
||||
egg_mass_kg: 9250,
|
||||
average_egg_weight_kg: 0.05,
|
||||
egg_average_selling_price: 1800,
|
||||
},
|
||||
},
|
||||
|
||||
performance: {
|
||||
depletion: 150,
|
||||
age_day: 35,
|
||||
mortality_std: 3.5,
|
||||
mortality_act: 4.2,
|
||||
deff_mortality: 0.7,
|
||||
fcr_std: 1.6,
|
||||
fcr_act: 1.72,
|
||||
deff_fcr: 0.12,
|
||||
awg: 60,
|
||||
},
|
||||
};
|
||||
|
||||
+12
-54
@@ -6,11 +6,13 @@ import {
|
||||
ClosingGeneralInformation,
|
||||
ClosingIncomingSapronak,
|
||||
ClosingOutgoingSapronak,
|
||||
ClosingProductionData,
|
||||
ClosingOverhead,
|
||||
ClosingSapronakCalculation,
|
||||
ClosingProductionData,
|
||||
} from '@/types/api/closing';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
|
||||
// TODO: delete these dummy data later
|
||||
import {
|
||||
dummyGetAllFetcher,
|
||||
dummyGetSingle,
|
||||
@@ -19,55 +21,12 @@ import {
|
||||
dummyGetGeneralInfo,
|
||||
dummyGetPerhitunganSapronak,
|
||||
dummyGetOverhead,
|
||||
dummyClosingProductionData,
|
||||
} from '@/dummy/closing.dummy';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { ClosingSales } from '@/types/api/closing';
|
||||
import { sleep } from '@/lib/helper';
|
||||
|
||||
export const dummyClosingProductionResponse: BaseApiResponse<ClosingProductionData> =
|
||||
{
|
||||
code: 200,
|
||||
status: 'success',
|
||||
message: 'Closing production data fetched successfully',
|
||||
data: {
|
||||
purchase: {
|
||||
initial_population: 10_000,
|
||||
claim_culling: 150,
|
||||
final_population: 9_850,
|
||||
feed_in_kg: 18_000,
|
||||
feed_used_kg: 17_200,
|
||||
feed_used_per_head_kg: 1.75,
|
||||
},
|
||||
|
||||
sales: {
|
||||
sales_kg: 18_500,
|
||||
sales_head: 9_600,
|
||||
average_weight_kg: 1.93,
|
||||
average_price_per_kg: 20_500,
|
||||
},
|
||||
|
||||
performance: {
|
||||
depletion_head: 400,
|
||||
depletion_percentage: 4,
|
||||
age_days: 35,
|
||||
mortality_std: 3.5,
|
||||
mortality_act: 4,
|
||||
deff_mortality: 0.5,
|
||||
fcr_std: 1.6,
|
||||
fcr_act: 1.72,
|
||||
deff_fcr: 0.12,
|
||||
adg: 55,
|
||||
ip: 320,
|
||||
},
|
||||
|
||||
variance: {
|
||||
variance_head: -250,
|
||||
variance_head_percentage: -2.5,
|
||||
variance_feed_kg: -800,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
constructor(basePath: string) {
|
||||
super(basePath);
|
||||
@@ -180,17 +139,16 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
}
|
||||
}
|
||||
|
||||
async getProductionData(id: number) {
|
||||
async getProductionData(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingProductionData> | undefined> {
|
||||
try {
|
||||
// const getProductionDataPath = `${this.basePath}/${id}/production-data`;
|
||||
// const getProductionDataRes = await httpClient<
|
||||
// BaseApiResponse<ClosingProductionData>
|
||||
// >(getProductionDataPath);
|
||||
const getProductionDataPath = `${this.basePath}/${id}/production-data`;
|
||||
const getProductionDataRes = await httpClient<
|
||||
BaseApiResponse<ClosingProductionData>
|
||||
>(getProductionDataPath);
|
||||
|
||||
// return getProductionDataRes;
|
||||
|
||||
await sleep(1000);
|
||||
return dummyClosingProductionResponse;
|
||||
return getProductionDataRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ClosingProductionData>>(error)) {
|
||||
return error.response?.data;
|
||||
|
||||
Vendored
+48
-17
@@ -23,6 +23,33 @@ export type BaseSales = {
|
||||
payment_status: string;
|
||||
};
|
||||
|
||||
export type BaseClosingSales = {
|
||||
project_type: string;
|
||||
flock_id: number;
|
||||
period: number;
|
||||
sales: BaseSales[];
|
||||
};
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
import { Product } from '@type/api/master-data/product';
|
||||
import { Customer } from '@type/api/master-data/customer';
|
||||
import { BaseMetadata } from '@/types/api/api-general';
|
||||
|
||||
export type BaseSales = {
|
||||
id: number;
|
||||
realization_date: string;
|
||||
age: number;
|
||||
do_number: string;
|
||||
product: Product;
|
||||
customer: Customer;
|
||||
qty: number;
|
||||
weight: number;
|
||||
avg_weight: number;
|
||||
price: number;
|
||||
total_price: number;
|
||||
kandang: Kandang;
|
||||
payment_status: string;
|
||||
};
|
||||
|
||||
export type BaseClosingSales = {
|
||||
project_type: string;
|
||||
flock_id: number;
|
||||
@@ -84,33 +111,36 @@ export type ClosingProductionData = {
|
||||
initial_population: number;
|
||||
claim_culling: number;
|
||||
final_population: number;
|
||||
feed_in_kg: number;
|
||||
feed_used_kg: number;
|
||||
feed_used_per_head_kg: number;
|
||||
feed_in: number;
|
||||
feed_used: number;
|
||||
feed_used_per_head: number;
|
||||
};
|
||||
|
||||
sales: {
|
||||
sales_kg: number;
|
||||
sales_head: number;
|
||||
average_weight_kg: number;
|
||||
average_price_per_kg: number;
|
||||
chicken: {
|
||||
sales_population: number;
|
||||
sales_weight: number;
|
||||
average_weight: number;
|
||||
chicken_average_selling_price: number;
|
||||
};
|
||||
egg?: {
|
||||
egg_pieces: number;
|
||||
egg_mass_kg: number;
|
||||
average_egg_weight_kg: number;
|
||||
egg_average_selling_price: number;
|
||||
};
|
||||
};
|
||||
|
||||
performance: {
|
||||
depletion_head: number;
|
||||
depletion_percentage: number;
|
||||
age_days: number;
|
||||
depletion: number;
|
||||
age_day: number;
|
||||
mortality_std: number;
|
||||
mortality_act: number;
|
||||
deff_mortality: number;
|
||||
fcr_std: number;
|
||||
fcr_act: number;
|
||||
deff_fcr: number;
|
||||
adg: number;
|
||||
ip: number;
|
||||
};
|
||||
variance: {
|
||||
variance_head: number;
|
||||
variance_head_percentage: number;
|
||||
variance_feed_kg: number;
|
||||
awg: number;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -176,4 +206,5 @@ export type OverheadTotal = {
|
||||
actual_total_amount: number;
|
||||
cost_per_bird: number;
|
||||
};
|
||||
|
||||
export type ClosingSales = BaseMetadata & BaseClosingSales;
|
||||
|
||||
Reference in New Issue
Block a user