Class InvoiceServices
Note that throughout this file we use BigDecimal to do arithmetic. It is critical to understand the way BigDecimal works if you wish to modify the computations in this file. The most important things to keep in mind:
Critically important: BigDecimal arithmetic methods like add(), multiply(), divide() do not modify the BigDecimal itself. Instead, they return a new BigDecimal. For example, to keep a running total of an amount, make sure you do this:
amount = amount.add(subAmount);
and not this,
amount.add(subAmount);
Use .setScale(scale, roundingMode) after every computation to scale and round off the decimals. Check the code to see how the scale and roundingMode are obtained and how the function is used.
use .compareTo() to compare big decimals
ex. (amountOne.compareTo(amountTwo) == 1) checks if amountOne is greater than amountTwo
Use .signum() to test if value is negative, zero, or positive
ex. (amountOne.signum() == 1) checks if the amount is a positive non-zero number
Never use the .equals() function becaues it considers 2.0 not equal to 2.00 (the scale is different) Instead, use .compareTo() or .signum(), which handles scale correctly.
For reference, check the official Sun Javadoc on java.math.BigDecimal.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncalculateInvoicedAdjustmentTotal
(DispatchContext dctx, Map<String, Object> context) checkInvoicePaymentApplications
(DispatchContext ctx, Map<String, Object> context) checkPaymentInvoices
(DispatchContext dctx, Map<String, Object> context) createCommissionInvoices
(DispatchContext dctx, Map<String, Object> context) createInvoiceForOrder
(DispatchContext dctx, Map<String, Object> context) Service to create an invoice for an ordercreateInvoiceForOrderAllItems
(DispatchContext dctx, Map<String, Object> context) createInvoiceFromReturn
(DispatchContext dctx, Map<String, Object> context) createInvoicesFromReturnShipment
(DispatchContext dctx, Map<String, Object> context) createInvoicesFromShipment
(DispatchContext dctx, Map<String, Object> context) createInvoicesFromShipments
(DispatchContext dctx, Map<String, ? extends Object> context) createSalesInvoicesFromDropShipment
(DispatchContext dctx, Map<String, Object> context) importInvoice
(DispatchContext dctx, Map<String, Object> context) readyInvoices
(DispatchContext dctx, Map<String, Object> context) setInvoicesToReadyFromShipment
(DispatchContext dctx, Map<String, Object> context) updatePaymentApplication
(DispatchContext dctx, Map<String, Object> context) Service to add payment application records to indicate which invoices have been paid/received.updatePaymentApplicationDef
(DispatchContext dctx, Map<String, Object> context) Service to add payment application records to indicate which invoices have been paid/received.updatePaymentApplicationDefBd
(DispatchContext dctx, Map<String, Object> context)
-
Constructor Details
-
InvoiceServices
public InvoiceServices()
-
-
Method Details
-
createInvoiceForOrderAllItems
-
createInvoiceForOrder
public static Map<String,Object> createInvoiceForOrder(DispatchContext dctx, Map<String, Object> context) Service to create an invoice for an order -
createCommissionInvoices
-
readyInvoices
-
createInvoicesFromShipment
-
setInvoicesToReadyFromShipment
-
createSalesInvoicesFromDropShipment
-
createInvoicesFromShipments
-
createInvoicesFromReturnShipment
-
createInvoiceFromReturn
-
checkInvoicePaymentApplications
-
updatePaymentApplication
public static Map<String,Object> updatePaymentApplication(DispatchContext dctx, Map<String, Object> context) Service to add payment application records to indicate which invoices have been paid/received. For invoice processing, this service works on the invoice level when 'invoiceProcessing' parameter is set to "Y" else it works on the invoice item level. -
updatePaymentApplicationDef
public static Map<String,Object> updatePaymentApplicationDef(DispatchContext dctx, Map<String, Object> context) Service to add payment application records to indicate which invoices have been paid/received. For invoice processing, this service works on the invoice level when 'invoiceProcessing' parameter is set to "Y" else it works on the invoice item level.This version will apply as much as possible when no amountApplied is provided.
-
updatePaymentApplicationDefBd
-
calculateInvoicedAdjustmentTotal
-
checkPaymentInvoices
-
importInvoice
-