mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
187 lines
5.4 KiB
Go
187 lines
5.4 KiB
Go
package dto
|
|
|
|
// New Closing Keuangan Response DTO Structure
|
|
|
|
// Base metrics - digunakan di banyak tempat
|
|
type NewFinancialMetrics struct {
|
|
RpPerBird float64 `json:"rp_per_bird"`
|
|
RpPerKg float64 `json:"rp_per_kg"`
|
|
Amount float64 `json:"amount"`
|
|
}
|
|
|
|
// Comparison untuk Budgeting vs Realization
|
|
type NewComparison struct {
|
|
Budgeting NewFinancialMetrics `json:"budgeting"`
|
|
Realization NewFinancialMetrics `json:"realization"`
|
|
}
|
|
|
|
// HPP Purchase Section
|
|
type HppPurchase struct {
|
|
Pakan NewComparison `json:"pakan"`
|
|
OVK NewComparison `json:"OVK"`
|
|
DOC NewComparison `json:"DOC"`
|
|
Depresiasi NewComparison `json:"Depresiasi"`
|
|
}
|
|
|
|
// HPP Overhead Section
|
|
type HppOverhead struct {
|
|
Overhead NewComparison `json:"overhead"`
|
|
Ekspedisi NewComparison `json:"ekspedisi"`
|
|
}
|
|
|
|
// Summary HPP
|
|
type NewSummaryHpp struct {
|
|
Label string `json:"label"`
|
|
Budgeting NewFinancialMetrics `json:"budgeting"`
|
|
Realization NewFinancialMetrics `json:"realization"`
|
|
EggBudgeting *NewFinancialMetrics `json:"egg_budgeting,omitempty"`
|
|
EggRealization *NewFinancialMetrics `json:"egg_realization,omitempty"`
|
|
}
|
|
|
|
// HPP wrapper
|
|
type NewHpp struct {
|
|
HppPurchase HppPurchase `json:"hpp_purchase"`
|
|
HppOverhead HppOverhead `json:"hpp_overhead"`
|
|
SummaryHpp NewSummaryHpp `json:"summary_hpp"`
|
|
}
|
|
|
|
// Purchase Cost (dengan type field, embedded NewFinancialMetrics)
|
|
type PurchaseCost struct {
|
|
Type string `json:"type"`
|
|
NewFinancialMetrics
|
|
}
|
|
|
|
// PL Summary
|
|
type PLSummary struct {
|
|
GrossProfit NewFinancialMetrics `json:"gross_profit"`
|
|
SubTotal NewFinancialMetrics `json:"sub_total"`
|
|
NetProfit NewFinancialMetrics `json:"net_profit"`
|
|
}
|
|
|
|
// Profit Loss wrapper
|
|
type NewProfitLoss struct {
|
|
PenjualanTelur NewFinancialMetrics `json:"penjualan_telur"`
|
|
PurchaseCost PurchaseCost `json:"purchase_cost"`
|
|
Overhead NewFinancialMetrics `json:"overhead"`
|
|
Ekspedisi NewFinancialMetrics `json:"ekspedisi"`
|
|
Summary PLSummary `json:"summary"`
|
|
}
|
|
|
|
// Main Data structure
|
|
type NewClosingKeuanganData struct {
|
|
Hpp NewHpp `json:"hpp"`
|
|
ProfitLoss NewProfitLoss `json:"profit_loss"`
|
|
}
|
|
|
|
// Full Response DTO
|
|
type NewClosingKeuanganResponse struct {
|
|
Code int `json:"code"`
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
Data NewClosingKeuanganData `json:"data"`
|
|
}
|
|
|
|
// === MAPPER FUNCTIONS ===
|
|
|
|
// ToNewFinancialMetrics creates a new financial metrics
|
|
func ToNewFinancialMetrics(rpPerBird, rpPerKg, amount float64) NewFinancialMetrics {
|
|
return NewFinancialMetrics{
|
|
RpPerBird: rpPerBird,
|
|
RpPerKg: rpPerKg,
|
|
Amount: amount,
|
|
}
|
|
}
|
|
|
|
// ToNewComparison creates a new budgeting vs realization comparison
|
|
func ToNewComparison(budgetingRpPerBird, budgetingRpPerKg, budgetingAmount, realizationRpPerBird, realizationRpPerKg, realizationAmount float64) NewComparison {
|
|
return NewComparison{
|
|
Budgeting: ToNewFinancialMetrics(budgetingRpPerBird, budgetingRpPerKg, budgetingAmount),
|
|
Realization: ToNewFinancialMetrics(realizationRpPerBird, realizationRpPerKg, realizationAmount),
|
|
}
|
|
}
|
|
|
|
// ToHppPurchase creates HPP purchase section
|
|
func ToHppPurchase(pakan, oVK, dOC, depresiasi NewComparison) HppPurchase {
|
|
return HppPurchase{
|
|
Pakan: pakan,
|
|
OVK: oVK,
|
|
DOC: dOC,
|
|
Depresiasi: depresiasi,
|
|
}
|
|
}
|
|
|
|
// ToHppOverhead creates HPP overhead section
|
|
func ToHppOverhead(overhead, ekspedisi NewComparison) HppOverhead {
|
|
return HppOverhead{
|
|
Overhead: overhead,
|
|
Ekspedisi: ekspedisi,
|
|
}
|
|
}
|
|
|
|
// ToNewSummaryHpp creates HPP summary
|
|
func ToNewSummaryHpp(label string, budgeting, realization NewFinancialMetrics, eggBudgeting, eggRealization *NewFinancialMetrics) NewSummaryHpp {
|
|
return NewSummaryHpp{
|
|
Label: label,
|
|
Budgeting: budgeting,
|
|
Realization: realization,
|
|
EggBudgeting: eggBudgeting,
|
|
EggRealization: eggRealization,
|
|
}
|
|
}
|
|
|
|
// ToNewHpp creates complete HPP section
|
|
func ToNewHpp(hppPurchase HppPurchase, hppOverhead HppOverhead, summaryHpp NewSummaryHpp) NewHpp {
|
|
return NewHpp{
|
|
HppPurchase: hppPurchase,
|
|
HppOverhead: hppOverhead,
|
|
SummaryHpp: summaryHpp,
|
|
}
|
|
}
|
|
|
|
// ToPurchaseCost creates purchase cost item
|
|
func ToPurchaseCost(costType string, metrics NewFinancialMetrics) PurchaseCost {
|
|
return PurchaseCost{
|
|
Type: costType,
|
|
NewFinancialMetrics: metrics,
|
|
}
|
|
}
|
|
|
|
// ToPLSummary creates profit loss summary
|
|
func ToPLSummary(grossProfit, subTotal, netProfit NewFinancialMetrics) PLSummary {
|
|
return PLSummary{
|
|
GrossProfit: grossProfit,
|
|
SubTotal: subTotal,
|
|
NetProfit: netProfit,
|
|
}
|
|
}
|
|
|
|
// ToNewProfitLoss creates complete profit loss section
|
|
func ToNewProfitLoss(penjualanTelur, overhead, ekspedisi NewFinancialMetrics, purchaseCost PurchaseCost, summary PLSummary) NewProfitLoss {
|
|
return NewProfitLoss{
|
|
PenjualanTelur: penjualanTelur,
|
|
PurchaseCost: purchaseCost,
|
|
Overhead: overhead,
|
|
Ekspedisi: ekspedisi,
|
|
Summary: summary,
|
|
}
|
|
}
|
|
|
|
// ToNewClosingKeuanganData creates complete closing keuangan data
|
|
func ToNewClosingKeuanganData(hpp NewHpp, profitLoss NewProfitLoss) NewClosingKeuanganData {
|
|
return NewClosingKeuanganData{
|
|
Hpp: hpp,
|
|
ProfitLoss: profitLoss,
|
|
}
|
|
}
|
|
|
|
// ToSuccessNewClosingKeuanganResponse creates success response shortcut
|
|
func ToSuccessNewClosingKeuanganResponse(data NewClosingKeuanganData) NewClosingKeuanganResponse {
|
|
return NewClosingKeuanganResponse{
|
|
Code: 200,
|
|
Status: "success",
|
|
Message: "Get closing keuangan successfully",
|
|
Data: data,
|
|
}
|
|
}
|
|
|