Invoice Data XML Scripts

Each MineMarket invoice screen (for example, Sales Invoice) has a Report tab that displays a printable invoice. The invoice report template is a Crystal Reports template. The template may either be one of the default ones supplied with MineMarket (for example, InvoiceDefault.rpt), or one created specifically for the customer.

The names of the default data items included in the invoice XML output can be determined from the InvoiceDataSet.xsd file. If extra nodes are required, the invoice XSD that the original XML document is based on must be modified to include the extra nodes. After the XSD has been edited, the Crystal Report RPT file data source must be refreshed in the design environment to display the new nodes. See Invoice Data XSD.

When a user selects the Report tab of an invoice screen:

  1. MineMarket finds the applicable Crystal Reports invoice report template located in the InvoiceReportTemplatePath configured for the MineMarket Service. See Configure the MineMarket Service.
  2. MineMarket populates the core XML document with invoice report data.
  3. If the UseScript method in the Invoice Data XML script returns true, MineMarket passes the core XML document and the invoice object to the invoice XML generation event.
  4. The invoice XML generation event customises the XML document if required and passes it back to MineMarket.
  5. MineMarket parses the XML document in accordance with the selected invoice report template.

Formal Definition

Copy
using System;
using Mincom.MineMarket.DAL;
using Mincom.MineMarket;
using Mincom.MineMarket.Server;
using System.Data;
using System.Xml;
using System.Collections;

public class InvoiceDataXMLScriptEvent : IInvoiceDataXMLScript
{
    public InvoiceDataXMLScriptEvent() 
    {
    }

    #region IInvoiceDataXMLScript Members

    public XmlDocument UpdateDataSet(Invoice inv, XmlDocument originalDocument, 
        ArrayList parameters)
    {
        return originalDocument;
    }

    public bool UseScript(Invoice inv)
    {
        return true;
    }

    #endregion
}

Method Descriptions

UpdateDataSet

The method where code is placed for customisation, which has the following parameters:

  • inv—The invoice itself. Because the invoice object is passed to the script, you have access to core data that may not be contained in the XML document.
  • originalDocument—Contains the XML generated by core MineMarket, of type XmlDocument, which allows you to add, delete or update entries in the generated XML document.
  • ArrayList—An array of parameters, used to specify the parameters that need to be passed directly to the invoice RPT.

This method receives the invoice object used to populate the XML, the XML document and an array list of parameters, which is empty.

UseScript

Boolean method that determines if the script is called from MineMarket before passing the XML document to the report template. If true, the script will execute; and if false the script will not execute.

Coding Standards

Comments must be applied appropriately to the script and kept up to date.

A history of the updates and current version number must be recorded at the top of the script.

Variable names must be meaningful and not concatenated. For example, use address1 instead of add1.

Hard coding the number of decimals is not recommended because it can lead to rounding errors based on the contract configuration.

The invoice data XML script, the invoice XSD and any report templates must be uploaded to TFS under the appropriate customer project folder.

Invoice Document Types

You can query the invoice object to determine the invoice document type, and then use that to change the content or structure of the XML. For example:

Copy
if
{
  invoice is SalesInvoice
  or
  invoice is ServiceInvoice
}

For more detail, you can determine the type of despatch associated with the invoice. For example:

Copy
if
{
    invoice.InvoiceDespatchTotals[0].DespatchOrder.GerfulfillmentDespatch() 
        is Shipment
    or
    invoice.InvoiceDespatchTotals[0].DespatchOrder,GerFulfillmentDespatch() 
        is Train
}