From af7cfa3ba489aff75174762635f2a8656cfc1829 Mon Sep 17 00:00:00 2001 From: ojwanganto Date: Wed, 28 Aug 2024 01:21:40 +0300 Subject: [PATCH] revert billing of stock items from stock purchase price to use prices set in billables module --- .../cashier/advice/GenerateBillFromOrderable.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/cashier/advice/GenerateBillFromOrderable.java b/api/src/main/java/org/openmrs/module/kenyaemr/cashier/advice/GenerateBillFromOrderable.java index a84bafb..99a6916 100644 --- a/api/src/main/java/org/openmrs/module/kenyaemr/cashier/advice/GenerateBillFromOrderable.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/cashier/advice/GenerateBillFromOrderable.java @@ -77,7 +77,7 @@ public void afterReturning(Object returnValue, Method method, Object[] args, Obj DrugOrder drugOrder = (DrugOrder) order; Integer drugID = drugOrder.getDrug() != null ? drugOrder.getDrug().getDrugId() : 0; double drugQuantity = drugOrder.getQuantity() != null ? drugOrder.getQuantity() : 0.0; - List stockItems = stockService.getStockItemByDrug(drugID); + List stockItems = stockService.getStockItemByDrug(drugID); // we expect a one-to-one mapping of drug to stock item in the inventory module if (!stockItems.isEmpty()) { // check from the list for all exemptions @@ -171,22 +171,22 @@ public void addBillItemToBill(Order order, Patient patient, String cashierUUID, try { BillLineItem billLineItem = new BillLineItem(); + List itemPrices = new ArrayList<>(); if (stockitem != null) { - if (stockitem.getPurchasePrice().compareTo(BigDecimal.ZERO) <= 0) { // we want to get the price set for the stock item + itemPrices = priceService.getItemPrice(stockitem); + if ( itemPrices.size() < 1 || itemPrices.get(0).getPrice().compareTo(BigDecimal.ZERO) <= 0) { return; - } else { - billLineItem.setItem(stockitem); - billLineItem.setPrice(stockitem.getPurchasePrice()); } + billLineItem.setItem(stockitem); } else if (service != null) { - List itemPrices = priceService.getServicePrice(service); + itemPrices = priceService.getServicePrice(service); if ( itemPrices.size() < 1 || itemPrices.get(0).getPrice().compareTo(BigDecimal.ZERO) <= 0) { return; } billLineItem.setBillableService(service); - billLineItem.setPrice(itemPrices.get(0).getPrice());// defaulting to the first item price } + billLineItem.setPrice(itemPrices.get(0).getPrice());// defaulting to the first item price // Check if patient has an active bill Bill activeBill = new Bill(); activeBill.setPatient(patient);