feat: update InventoryMovement entity and service to use non-pointer UUIDs for location and zone fields
Deploy Application / deploy (push) Successful in 18s
Details
Deploy Application / deploy (push) Successful in 18s
Details
This commit is contained in:
parent
111d0cffa3
commit
abd8780191
|
|
@ -16,13 +16,13 @@ type TInventoryMovementEntity struct {
|
|||
MovementType string `gorm:"type:varchar(50);" json:"movement_type"`
|
||||
Status string `gorm:"type:varchar(50);default:'draft'" json:"status"`
|
||||
|
||||
ClientID uuid.UUID `gorm:"type:uuid;index;" json:"client_id"`
|
||||
SourceLocationID *uuid.UUID `gorm:"type:uuid;index;" json:"source_location_id"`
|
||||
DestinationLocationID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_location_id"`
|
||||
SourceZoneID *uuid.UUID `gorm:"type:uuid;index;" json:"source_zone_id"`
|
||||
DestinationZoneID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_zone_id"`
|
||||
SourceAisleID *uuid.UUID `gorm:"type:uuid;index;" json:"source_aisle_id"`
|
||||
DestinationAisleID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_aisle_id"`
|
||||
ClientID uuid.UUID `gorm:"type:uuid;index;" json:"client_id"`
|
||||
SourceLocationID uuid.UUID `gorm:"type:uuid;index;" json:"source_location_id"`
|
||||
DestinationLocationID uuid.UUID `gorm:"type:uuid;index;" json:"destination_location_id"`
|
||||
SourceZoneID uuid.UUID `gorm:"type:uuid;index;" json:"source_zone_id"`
|
||||
DestinationZoneID uuid.UUID `gorm:"type:uuid;index;" json:"destination_zone_id"`
|
||||
SourceAisleID uuid.UUID `gorm:"type:uuid;index;" json:"source_aisle_id"`
|
||||
DestinationAisleID uuid.UUID `gorm:"type:uuid;index;" json:"destination_aisle_id"`
|
||||
|
||||
MovementLines []TInventoryMovementLineEntity `gorm:"foreignKey:InvMovementID;references:ID"`
|
||||
SourceLocation MWarehouseEntity `gorm:"foreignKey:SourceLocationID;references:ID"`
|
||||
|
|
|
|||
|
|
@ -78,23 +78,25 @@ func (s *inventoryMovementService) Create(ctx context.Context, req dtodomain.Inv
|
|||
tx.Rollback()
|
||||
return dtodomain.InventoryMovementResponse{}, err
|
||||
}
|
||||
var sourceLocID *uuid.UUID
|
||||
if req.SourceLocationID != nil && *req.SourceLocationID != "" {
|
||||
parsed, err := uuid.Parse(*req.SourceLocationID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return dtodomain.InventoryMovementResponse{}, err
|
||||
}
|
||||
sourceLocID = &parsed
|
||||
|
||||
var sourceLocationID, destinationLocationID, sourceZoneID, destinationZoneID, sourceAisleID, destinationAisleID uuid.UUID
|
||||
if req.SourceLocationID != nil {
|
||||
sourceLocationID = uuid.MustParse(*req.SourceLocationID)
|
||||
}
|
||||
var destLocID *uuid.UUID
|
||||
if req.DestinationLocationID != nil && *req.DestinationLocationID != "" {
|
||||
parsed, err := uuid.Parse(*req.DestinationLocationID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return dtodomain.InventoryMovementResponse{}, err
|
||||
}
|
||||
destLocID = &parsed
|
||||
if req.DestinationLocationID != nil {
|
||||
destinationLocationID = uuid.MustParse(*req.DestinationLocationID)
|
||||
}
|
||||
if req.SourceZoneID != nil {
|
||||
sourceZoneID = uuid.MustParse(*req.SourceZoneID)
|
||||
}
|
||||
if req.DestinationZoneID != nil {
|
||||
destinationZoneID = uuid.MustParse(*req.DestinationZoneID)
|
||||
}
|
||||
if req.SourceAisleID != nil {
|
||||
sourceAisleID = uuid.MustParse(*req.SourceAisleID)
|
||||
}
|
||||
if req.DestinationAisleID != nil {
|
||||
destinationAisleID = uuid.MustParse(*req.DestinationAisleID)
|
||||
}
|
||||
|
||||
movement := entities.TInventoryMovementEntity{
|
||||
|
|
@ -103,8 +105,12 @@ func (s *inventoryMovementService) Create(ctx context.Context, req dtodomain.Inv
|
|||
MovementType: req.MovementType,
|
||||
ClientID: clientUUID,
|
||||
Status: req.Status,
|
||||
SourceLocationID: sourceLocID,
|
||||
DestinationLocationID: destLocID,
|
||||
SourceLocationID: sourceLocationID,
|
||||
DestinationLocationID: destinationLocationID,
|
||||
SourceZoneID: sourceZoneID,
|
||||
DestinationZoneID: destinationZoneID,
|
||||
SourceAisleID: sourceAisleID,
|
||||
DestinationAisleID: destinationAisleID,
|
||||
FullAuditTrail: utils.FillAuditTrail(ctx, constants.CREATE),
|
||||
}
|
||||
created, err := s.movementRepo.Create(ctx, tx, movement)
|
||||
|
|
|
|||
Loading…
Reference in New Issue