| | |
| | | return moreValueArr |
| | | } |
| | | |
| | | func AddMoreUnit(units []models.UnitItems, units2 []models.UnitItems) []models.UnitItems { |
| | | moreValueArr := make([]models.UnitItems, 0, len(units)) |
| | | for _, unitItem1 := range units { |
| | | for _, unitItem2 := range units2 { |
| | | if unitItem1.Unit == unitItem2.Unit { |
| | | moreValueArr = append(moreValueArr, models.UnitItems{ |
| | | Amount: unitItem1.Amount.Add(unitItem2.Amount), |
| | | Unit: unitItem1.Unit, |
| | | Floating: unitItem1.Floating, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | return moreValueArr |
| | | } |
| | | |
| | | // MoreUnitIsEnough 多单位库存是否足够 |
| | | func MoreUnitIsEnough(units []models.UnitItems, units2 []models.UnitItems) bool { |
| | | for _, unitItem1 := range units { |
| | | for _, unitItem2 := range units2 { |
| | | if unitItem1.Amount.LessThan(unitItem2.Amount) { |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | return true |
| | | } |
| | | |
| | | func SubMoreUnit(units []models.UnitItems, units2 []models.UnitItems) []models.UnitItems { |
| | | moreValueArr := make([]models.UnitItems, 0, len(units)) |
| | | for _, unitItem1 := range units { |
| | | for _, unitItem2 := range units2 { |
| | | if unitItem1.Unit == unitItem2.Unit { |
| | | moreValueArr = append(moreValueArr, models.UnitItems{ |
| | | Amount: unitItem1.Amount.Sub(unitItem2.Amount), |
| | | Unit: unitItem1.Unit, |
| | | Floating: unitItem1.Floating, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | return moreValueArr |
| | | } |
| | | |
| | | func FillMoreUnitToExcel(amount decimal.Decimal, units []models.UnitItems, startIndex int, column int, f *excelize.File) { |
| | | columnStr := strconv.Itoa(column) |
| | | for _, v := range units { |