mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
186 lines
5.4 KiB
Go
186 lines
5.4 KiB
Go
package dto
|
|
|
|
// === CLOSING KEUANGAN CODES ===
|
|
|
|
// Closing HPP Codes
|
|
type ClosingHPPCode string
|
|
|
|
const (
|
|
HPPCodePakan ClosingHPPCode = "PAKAN"
|
|
HPPCodeOVK ClosingHPPCode = "OVK"
|
|
HPPCodeDOC ClosingHPPCode = "DOC"
|
|
HPPCodeDepresiasi ClosingHPPCode = "DEPRESIASI"
|
|
HPPCodeOverhead ClosingHPPCode = "OVERHEAD"
|
|
HPPCodeEkspedisi ClosingHPPCode = "EKSPEDISI"
|
|
)
|
|
|
|
// Closing Profit Loss Codes
|
|
type ClosingProfitLossCode string
|
|
|
|
const (
|
|
PLCodeSales ClosingProfitLossCode = "SALES"
|
|
PLCodeSapronak ClosingProfitLossCode = "SAPRONAK"
|
|
PLCodeOverhead ClosingProfitLossCode = "OVERHEAD"
|
|
PLCodeEkspedisi ClosingProfitLossCode = "EKSPEDISI"
|
|
)
|
|
|
|
// === NEW CLOSING KEUANGAN DTO ===
|
|
|
|
// FinancialMetrics represents financial metrics with per unit and total amounts
|
|
type FinancialMetrics struct {
|
|
RpPerBird float64 `json:"rp_per_bird"`
|
|
RpPerKg float64 `json:"rp_per_kg"`
|
|
Amount float64 `json:"amount"`
|
|
}
|
|
|
|
// HPPItem represents an item in HPP section
|
|
type HPPItem struct {
|
|
ID uint `json:"id"`
|
|
Category string `json:"category"` // "purchase" or "overhead"
|
|
Code string `json:"code"` // "PAKAN", "OVK", "DOC", "EKSPEDISI"
|
|
Label string `json:"label"`
|
|
Budgeting FinancialMetrics `json:"budgeting"`
|
|
Realization FinancialMetrics `json:"realization"`
|
|
}
|
|
|
|
// HPPSummary represents summary for HPP section
|
|
type HPPSummary struct {
|
|
Label string `json:"label"`
|
|
Budgeting FinancialMetrics `json:"budgeting"`
|
|
Realization FinancialMetrics `json:"realization"`
|
|
EggBudgeting *FinancialMetrics `json:"egg_budgeting,omitempty"`
|
|
EggRealization *FinancialMetrics `json:"egg_realization,omitempty"`
|
|
}
|
|
|
|
// HPPSection represents HPP data section
|
|
type HPPSection struct {
|
|
Items []HPPItem `json:"items"`
|
|
Summary HPPSummary `json:"summary"`
|
|
}
|
|
|
|
// ProfitLossItem represents an item in Profit & Loss section
|
|
type ProfitLossItem struct {
|
|
Code string `json:"code"` // "SALES", "PURCHASE_DOC", "OVERHEAD", "EKSPEDISI"
|
|
Label string `json:"label"`
|
|
Type string `json:"type"` // "income", "purchase", "overhead"
|
|
RpPerBird float64 `json:"rp_per_bird"`
|
|
RpPerKg float64 `json:"rp_per_kg"`
|
|
Amount float64 `json:"amount"`
|
|
}
|
|
|
|
// ProfitLossSummary represents summary for Profit & Loss section
|
|
type ProfitLossSummary struct {
|
|
GrossProfit FinancialMetrics `json:"gross_profit"`
|
|
SubTotal FinancialMetrics `json:"sub_total"`
|
|
NetProfit FinancialMetrics `json:"net_profit"`
|
|
}
|
|
|
|
// ProfitLossSection represents Profit & Loss data section
|
|
type ProfitLossSection struct {
|
|
Items []ProfitLossItem `json:"items"`
|
|
Summary ProfitLossSummary `json:"summary"`
|
|
}
|
|
|
|
// ClosingKeuanganData represents the main data structure
|
|
type ClosingKeuanganData struct {
|
|
HPP HPPSection `json:"hpp"`
|
|
ProfitLoss ProfitLossSection `json:"profit_loss"`
|
|
}
|
|
|
|
// ClosingKeuanganResponse represents the full API response
|
|
type ClosingKeuanganResponse struct {
|
|
Code int `json:"code"`
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
Data ClosingKeuanganData `json:"data"`
|
|
}
|
|
|
|
// === MAPPER FUNCTIONS ===
|
|
|
|
// ToFinancialMetrics creates FinancialMetrics from values
|
|
func ToFinancialMetrics(rpPerBird, rpPerKg, amount float64) FinancialMetrics {
|
|
return FinancialMetrics{
|
|
RpPerBird: rpPerBird,
|
|
RpPerKg: rpPerKg,
|
|
Amount: amount,
|
|
}
|
|
}
|
|
|
|
// ToHPPItem creates HPP item
|
|
func ToHPPItem(id uint, category, code, label string, budgeting, realization FinancialMetrics) HPPItem {
|
|
return HPPItem{
|
|
ID: id,
|
|
Category: category,
|
|
Code: code,
|
|
Label: label,
|
|
Budgeting: budgeting,
|
|
Realization: realization,
|
|
}
|
|
}
|
|
|
|
// ToHPPSummary creates HPP summary
|
|
func ToHPPSummary(label string, budgeting, realization FinancialMetrics, eggBudgeting, eggRealization *FinancialMetrics) HPPSummary {
|
|
return HPPSummary{
|
|
Label: label,
|
|
Budgeting: budgeting,
|
|
Realization: realization,
|
|
EggBudgeting: eggBudgeting,
|
|
EggRealization: eggRealization,
|
|
}
|
|
}
|
|
|
|
// ToHPPSection creates HPP section
|
|
func ToHPPSection(items []HPPItem, summary HPPSummary) HPPSection {
|
|
return HPPSection{
|
|
Items: items,
|
|
Summary: summary,
|
|
}
|
|
}
|
|
|
|
// ToProfitLossItem creates Profit & Loss item
|
|
func ToProfitLossItem(code, label, itemType string, rpPerBird, rpPerKg, amount float64) ProfitLossItem {
|
|
return ProfitLossItem{
|
|
Code: code,
|
|
Label: label,
|
|
Type: itemType,
|
|
RpPerBird: rpPerBird,
|
|
RpPerKg: rpPerKg,
|
|
Amount: amount,
|
|
}
|
|
}
|
|
|
|
// ToProfitLossSummary creates Profit & Loss summary
|
|
func ToProfitLossSummary(grossProfit, subTotal, netProfit FinancialMetrics) ProfitLossSummary {
|
|
return ProfitLossSummary{
|
|
GrossProfit: grossProfit,
|
|
SubTotal: subTotal,
|
|
NetProfit: netProfit,
|
|
}
|
|
}
|
|
|
|
// ToProfitLossSection creates Profit & Loss section
|
|
func ToProfitLossSection(items []ProfitLossItem, summary ProfitLossSummary) ProfitLossSection {
|
|
return ProfitLossSection{
|
|
Items: items,
|
|
Summary: summary,
|
|
}
|
|
}
|
|
|
|
// ToClosingKeuanganData creates complete closing keuangan data
|
|
func ToClosingKeuanganData(hpp HPPSection, profitLoss ProfitLossSection) ClosingKeuanganData {
|
|
return ClosingKeuanganData{
|
|
HPP: hpp,
|
|
ProfitLoss: profitLoss,
|
|
}
|
|
}
|
|
|
|
// ToSuccessClosingKeuanganResponse creates success response
|
|
func ToSuccessClosingKeuanganResponse(data ClosingKeuanganData) ClosingKeuanganResponse {
|
|
return ClosingKeuanganResponse{
|
|
Code: 200,
|
|
Status: "success",
|
|
Message: "Get closing keuangan successfully",
|
|
Data: data,
|
|
}
|
|
}
|