The invoice item descriptor includes these properties:
Property | Description |
---|---|
| Amount to be paid by the invoice. |
| Date the invoice was created. |
| Link to a |
| Unique repository ID of the invoice. |
| System-generated identifying number. |
| Date the invoice was last modified. |
| ID of the |
| Date the invoice must be paid. |
| ID of the |
| Link to a |
| Purchase order number assigned to the invoice by the user at the time of checkout; need not be unique. |
| Value copied from the |
| Provided for subclassing purposes; use to indicate if an item belongs to the superclass or a subclass. Read-only. |
| Integer that is incremented automatically each time the product is updated; used to prevent version conflict. Read-only. |
The orderId
allows you to find the Order being paid for with the invoice, and the paymentGroupId
identifies the corresponding PaymentGroup
, telling you which parts of the order the invoice pays for. This can be important if billing is split among multiple payment groups. For example, if you want to generate an itemized bill that includes only the items billed to a particular invoice, you need to find the corresponding PaymentGroup
and iterate over its commerce items to create the bill.
Given the orderId
and paymentGroupId
, you can find the Order
and PaymentGroup
objects using the following code:
public void doSomethingWithInvoice(RepositoryItem invoiceItem) { OrderManager om = getOrderManager(); Order order = null; PaymentGroup payment = null; try { String orderId =(String)invoiceItem.getPropertyValue("orderId"); String paymentId = (String)invoiceItem.getPropertyValue("paymentGroupId"); if (orderId != null) order = om.getOrder(orderId); if (order != null && paymentId != null) payment = order.getPaymentGroup(paymentId); ... work with order and payment... } catch (Exception e) { ... handle exceptions... } }