Send a Pro Forma Invoice by Email

By using the REST API, you can create pro forma invoices and send them by email. For details about pro forma invoices, see Pro Forma Invoices: General Information.

System Preparation

Before you test the code below, you need to configure your client application and the MYOB Acumatica instance to be used as follows:
  1. Deploy a new MYOB Acumatica instance with the U100 dataset. For details on deploying an instance, see Instance Deployment: To Deploy an Instance with Demo Data.
  2. On the Enable/Disable Features (CS100000) form, make sure the Projects feature is enabled.
  3. To sign in to the instance in the client application, use the tenant name (which you specified when you created the instance) and the HEADOFFICE branch.
  4. If you are using Postman as the client application for testing, in the IntegrationDevelopmentGuide.postman_collection.json collection, make sure that the collection’s variables have the proper values. This collection is located in the IntegrationDevelopment\Help folder of the Help-and-Training-Examples repository on GitHub.
  5. Execute the following requests:
    1. Create a Project from a Project Template
    2. Make a Project Active
    3. Specify the Next Billing Date for a Project
    4. Retrieve a Project Task
    5. Activate a Project Task
    6. Specify the Progress of a Project Task
    7. Invoke Project Billing
    8. Retrieve the List of Pro Forma Invoices of a Project
    9. Send a Pro Forma Invoice by Email

Requests

You can use the following sequence of examples of HTTP requests to send a pro forma invoice by email through the contract-based REST API. You will use the RefNbr value of the pro forma invoice that is retrieved in Retrieve the List of Pro Forma Invoices of a Project.
Tip: In the request examples below, <MYOB Acumatica instance URL> is the URL of the MYOB Acumatica instance (such as https://my.acumatica.com/MyInstance). You can omit the instance name in the URL (such as https://my.acumatica.com) if the instance is installed in the root of the website.

Do the following:

  1. Send the pro forma invoice by email.
    POST /EmailProFormaInvoice HTTP/1.1
    Host: [<MYOB Acumatica instance URL>]/entity/Default/24.200.001/ProFormaInvoice
    Accept: application/json
    Content-Type: application/json
    
    {
      "entity" : {
        "RefNbr": {
            "value": "000019"
        }
      }
    }
    
    HTTP/1.1 202 Accepted
    Location: [/<MYOB Acumatica instance URL>]/entity/Default/24.200.001/
        ProFormaInvoice/EmailProFormaInvoice/status/a4caa455-0eed-4c11-a5a9-2a8333e53db1
  2. Monitor the status of the operation until the system returns the 204 No Content code.
    GET /EmailProFormaInvoice/status/a4caa455-0eed-4c11-a5a9-2a8333e53db1 HTTP/1.1
    Host: [<MYOB Acumatica instance URL>]/entity/Default/24.200.001/ProFormaInvoice
    Accept: application/json
    Content-Type: application/json
    
    HTTP/1.1 204 No Content

Usage Notes

By using the REST API, you can create pro forma invoices and send them by email. For details about pro forma invoices, see Pro Forma Invoices: General Information.

For a pro forma invoice to be created from a project, the project must have Customer, BillingRule, BillingPeriod, and NextBillingDate specified, and must have the Active status. Because of data validation in the project, NextBillingDate cannot be specified for a project with the In Planning status, and you cannot change the customer in a project with the Active status. Therefore, these settings can be specified only in multiple API calls, as shown in the code examples below.

A ProFormaInvoice entity can be created through the invocation of the RunProjectBilling action of the Project entity. Because email settings are not mapped to any fields of the Project entity, you have to prepare a project template with the specified email settings on the Project Templates (PM208000) form and then use this template for the creation of the project through the API. The project template can also contain preconfigured project tasks, as is the case with the PROGRESS template, which is preconfigured in the U100 dataset and used in this example. For details about project templates, see Project Templates and Common Tasks: General Information.

You may use the following sequence of requests while creating pro forma invoices and sending them by email:

  1. Create a Project from a Project Template
  2. Make a Project Active
  3. Specify the Next Billing Date for a Project
  4. Retrieve a Project Task
  5. Activate a Project Task
  6. Specify the Progress of a Project Task
  7. Invoke Project Billing
  8. Retrieve the List of Pro Forma Invoices of a Project
  9. Send a Pro Forma Invoice by Email