| | |
| | | Cost: v.Cost, |
| | | SalePrice: v.SalePrice, |
| | | }) |
| | | if len(outputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeOutgoing) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调拨出库", |
| | | BaseOperationType: constvar.BaseOperationTypeOutgoing, |
| | | Details: outputDetails, |
| | | LocationID: outputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调拨出库", |
| | | IsInternalOutput: true, |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | if len(outputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeOutgoing) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调拨出库", |
| | | BaseOperationType: constvar.BaseOperationTypeOutgoing, |
| | | Details: outputDetails, |
| | | LocationID: outputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调拨出库", |
| | | IsInternalOutput: true, |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | return nil |
| | |
| | | Remark: v.Remark, |
| | | }) |
| | | } |
| | | //if locAmount, aok := mapLocAmount[strconv.Itoa(v.ToLocationID)+v.ProductId]; aok { |
| | | // locAmount.Amount = v.Amount |
| | | // if err := models.NewLocationProductAmountSearch().SetOrm(tx).SetID(locAmount.Id).Save(locAmount); err != nil { |
| | | // return err |
| | | // } |
| | | //} else { |
| | | // if err := models.NewLocationProductAmountSearch().SetOrm(tx).Create(&models.LocationProductAmount{ |
| | | // LocationId: v.ToLocationID, |
| | | // ProductCategoryID: v.Product.CategoryId, |
| | | // ProductId: v.ProductId, |
| | | // Amount: v.Amount, |
| | | // CreateDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | // }); err != nil { |
| | | // return err |
| | | // } |
| | | //} |
| | | |
| | | if len(inputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeIncoming) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调整入库", |
| | | BaseOperationType: constvar.BaseOperationTypeIncoming, |
| | | Details: inputDetails, |
| | | LocationID: inputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整入库", |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | if len(inputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeIncoming) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | if len(outputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeOutgoing) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调整出库", |
| | | BaseOperationType: constvar.BaseOperationTypeOutgoing, |
| | | Details: outputDetails, |
| | | LocationID: outputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整出库", |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调整入库", |
| | | BaseOperationType: constvar.BaseOperationTypeIncoming, |
| | | Details: inputDetails, |
| | | LocationID: inputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整入库", |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | if len(outputDetails) > 0 { |
| | | opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeOutgoing) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | operation := &models.Operation{ |
| | | OperationTypeId: opTypeId, |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存调整出库", |
| | | BaseOperationType: constvar.BaseOperationTypeOutgoing, |
| | | Details: outputDetails, |
| | | LocationID: outputDetails[0].FromLocationID, |
| | | OperationTypeName: "库存调整出库", |
| | | } |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(operation); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | return nil |