| | |
| | | LocationID: output.LocationID, |
| | | OperationSource: constvar.OperationSourceSaleDelivery, |
| | | SalesDetailsNumber: output.SaleDetailsNumber, |
| | | WarehouseId: output.WarehouseID, |
| | | } |
| | | operations = append(operations, operation) |
| | | autoCode = models.GetAutoCode(maxAutoIncr, codeStandard) |
| | |
| | | BaseOperationType: constvar.BaseOperationTypeInternal, |
| | | Details: details, |
| | | CheckedBy: userInfo.Username, |
| | | WarehouseId: operation.WarehouseId, |
| | | }).Error; err != nil { |
| | | return err |
| | | } |
| | |
| | | var inputDetails []*models.OperationDetails |
| | | var outputDetails []*models.OperationDetails |
| | | for _, v := range listDetails { |
| | | if _, aok := mapLocAmount[strconv.Itoa(v.ToLocationID)+v.ProductId]; aok { |
| | | if _, aok := mapLocAmount[strconv.Itoa(v.FromLocationID)+v.ProductId]; aok { |
| | | if v.StockAmount.Equal(v.Amount) { //盘点数量和剩余数量一致 |
| | | continue |
| | | } |
| | |
| | | Details: inputDetails, |
| | | LocationID: inputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整入库", |
| | | WarehouseId: originOperation.WarehouseId, |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | |
| | | Details: outputDetails, |
| | | LocationID: outputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整出库", |
| | | WarehouseId: originOperation.WarehouseId, |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | |
| | | } |
| | | |
| | | func GetTargetOperationTypeIdByOperation(operation *models.Operation, baseOT constvar.BaseOperationType) (operationTypeId int, err error) { |
| | | oT, err := models.NewOperationTypeSearch().SetID(uint(operation.OperationTypeId)).First() |
| | | if err != nil { |
| | | return 0, err |
| | | } |
| | | targetOT, err := models.NewOperationTypeSearch().SetBaseOperationType(baseOT).SetWarehouseId(oT.WarehouseId).First() |
| | | targetOT, err := models.NewOperationTypeSearch().SetBaseOperationType(baseOT).SetWarehouseId(operation.WarehouseId).First() |
| | | if err != nil { |
| | | return 0, err |
| | | } |