diff --git a/src/main/java/org/spin/grpc/service/PointOfSalesForm.java b/src/main/java/org/spin/grpc/service/PointOfSalesForm.java index 431d8b0b..89355bc5 100644 --- a/src/main/java/org/spin/grpc/service/PointOfSalesForm.java +++ b/src/main/java/org/spin/grpc/service/PointOfSalesForm.java @@ -3665,7 +3665,7 @@ private ListOrdersResponse.Builder listOrders(ListOrdersRequest request) { query.setLimit(limit, offset) .getIDsAsList() .forEach(orderId -> { - Order.Builder orderBuilder = POSConvertUtil.convertOder(orderId); + Order.Builder orderBuilder = OrderConverUtil.convertOder(orderId); builder.addOrders(orderBuilder); }); diff --git a/src/main/java/org/spin/pos/util/OrderConverUtil.java b/src/main/java/org/spin/pos/util/OrderConverUtil.java index 48df5172..16488173 100644 --- a/src/main/java/org/spin/pos/util/OrderConverUtil.java +++ b/src/main/java/org/spin/pos/util/OrderConverUtil.java @@ -34,7 +34,22 @@ import org.spin.service.grpc.util.value.ValueManager; public class OrderConverUtil { - + + /** + * Convert Order from entity + * @param orderId + * @return + */ + public static Order.Builder convertOder(int orderId) { + Order.Builder builder = Order.newBuilder(); + if(orderId <= 0) { + return builder; + } + MOrder order = new MOrder(Env.getCtx(), orderId, null); + return OrderConverUtil.convertOrder( + order + ); + } /** * Convert Order from entity * @param order @@ -106,6 +121,16 @@ public static Order.Builder convertOrder(MOrder order) { BigDecimal openAmount = (grandTotal.subtract(totalPaymentAmount).compareTo(Env.ZERO) < 0? Env.ZERO: grandTotal.subtract(totalPaymentAmount)); BigDecimal refundAmount = (grandTotal.subtract(totalPaymentAmount).compareTo(Env.ZERO) > 0? Env.ZERO: grandTotal.subtract(totalPaymentAmount).negate()); BigDecimal displayCurrencyRate = ConvertUtil.getDisplayConversionRateFromOrder(order); + + if (order.getC_Invoice_ID() > 0) { + MInvoice invoice = new MInvoice(order.getCtx(), order.getC_Invoice_ID(), order.get_TrxName()); + builder.setInvoiceNo( + StringManager.getValidString( + invoice.getDocumentNo() + ) + ); + } + // Convert return builder .setId( diff --git a/src/main/java/org/spin/pos/util/POSConvertUtil.java b/src/main/java/org/spin/pos/util/POSConvertUtil.java index 571a4f79..ff133bb8 100644 --- a/src/main/java/org/spin/pos/util/POSConvertUtil.java +++ b/src/main/java/org/spin/pos/util/POSConvertUtil.java @@ -30,7 +30,6 @@ import org.compiere.model.MCountry; import org.compiere.model.MInOutLine; import org.compiere.model.MLocation; -import org.compiere.model.MOrder; import org.compiere.model.MOrderLine; import org.compiere.model.MProduct; import org.compiere.model.MRegion; @@ -47,7 +46,6 @@ import org.spin.backend.grpc.pos.City; import org.spin.backend.grpc.pos.CommandShortcut; import org.spin.backend.grpc.pos.Customer; -import org.spin.backend.grpc.pos.Order; import org.spin.backend.grpc.pos.Region; import org.spin.backend.grpc.pos.ShipmentLine; import org.spin.grpc.service.core_functionality.CoreFunctionalityConvert; @@ -150,24 +148,6 @@ public static Campaign.Builder convertCampaign(MCampaign campaign) { - /** - * Convert Order from entity - * @param orderId - * @return - */ - public static Order.Builder convertOder(int orderId) { - Order.Builder builder = Order.newBuilder(); - if(orderId <= 0) { - return builder; - } - MOrder order = new MOrder(Env.getCtx(), orderId, null); - return OrderConverUtil.convertOrder( - order - ); - } - - - public static CommandShortcut.Builder convertCommandShorcut(PO commandShortcut) { CommandShortcut.Builder builder = CommandShortcut.newBuilder(); if (commandShortcut == null) {