Available Action Scripts

Summary

This document lists available scripts for use as actions in EngageIP. For more information on actions see the article Extending EngageIP With Action Scripts.

Adding Action Scripts

To use these scripts, click on Action link on the Setup page and paste the code in as shown, enter a descriptive name and click Save. The action scripts can then be selected for use under Credit Rating / Payment terms for example.

Late Fee Script - Percentage of Invoice Balance

Note: For late fee scripts, be sure to update the associated Service name to match an existing service in your deployment. The Service name is required for taxing and reporting purposes.

This script will add a late fee calculated as a percentage of the invoice balance based on the value you enter in the 'Rate' field. If you need the system to add a rate like 1.5% rather then a whole number you can convert the rate profile question to a datatype of 'double'. This allows you to enter 1.5 which will be calculated down to 0.015 in the script below.

Under the action created, click add to add a profile question, configure it as below (both for percentage or flat fee). When you add the action to credit rating, it will request the percentage or flat fee you want to add according to the action you've selected in this article.

//Name: LateFeeFlatFee //Description: //EventCode: if (context.ContainsKey("InvoiceID")) { var invoice = Invoice.GetByID(Convert.ToInt32(context["InvoiceID"])); if (Logic.Core.User.GetUserBalance(invoice.UserID) > 0) { var rate = Convert.ToDouble(context["Rate"]); var statement = Logisense.Boss.Logic.Billing.Bill.RetrieveStatement(Logisense.Boss.Logic.Billing.Bill.FindTopLevelParent(invoice.UserID)); using (var invoiceSummaryCalculator = new InvoiceSummaryCalculator(statement)) { Logisense.Boss.Logic.Billing.Bill.AddCharge(statement.ID, invoice.UserID, rate, "Late charge", DateTime.MinValue, DateTime.MinValue, false, invoiceSummaryCalculator, Service.SearchByName("Invoice Late Fee CDN")[0]); invoiceSummaryCalculator.UpdateAggregate(); } } return true; } return false;


To add a GL Code, you can insert a service name as shown in the below script:

if (context.ContainsKey("InvoiceID")) { Invoice invoice = Invoice.GetByID(Convert.ToInt32(context["InvoiceID"])); double rate = Convert.ToDouble(context["Rate"]); double total = Logisense.Boss.Logic.Invoicing.GetInvoiceTotal(invoice); int statementID = Logisense.Boss.Logic.Billing.Bill.RetrieveStatement(Logisense.Boss.Logic.Billing.Bill.FindTopLevelParent(invoice.UserID)); double amount = Logisense.Boss.Logic.Billing.Rounding.Round(total * (rate / 100), 2); Logisense.Boss.Logic.Billing.Bill.AddCharge(statementID, invoice.UserID, amount, "Late charge", DateTime.MinValue, DateTime.MinValue, true,Service.SearchByName("Invoice Late Fee CDN")[0]); return true; } else { return false; }

Late Fee Script - Percentage with No Tax Applied

This script will add a dollar amount late fee to an account as a percentage of the invoice total but will not have taxes applied to the late fee.

//Name: LateFeePercentageNoTaxApplied //Description: //EventCode: if (context.ContainsKey("InvoiceID")) { var invoice = Invoice.GetByID(Convert.ToInt32(context["InvoiceID"])); var rate = Convert.ToDouble(context["Rate"]); var total = Invoicing.GetInvoiceTotal(invoice); var totalTax = 0d; var statement = Logisense.Boss.Logic.Billing.Bill.RetrieveStatement(Logisense.Boss.Logic.Billing.Bill.FindTopLevelParent(invoice.UserID)); foreach (var statementDetail in statement.GetStatementDetailsCollection()) { foreach (var statementDetailsTax in statementDetail.GetStatementDetailsTaxCollection()) { totalTax += statementDetailsTax.Amount; } } total -= totalTax; var amount = Logisense.Boss.Logic.Billing.Rounding.Round(total * (rate / 100), 2); using (var invoiceSummaryCalculator = new InvoiceSummaryCalculator(statement)) { Logisense.Boss.Logic.Billing.Bill.AddCharge(statement.ID, invoice.UserID, amount, "Late charge", DateTime.MinValue, DateTime.MinValue, false, invoiceSummaryCalculator, Service.SearchByName("Invoice Late Fee CDN")[0]); invoiceSummaryCalculator.UpdateAggregate(); } return true; } return false;

Late Fee Script - Flat Fee

The script below adds a flat fee when credit rating runs and the invoice has an overdue balance.

Send Email Script - Standard

This script sends an email when an invoice has an overdue balance. The profile questions will take the name of the email message setup under 'email messages' on the setup page.

Send Email if User Status IS NOT 'Canceled'

Note: this script references the back end status, not the defined label status on the setup tab. Available back end statuses are 'Canceled', 'Active', 'Suspended' and 'Prospect'.

Set User Status where NOT 'Canceled'

Similar to above, an if statement will set the user status when the account is not in a status of 'canceled'.

Note: When setting an account status to canceled the system will cancel any packages and add a prorated refund by default. If you do not want a prorated refund you can create a status of 'Suspended' with a back end status of 'Active'. You can then track who has this status and perform administrative tasks on them as needed, enable, charge credit card manually, etc.

Balance Threshold Wrappers

This script is used to include thresholds like invoice balance thresholds into the logic, see below options. For assistance on using these, please contact LogiSense customer support.

LogiSense Support  

email: support@logisense.com

phone (Canada): 1-519-249-0508

phone (USA): 1-917-410-3584

 

The below script checks profile question on the action called 'Threshold' and will only execute its payload (in this case an email user script) if the invoice balance is greater than x (as //configured in the profile question.


Second Example - To run the payment term IF the recurring total is greater then y, use the following script which will send an email but can be implanted with other action scripts to do things like applying a late fee or other functionality.

On each action you will need to add these Profile Questions:

Name

DataType

Threshold

Double

EventLogMessageOnThresholdNotMet

Text

EmailMessage

Text

Write Off

This write off script requires two profile questions on action:

  • EventLogMessage - Profile question with a datatype of text. This message will be added to the Event Log report if the user is NOT canceled. Otherwise there is Event Log text in the action that can be adjusted

  • UserStatus - this is the status to which you would like the user to be set, i.e. you should have a status named 'Write Off' and that value should be in the profile question as well. The name needs to match the status type exactly

This write off script is fired by payment terms for invoices that are past due by a set amount. It will set the user status on the account to that which you have selected and add a credit to the account to zero out the accounts balance effectively removing it from reports (because its balanced).