mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-22 22:35:43 +00:00
feat[BE]: enhance expense management with location and project flock integration, including updates to migrations, entities, services, and validations
This commit is contained in:
@@ -76,7 +76,6 @@ type ExpenseRealizationDTO struct {
|
||||
|
||||
type KandangGroupDTO struct {
|
||||
Id uint64 `json:"id"`
|
||||
KandangId uint64 `json:"kandang_id"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Pengajuans []ExpenseNonstockDTO `json:"pengajuans,omitempty"`
|
||||
Realisasi []ExpenseRealizationDTO `json:"realisasi,omitempty"`
|
||||
@@ -178,7 +177,6 @@ func ToExpenseDetailDTO(e *entity.Expense) ExpenseDetailDTO {
|
||||
var pengajuans []ExpenseNonstockDTO
|
||||
var realisasi []ExpenseRealizationDTO
|
||||
|
||||
// Map documents from Document service
|
||||
for _, doc := range e.Documents {
|
||||
documents = append(documents, DocumentDTO{
|
||||
ID: uint64(doc.Id),
|
||||
@@ -186,7 +184,6 @@ func ToExpenseDetailDTO(e *entity.Expense) ExpenseDetailDTO {
|
||||
})
|
||||
}
|
||||
|
||||
// Map realization documents from Document service
|
||||
for _, doc := range e.RealizationDocuments {
|
||||
realizationDocs = append(realizationDocs, DocumentDTO{
|
||||
ID: uint64(doc.Id),
|
||||
@@ -271,6 +268,8 @@ func ToExpenseNonstockDTO(ns entity.ExpenseNonstock) ExpenseNonstockDTO {
|
||||
|
||||
func ToKandangGroupDTO(pengajuans []ExpenseNonstockDTO, realisasi []ExpenseRealizationDTO, nonstocks []entity.ExpenseNonstock) []KandangGroupDTO {
|
||||
kandangMap := make(map[uint64]*KandangGroupDTO)
|
||||
var directPengajuans []ExpenseNonstockDTO
|
||||
var directRealisasi []ExpenseRealizationDTO
|
||||
|
||||
for _, p := range pengajuans {
|
||||
var kandangId uint64
|
||||
@@ -287,16 +286,19 @@ func ToKandangGroupDTO(pengajuans []ExpenseNonstockDTO, realisasi []ExpenseReali
|
||||
}
|
||||
|
||||
if kandangId > 0 {
|
||||
|
||||
if kandangMap[kandangId] == nil {
|
||||
kandangMap[kandangId] = &KandangGroupDTO{
|
||||
Id: kandangId,
|
||||
KandangId: kandangId,
|
||||
Name: kandangName,
|
||||
Pengajuans: []ExpenseNonstockDTO{},
|
||||
Realisasi: []ExpenseRealizationDTO{},
|
||||
}
|
||||
}
|
||||
kandangMap[kandangId].Pengajuans = append(kandangMap[kandangId].Pengajuans, p)
|
||||
} else {
|
||||
|
||||
directPengajuans = append(directPengajuans, p)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,13 +318,24 @@ func ToKandangGroupDTO(pengajuans []ExpenseNonstockDTO, realisasi []ExpenseReali
|
||||
if kandangMap[kandangId] == nil {
|
||||
kandangMap[kandangId] = &KandangGroupDTO{
|
||||
Id: kandangId,
|
||||
KandangId: kandangId,
|
||||
Name: kandangName,
|
||||
Pengajuans: []ExpenseNonstockDTO{},
|
||||
Realisasi: []ExpenseRealizationDTO{},
|
||||
}
|
||||
}
|
||||
kandangMap[kandangId].Realisasi = append(kandangMap[kandangId].Realisasi, r)
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
// If there are direct expenses (without kandang), add them as a special entry with id=0
|
||||
if len(directPengajuans) > 0 || len(directRealisasi) > 0 {
|
||||
kandangMap[0] = &KandangGroupDTO{
|
||||
Id: 0,
|
||||
|
||||
Name: "",
|
||||
Pengajuans: directPengajuans,
|
||||
Realisasi: directRealisasi,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user