Ver a proveniência

make PCS/CTN in stock in qty conversion round up

master
Fai Luk há 19 horas
ascendente
cometimento
05cc03c689
1 ficheiros alterados com 18 adições e 2 eliminações
  1. +18
    -2
      src/main/java/com/ffii/fpsms/modules/master/service/ItemUomService.kt

+ 18
- 2
src/main/java/com/ffii/fpsms/modules/master/service/ItemUomService.kt Ver ficheiro

@@ -224,6 +224,22 @@ open class ItemUomService(
return stockQty.setScale(0, RoundingMode.DOWN)
}

/**
* Stock UOM code [PCS/CTN]* denotes pieces-per-carton; displayed stock qty should be whole cartons (integer).
*/
private fun isPiecesPerCartonStockUomCode(stockUnit: ItemUom?): Boolean {
val code = stockUnit?.uom?.code?.trim() ?: return false
return code.startsWith("PCS/CTN", ignoreCase = true)
}

/** After ratio math: 2 decimals, or integer when stock unit is PCS/CTN… */
private fun finalizePreciseStockQty(stockUnit: ItemUom?, stockQty: BigDecimal): BigDecimal {
if (isPiecesPerCartonStockUomCode(stockUnit)) {
return stockQty.setScale(0, RoundingMode.HALF_UP)
}
return stockQty.setScale(2, RoundingMode.HALF_UP)
}

/**
* Convert purchase qty -> stock qty and keep decimal precision.
* Used for PO flows where decimal quantity must be preserved.
@@ -242,7 +258,7 @@ open class ItemUomService(
.multiply(stockUnit.ratioD ?: one)
.divide(stockUnit.ratioN ?: one, calcScale, RoundingMode.HALF_UP)

return stockQty.setScale(2, RoundingMode.HALF_UP)
return finalizePreciseStockQty(stockUnit, stockQty)
}

/**
@@ -263,7 +279,7 @@ open class ItemUomService(
.multiply(stockUnit.ratioD ?: one)
.divide(stockUnit.ratioN ?: one, calcScale, RoundingMode.HALF_UP)

return stockQty.setScale(2, RoundingMode.HALF_UP)
return finalizePreciseStockQty(stockUnit, stockQty)
}

// See if need to update the response


Carregando…
Cancelar
Guardar