Skip to content

Commit

Permalink
feat: Add Invoice No on POS order. (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt authored Dec 26, 2024
1 parent c6c4440 commit 9d376fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/spin/grpc/service/PointOfSalesForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
27 changes: 26 additions & 1 deletion src/main/java/org/spin/pos/util/OrderConverUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/org/spin/pos/util/POSConvertUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9d376fc

Please sign in to comment.