Generate Payable Invoice from Expense Report

Problem

You have expense reports in PSA but need to generate payable invoices in your accounting system for reimbursement.

Solution

Create ClickLink rules using ClickLink to convert PSA expense reports to payable invoices in Accounting:

  1. Add the following custom fields to the PSA Expense Report object.
    • Sent_to_Accounting (checkbox)
    • Employee Account (text formula 'PSA User (Employee)')
    • Payable Reference (text formula TEXT( pse__First_Expense_Date__c )). This generates a text version of the first expense date. This will be used for the payable invoice reference.
  2. Add the following custom fields to the Accounting Payable Invoice object:
    • Expense Report (Lookup to PSA expense report)
  3. Add the following custom fields to the Expense object:
    • Expense GLA (text formula). The formula should contain CASE(TEXT( pse__Type__c), TypeName, TypeID). Where TypeName, TypeID reflect the data in your system. Your formula might look something like this:

      CASE(TEXT( pse__Type__c),'Airfare','6090 - Travel','Lodging (Room and Tax)','6092 - Lodging','Car Rental','6096 - Other Travel','Gasoline','6096 - Other Travel','Taxi','6096 - Other Travel','Subway','6096 - Other Travel','Auto Mileage','6096 - Other Travel','Personal Meals','6091 - Meals','Business Meals','6091 - Meals','Phone','6170 - Telephone','Office Supplies and Services','6080 - Office Expense','IT Equipment and Services','6080 - Office Expense','Postage and Shipping','6080 - Office Expense','General and Admin Expenses','6080 - Office Expense','Employee Relations','6080 - Office Expense','Recruiting','6080 - Office Expense','Miscellaneous','6080 - Office Expense','6096 - Other Travel')

    Note:

    The entries that you include here must exist as General Ledger account records in Accounting.

  4. Add the following custom fields to the Payable Invoice Expense Line Item object:
    • Project (lookup to Project in PSA)
    • SetGLAToDefault (checkbox)
  5. Create a ClickLink rule to convert an expense report to a payable invoice:
    Recommended Values for the Create Payable Invoice from Expense Report ClickLink Rule
    ItemValue
    ClickLink Rule NameCreate Payable Invoice from Expense Report
    Source Objectpse__Expense_Report__c
    Source Object Name FieldName
    Source Object Processed Field Sent_to_Accounting__c
    Target Objectc2g__codaPurchaseInvoice__c
    Target Object Name FieldName
  6. Create these ClickLink mappings for the ClickLink rule you created in the previous step:
    Recommended Mappings for the Create Payable Invoice from Expense Report ClickLink Rule
    Target Record Created FromMapping TypeSource FieldTarget Field
    Source RecordSource Fieldpse__Description__cc2g__InvoiceDescription__c
    Source RecordSource Fieldpse__Last_Expense_Date__cc2g__InvoiceDate__c
    Source RecordSource Field pse__Project__cProject__c
    Source RecordSource FieldNameExpense_Report__c
    Source RecordSource FieldEmployee_Account__cc2g__Account__c
    Source RecordSource FieldPayable_Reference__cc2g__AccountInvoiceNumber__c
  7. Create a ClickLink rule to convert a PSA expense to a payable expense line:
    Recommended Values for the Create Payable Expense Line from PSA Expense ClickLink Rule
    ItemValue
    ClickLink Rule NameCreate Payable Expense Line from PSA Expense
    Source Objectpse__Expense__c
    Source Object Name FieldName
    Target Objectc2g__codaPurchaseInvoiceExpenseLineItem__c
    Target Object Name FieldName
  8. Create these ClickLink mappings for the ClickLink rule that you created in the previous step:
    Recommended Mappings for the Create Payable Expense Line from PSA Expense ClickLink Rule
    Target Record Created FromMapping TypeMapping LiteralSource FieldTarget Field
    Source RecordSource Field  pse__Reimbursement_Amount__cc2g__NetValue__c
    Source RecordSource Field Expense_GLA__cc2g__GeneralLedgerAccount__c
    Source RecordSource Field  pse__Description__cc2g__LineDescription__c
    Source RecordSource Field pse__Project__cProject__c
    Source RecordLiteral0 ffap__SetGLAToDefault__c
  9. Create a Visualforce page to convert a single Expense Report to a Payable Invoice. You can use the following Visualforce markup:

    <apex:page standardController="pse__Expense_Report__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}">

    <ffirule:IntegrationRule engine="{!engine}"/></apex:page>
  10. Create a Visualforce page to convert payable invoices to expense reports. You can use the following Visualforce markup:

    <apex:page standardController="pse__Expense_Report__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}" recordSetVar="records">

    <ffirule:IntegrationRule engine="{!engine}"/></apex:page>
  11. In the Create Payable Invoice from Expense Report ClickLink rule, create ClickLink buttons for the Visualforce pages that you created in the previous step.
  12. In the Expense Reports object, create custom buttons that reference the Visualforce pages you created in the previous step.
  13. Add the Create Payable Invoice custom button to the Expense Report page layout
  14. Add the Create Payable Invoices custom button to the Expense Reports List View search layout.
  15. Create the following ClickLink relationship:
    Recommended Relationship for the Create Payable Invoice from Expense Report ClickLink Rule
    ClickLink Relationship NameRelationship NameRelationship ClickLink Rule Relationship Target Field
    Expense Lines to Expense Reportpse__Expense_Lines__rCreate Payable Expense Line from PSA Expensec2g__PurchaseInvoice__c

To test the ClickLink rule, create an expense report in PSA with approved expenses and click Create Payable Invoice. A payable invoice is created in Accounting with the expenses on the expense report from PSA.