mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat/BE/US-304/TASK-292,293-restriction expense not finish and stock not used,add status project flock completed, fix dto purchase, fix dto nonstock supplier, purchase
This commit is contained in:
@@ -110,7 +110,10 @@ func (s *purchaseService) withRelations(db *gorm.DB) *gorm.DB {
|
||||
Preload("Items.Product.Flags").
|
||||
Preload("Items.Warehouse.Area").
|
||||
Preload("Items.Warehouse.Location").
|
||||
Preload("Items.ProductWarehouse")
|
||||
Preload("Items.ProductWarehouse").
|
||||
Preload("Items.ExpenseNonstock").
|
||||
Preload("Items.ExpenseNonstock.Expense").
|
||||
Preload("Items.ExpenseNonstock.Expense.Supplier")
|
||||
}
|
||||
|
||||
func (s *purchaseService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entity.Purchase, int64, error) {
|
||||
@@ -319,8 +322,8 @@ func (s *purchaseService) CreateOne(c *fiber.Ctx, req *validation.CreatePurchase
|
||||
purchase := &entity.Purchase{
|
||||
SupplierId: uint(req.SupplierID),
|
||||
// DueDate: dueDate,
|
||||
Notes: req.Notes,
|
||||
CreatedBy: uint(actorID),
|
||||
Notes: req.Notes,
|
||||
CreatedBy: uint(actorID),
|
||||
}
|
||||
|
||||
items := make([]*entity.PurchaseItem, 0, len(aggregated))
|
||||
@@ -432,7 +435,7 @@ func (s *purchaseService) ApproveStaffPurchase(c *fiber.Ctx, id uint, req *valid
|
||||
|
||||
syncReceiving := !isInitialApproval && hasReceivingData
|
||||
|
||||
if len(req.Items) == 0 {
|
||||
if action == entity.ApprovalActionApproved && len(req.Items) == 0 {
|
||||
return nil, utils.BadRequest("Items must not be empty for staff approval")
|
||||
}
|
||||
|
||||
@@ -1397,21 +1400,21 @@ func (s *purchaseService) loadPurchase(
|
||||
}
|
||||
|
||||
func collectPFKIDsFromPurchase(p *entity.Purchase) []uint {
|
||||
seen := make(map[uint]struct{})
|
||||
ids := make([]uint, 0)
|
||||
seen := make(map[uint]struct{})
|
||||
ids := make([]uint, 0)
|
||||
|
||||
for _, item := range p.Items {
|
||||
if item.ProjectFlockKandangId == nil || *item.ProjectFlockKandangId == 0 {
|
||||
continue
|
||||
}
|
||||
id := uint(*item.ProjectFlockKandangId)
|
||||
if _, ok := seen[id]; ok {
|
||||
continue
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
for _, item := range p.Items {
|
||||
if item.ProjectFlockKandangId == nil || *item.ProjectFlockKandangId == 0 {
|
||||
continue
|
||||
}
|
||||
id := uint(*item.ProjectFlockKandangId)
|
||||
if _, ok := seen[id]; ok {
|
||||
continue
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
func (s *purchaseService) ensureProjectFlockNotClosedForPurchase(
|
||||
ctx context.Context,
|
||||
@@ -1429,5 +1432,3 @@ func (s *purchaseService) ensureProjectFlockNotClosedForPurchase(
|
||||
|
||||
return commonSvc.EnsureProjectFlockNotClosedForProductWarehouses(ctx, db, pfkIDs)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user