解决单据保存时候单位换算的报错
This commit is contained in:
@@ -227,6 +227,7 @@ public class UnitService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BigDecimal parseStockByUnit(BigDecimal stock, Unit unitInfo, String materialUnit) {
|
public BigDecimal parseStockByUnit(BigDecimal stock, Unit unitInfo, String materialUnit) {
|
||||||
|
if(stock!=null) {
|
||||||
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
stock = stock.divide(unitInfo.getRatio(), 2, BigDecimal.ROUND_HALF_UP);
|
stock = stock.divide(unitInfo.getRatio(), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
@@ -236,6 +237,7 @@ public class UnitService {
|
|||||||
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
stock = stock.divide(unitInfo.getRatioThree(), 2, BigDecimal.ROUND_HALF_UP);
|
stock = stock.divide(unitInfo.getRatioThree(), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return stock;
|
return stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +249,7 @@ public class UnitService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BigDecimal parseUnitPriceByUnit(BigDecimal unitPrice, Unit unitInfo, String materialUnit) {
|
public BigDecimal parseUnitPriceByUnit(BigDecimal unitPrice, Unit unitInfo, String materialUnit) {
|
||||||
|
if(unitPrice!=null) {
|
||||||
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
unitPrice = unitPrice.multiply(unitInfo.getRatio());
|
unitPrice = unitPrice.multiply(unitInfo.getRatio());
|
||||||
}
|
}
|
||||||
@@ -256,6 +259,7 @@ public class UnitService {
|
|||||||
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
unitPrice = unitPrice.multiply(unitInfo.getRatioThree());
|
unitPrice = unitPrice.multiply(unitInfo.getRatioThree());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return unitPrice;
|
return unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +271,7 @@ public class UnitService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BigDecimal parseAllPriceByUnit(BigDecimal allPrice, Unit unitInfo, String materialUnit) {
|
public BigDecimal parseAllPriceByUnit(BigDecimal allPrice, Unit unitInfo, String materialUnit) {
|
||||||
|
if(allPrice!=null) {
|
||||||
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != null && unitInfo.getRatio().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
allPrice = allPrice.divide(unitInfo.getRatio(), 2, BigDecimal.ROUND_HALF_UP);
|
allPrice = allPrice.divide(unitInfo.getRatio(), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
@@ -276,6 +281,7 @@ public class UnitService {
|
|||||||
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
if (materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != null && unitInfo.getRatioThree().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
allPrice = allPrice.divide(unitInfo.getRatioThree(), 2, BigDecimal.ROUND_HALF_UP);
|
allPrice = allPrice.divide(unitInfo.getRatioThree(), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return allPrice;
|
return allPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user