Skip to content

Sage 50 UK Purchase Invoice XML

Import Purchase Invoices allows you to post existing purchase orders to the ledger in Sage 50, resulting in a purchase invoice being raised against the supplier's account. We recommend that the Id field be populated by the unique id of the invoice from the external system, Zynk uses this field to track invoices already imported to prevent duplicates being created in Sage.

Any fields not documented below are not directly supported with our imports.

Tasks

Minimal XML Sample

The XML below represents the minimum information that needs to be provided to create a purchase invoice in Sage. This would result in all items on the purchase order number specified being invoiced.

<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <PurchaseOrderNumber>123</PurchaseOrderNumber>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>

In each of the following sections most of the XML has been omitted to make the samples easier to read, you will need to provide the above as a minimum to create a purchase invoice. The whole structure of the Company schema is used below as a reference of where fields should be in the object model.

A complete sample showing everything that can be provided is shown at the bottom of this page.

Preventing Duplication of Purchase Invoices

You can optionally provide an Id for each purchase invoice, populating it with the unique identifier of the purchase invoice from the external system (where the data originated). Any successfully imported purchase invoice Id's will be stored in Zynk's truth table, and associated with the Sage transaction header number and Workflow. Zynk will also store a combination of the purchase invoice Id provided and the Sage item ID of each line that appeared on the invoice, associated with the Sage transaction split number and Workflow.

The Import Purchase Invoices task can then be set to prevent duplicates based on the stored Id's, preventing accidental reprocessing of already imported purchase invoices.

Sage Field XML Field Example  Field Type  Field Length  Input 
Id 123  string 255 Optional 
<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <Id>123</Id>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>

Purchase Order Lookup

In order to lookup the purchase order to invoice, one of the following identifiers can be used, if multiple identifiers are specified then the following precedence is used: -

  • PurchaseOrderNumber
  • PurchaseOrderId
Sage Field XML Field  Example  Field Type  Field Length  Input 
Order No.  PurchaseOrderNumber* 123  integer  - Dependant 
- PurchaseOrderId* 123  string  255 Dependant 
  • PurchaseOrderNumber* - The order no shown on the Sage 50 purchase order. If the purchase order was imported into Sage via Zynk, this would be shown in the PurchaseOrderNumber element in the success file that was generated by the Import Purchase Orders task. It would also appear in the same place in the output file for an Export Purchase Orders task.
  • PurchaseOrderId* - If the purchase order was imported into Sage by Zynk as part of the same workflow, and an Id (3rd party system identifier) was specified in the XML, this Id can be used to match the purchase order.
<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <PurchaseOrderNumber>123</PurchaseOrderNumber>
      <PurchaseOrderId>123</PurchaseOrderId>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>

Purchase Invoice Details

The task will generate purchase invoice (PI) transactions against the supplier's account. The following information can be specified on these transactions. All other fields are populated automatically based on the purchase order lines that are being invoiced.

Sage Field XML Field  Example  Field Type  Field Length  Input 
Date  InvoiceDate*  2022-01-01  datetime - Optional 
Ref InvoiceNumber  INV-123  string 10  Optional 
Ex Ref InvoiceSecondReference PO-123 string 10 Optional
  • InvoiceDate* - If this field is not set in the XML, it will default to the current date.
  • InvoiceNumber* - If this field is not set in the XML, it will default to the order no of the purchase order being invoiced.
  • InvoiceSecondReference* - If this field is not set in the XML, it will be left blank in Sage.
<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <InvoiceDate>2022-01-01</InvoiceDate>
      <InvoiceNumber>INV-123</InvoiceNumber>
      <InvoiceSecondReference>PO-123</InvoiceSecondReference>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>

Purchase Invoice Item Details

You can optionally provide a collection of items that you would like to invoice, along with the quantity to invoice. This allows you to control exactly which products are invoiced, and what quantity. Items are matched based on product code. If the same product code appears on more than one line on the purchase order, they will be invoiced one after the other in order they appear, until the quantity specified in the XML is exhausted.

If you don't provide a collection of items, the task will invoice all delivered (but yet to be invoiced) items on the purchase order.

Please note that the task will never receive deliveries into Sage. So the quantity that can be invoiced is limited to the delivered quantity for each line. If you need to receive deliveries into Sage, you will need to use the Import GRN task.

Sage Field XML Field  Example  Field Type  Field Length  Input 
Product Code Sku PROD0001 string 30 Optional
To Inv QtyInvoiced 1.00 decimal  - Optional
<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <PurchaseInvoiceItems>
        <Item>
          <Sku>PROD0001</Sku>
          <QtyInvoiced>1.00</QtyInvoiced>
        </Item>
      </PurchaseInvoiceItems>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>

Complete XML Sample

This sample shows all data that can be provided via our purchase invoice import into Sage 50.

<?xml version="1.0" encoding="utf-8"?>
<Company>
  <PurchaseInvoices>
    <PurchaseInvoice>
      <Id>123</Id>
      <PurchaseOrderNumber>123</PurchaseOrderNumber>
      <PurchaseOrderId>123</PurchaseOrderId>
      <InvoiceDate>2022-01-01</InvoiceDate>
      <InvoiceNumber>INV-123</InvoiceNumber>
      <InvoiceSecondReference>PO-123</InvoiceSecondReference>
      <PurchaseInvoiceItems>
        <Item>
          <Sku>PROD0001</Sku>
          <QtyInvoiced>1.00</QtyInvoiced>
        </Item>
      </PurchaseInvoiceItems>
    </PurchaseInvoice>
  </PurchaseInvoices>
</Company>