The invoice item descriptor includes these properties:

Property

Description

balanceDue

Amount to be paid by the invoice.

creationDate

Date the invoice was created.

deliveryInfo

Link to a deliveryInfo item.

id

Unique repository ID of the invoice.

invoiceNumber

System-generated identifying number. InvoiceNumber is unique as provided, but you can customize your system to generate multiple invoices with the same number.

lastModifiedDate

Date the invoice was last modified.

orderId

ID of the Order item in the Order repository to which the invoice is linked.

paymentDueDate

Date the invoice must be paid.

paymentGroupId

ID of the paymentGroup item in the Order repository; identifies which parts of the order (commerce items, shipping costs, etc.) the invoice pays for.

paymentTerms

Link to a paymentTerms item.

poNumber

Purchase order number assigned to the invoice by the user at the time of checkout; need not be unique.

requisitionNumber

Value copied from the requisitionNumber property of the payment group assigned to the invoice.

type

Provided for subclassing purposes; use to indicate if an item belongs to the superclass or a subclass. Read-only.

version

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...
      }
    }
 
loading table of contents...