Purpose
The purpose of this Administrator Guide is to provide information about Utilities packaged Purchase Orders. The intended audience for this document is System Administrators/Payroll Users. If your Org does not have access to the Purchase Order object, you will need to contact 2cloudnine to discuss the suitability of installing the 2cloudnine Utilities Extension Package.Overview
The new custom object Purchase Order serves as the primary record to capture important details related to a Client’s Purchase Order. After creating the Purchase Order records, they are linked to an Assignment using a Purchase Order Junction record. To learn more, please refer to the QRG Creating Purchase Orders and QRG Creating Purchase Order Junctions.Assignment Setup
The following relates to the configuration of Timesheet Assignments and related Assignment Rates when utilising PO Management. This is based on using the ‘Process PO Allocation’ logic, which is designed with the assumption of Assignments defining if a Purchase Order is required, and that Pay Transactions cannot be invoiced until they have a Purchase Order. Exceptions to this include the Invoice without PO Depletion Rule (refer to QRG Create a Purchase Order - Utilities) and Assignment Rates > Pay Codes that can be invoiced without a Purchase Order. IMPORTANT: If using an alternative Process PO Allocation logic, this step may not be required based on your defined process logic. Assignment Requires Purchase Order To enable Purchase Order Management for an Assignment, you must select the checkbox Requires Purchase Order. Populating the ‘To Be Invoiced?’ field on Assignment Rates To ensure Pay Transactions that require Purchase Orders are not invoiced before being assigned a Purchase Order, the Pay Transactions must ensure the field ‘To Be Invoiced?’ is ‘No’ upon creation. The ‘To Be Invoiced?’ field on the Pay Transaction is defaulted from the ‘To Be Invoiced’ field on the related Assignment Rate. For this, it is required that any Assignments and related Assignment Rate > Pay Codes that require a Purchase Order, you must ensure the ‘To Be Invoiced’ field on the related Assignment Rates is not updated to Yes. Failure to populate the To Be Invoiced field on the Assignment correctly will result in Pay Transactions being generated with To Be Invoiced? Field as TRUE, causing the default Process PO Allocation to be FALSE, and the Pay Transactions will not be processed by the PO Management process. To ensure Pay Transactions that require Purchase Orders are correctly processed, we recommend one of the following approaches:- Flow (Recommended) Utilising two record-triggered Flows is a simplistic and recommended solution for this requirement: The first Flow should run on the creation or update of Assignment Rates using the following criteria:
- Assignment Rate > Assignment > ‘Requires Purchase Order’ = TRUE.
- Assignment Rate > Pay Code > PO Allocation Type != NULL The second Flow runs on the update of an Assignment where Requires Purchase Order is set to TRUE. This Flow will then find all Active or Pending Assignment Rates where the Assignment Rate > Pay Code > PO Allocation Type != NULL, and update the Assignment Rate field ‘To Be Invoiced’ to ‘No’. IMPORTANT: This approach has been previously delivered for Customers and can be deployed into another Org upon request to 2cloudnine.
- Defaulting ‘To Be Invoiced?’ as ‘No’. This solution applies a standardised approach by defaulting the field ‘To Be Invoiced’ to ‘No’ for all Timesheet Assignment Rates. This means all Pay Transactions cannot be invoiced until this field is updated. Where there are Pay Transactions that do not require a Purchase Order, a Purchase Order related to the Assignment Rate is still configured, but with a Depletion Rule of Invoice without PO, and the PO Allocation Type set to those Pay Transactions that do not require a Purchase Order. Whilst this approach is simpler in terms of configuration, it creates an administrative overhead, as every Assignment that does not require a Purchase Order still goes through the PO Management process before being invoiced.
Process PO Allocation on Pay Transactions
To utilise the PO Management functionality, Pay Transactions must be flagged for PO processing. There are two ways to determine which Pay Transactions should be processed: Default Process PO Allocation The PO Management functionality includes a default formula field on the Pay Transaction named Process PO Allocation. This formula field returns TRUE when the following criteria are met:- Assignment > Requires Purchase Order = TRUE
- Invoice Rate != 0
- Invoice Item = NULL
- Purchase Order = NULL
- To Be Invoiced? = FALSE
- Assignment > Requires Purchase Order = TRUE
- Invoice Item = NULL
- Purchase Order = NULL
- Non-payment Pay Transactions (e.g. Superannuation transactions) being processed.
- Purchase Orders being overridden on Pay Transactions already invoiced.
Important Notes(Alternate Custom Method)Purchase Order Management can be processed using an alternate custom method by invoking the
global Apex Class ‘apex-SkiePurchaseOrderManagementInvocable’.This field should return FALSE at the conclusion of the PO Allocation. The Custom Formula Field must
contain ‘PURCHASE ORDER = NULL’ to ensure that once the Purchase Order has been applied, it is
not processed again.
Update Pay Codes
In order for Pay Transactions to be correctly processed, all Payment, Allowance, and Expense Pay Codes must have the field PO Allocation Type populated. The Global Value Set PO Allocation Types contains by default, the options for Payment, Allowance & Expense, but can be updated to include any Customer requirements, allowing for granular allocation of Pay Transactions to Purchase Orders.Pay Transaction Trigger
To aggregate the value of processed Pay Transactions against their related Purchase Orders, a Trigger named Trg_PayTxn_Staffing has been implemented on the Pay Transaction. This Trigger runs on the following events: after insert, after update, before delete, and after undelete. Its purpose is to ensure that the Invoice Total Ex. Tax value from a Pay Transaction is accurately reflected in the Current Spend field of the associated Purchase Order. When a Pay Transaction is linked to a Purchase Order, it adds the value of Invoice Total Ex. Tax to the Purchase Order’s Current Spend. If the Purchase Order is removed from the Pay Transaction, or the Pay Transaction is deleted, the trigger subtracts the corresponding value from the Current Spend. In the case of an undeleted Pay Transaction, the value is added back to the related Purchase Order. This ensures that the Current Spend on each Purchase Order remains accurately updated based on the total of all associated Pay Transactions.Include PO in Invoice Grouping
Purchase Order Management allows you to automatically append the Purchase Order ID to the Invoice Group By ID of processed Pay Transactions, ensuring Invoices are uniquely grouped by Purchase Order. Without this setting, even though Purchase Order Numbers are applied to Pay Transactions, the resulting Invoices may include multiple Purchase Orders in a single document. For clients who require one Purchase Order per Invoice, this feature eliminates the need for custom logic. This can be configured per Customer via the Invoice Setting record using the Include PO in Invoice Grouping field:- If set to Yes, the Purchase Order ID will be appended to the Invoice Group By ID of each processed Pay Transaction.
- If set to No or left blank, the Purchase Order will still be applied to the Pay Transaction, but it will not affect Invoice Grouping.
Project Code Allocation
The PO Management functionality also supports the allocation of Purchase Orders to Project Codes. This optional functionality can be used for project-based Purchase Order allocation. Only Assignment Level Project Codes can be related to a Purchase Order, allowing for a single Project Code to be assigned to a single Purchase Order. When an Assignment Level Project Code is updated with a Purchase Order, during the PO Allocation process, the Flow checks if the Pay Transaction > Project Code > Purchase Order matches the found Junction > Purchase Order. If found, the Purchase Order will be allocated to the Pay Transaction. If it does NOT match the found Junction > Purchase Order, the Purchase Order will not be allocated to the Pay Transaction and will continue with the PO Allocation Process.PO Management and Timesheet Adjustments
When using both the PO Management and Timesheet Adjustment functionality together, it is critical to understand the impact Timesheet Adjustments have on Pay Transactions assigned to Purchase Orders. When a Timesheet Adjustment is processed, the original Pay Transactions will remain linked to the Purchase Order. However, the newly created reversal (negative) Pay Transactions will not. This is intentional, as the negative Pay Transactions need to be picked up by the PO Management process to correctly reapply the negative amount back to the Purchase Order. IMPORTANT : By default, reversal Pay Transactions created by the Timesheet Adjustment process have the ‘To Be Invoiced?’ field set to TRUE. If left unchanged, when running the standard Process PO Allocation, these reversal Pay Transactions will not be assigned to a Purchase Order — meaning the negative value will not be reapplied. To address this, we recommend using a fast action Record-Triggered Flow on the Pay Transaction. This Flow should automatically set ‘To Be Invoiced?’ to FALSE on the reversal Pay Transactions if the related Original Pay Transaction is linked to a Purchase Order. This ensures the negative value is correctly returned to the Purchase Order when both PO Management and Timesheet Adjustment functionalities are in use.Process PO Allocation Setup
To accommodate the many variables between clients and their timings, as well as impacts on downstream invoicing, there are two options for triggering the PO Allocation Process. Both options can be used together, offering maximum flexibility in determining when Purchase Orders should be processed. Scheduled Batch Job The first option is to schedule a Batch Job that allocates Pay Transactions to Purchase Orders at defined intervals. The key consideration is timing — if invoicing occurs shortly after Pay Transactions are generated, ensure the Batch Job runs frequently enough to avoid delays (i.e. hourly). In typical Orgs, scheduling hourly or even daily is sufficient, as invoicing generally occurs after Payroll is complete. To run the script hourly :- Copy the block of script to be run.
- Select Setup > Developer Console .
- Debug > Open Execute Anonymous Window .
- Delete or comment out any code that is in the window.
- Paste in the copied script from below.
- Click the Execute button.
Script
Script
- Select Activate .
Important Notes(Process PO Allocation)This Flow is considered optional and is used to support the PO Management process. Without this
Flow, the PO Management can still be used but will require other methods to run the PO
Management Apex Class.
- Select your desired app and select Edit using the drop-down.
- Select Utility Items .
- Select Add Utility Item .
- Search for and select Flow .
- Complete all fields and ensure in the Flow lookup you select 2c9 Utilities - Process PO Allocation .
- Select Save .
Important Notes(Flow within Utility Bar)If using a Managed Package App, it is not possible to add a Utility Bar. You must either create a new
App or utilise an App Record Page to host the ‘2c9 Utilities - Process PO Allocation’ Flow.
Update Custom Settings (Optional)
The PO Management functionality uses a Custom Setting 2c9 - PO Management Settings to define certain variable data. There are two optional settings available to be updated. ApexClass Id This setting must be populated if you are using the Process PO Allocation. Failure to provide the Apex Class Id will result in the Flow failing to successfully complete. To populate the Custom Setting: Go to Setup - Developer Console- Select the Query Editor tab near the bottom.
- Paste the following text and then select the Execute button:
SELECT Id, Name FROM ApexClass WHERE Name = 'PurchaseOrderManagementInvocable'
- Copy the value in the ID field.
- Go to Setup > Custom Settings > 2c9 - PO Management Settings > Manage
- Select the New button in the top half of the page.
- Enter the copied Apex Class ID into the Apexclass Id field.
- Select Save.
- Select Edit or the New button from the top half of the page (if not done in other configuration).
- Enter the API name of the Custom Boolean Field into the Custom Process PO Allocation field.
- Select Save .
Update Custom Metadata Types (Conditionally Compulsory)
If Customers will be utilising the function to automatically include the Purchase Order Id into the Invoice Group By ID (see Include PO in Invoice Grouping), this step is required. The purpose of this is to allow the Purchase Order Number and Invoice Group By ID fields to be overwritten from the PO Management process. Failure to configure this step will result in the Product triggers overwriting these Fields. To update the Custom Metadata Types: Go to Setup - Custom Metadata Types - T2P Pay Transaction Override Setting - Manage Records- Select the New button.
- Enter the following details:
- Label = Purchase Order Number
- T2P Pay Transaction Override Setting Name = Purchase_Order_Number
- Pay Transaction Field API Name = tc9_et__Purchase_Order_Number__c
- Override on Insert = Yes
- Override on Update = Yes
- Select Save .
- Select the New button again.
- Enter the following details:
- Label = Invoice Group By ID
- T2P Pay Transaction Override Setting Name = Invoice_Group_By_ID
- Pay Transaction Field API Name = tc9_et__Invoice_Group_By_ID__c
- Override on Insert = Yes
- Override on Update = Yes
- Select Save .
Mapping
During the allocation of a Purchase Order to a Pay Transaction, the PO Management process will utilise the following mapping:Important Notes(Current Spend field)This uses a combination of the Depletion Rule and Remaining Spend when determining which
Purchase Order to allocate. If the Invoice Total Ex Tax was $1000, then the Pay Transaction could be
allocated to a PO Junction with a Depletion Rule of ‘Overspend’ and a Remaining Spend below
$1,000. If the Purchase Order Junction has a Depletion Rule of ‘Hold Off’, then it would NOT allocate to
that Purchase Order and instead look for the next available one.