Skip to content

Instantly share code, notes, and snippets.

@sreynard
sreynard / MortgageCalculator.txt
Last active August 29, 2015 14:01 — forked from cba2ry/MortgageCalculatorWithMagic.txt
Apex Plug-In that calculates monthly payment (for Force.com Cloud Flow Designer Workbook)
global class MortgageCalculator implements Process.Plugin
{
global Process.PluginResult invoke(Process.PluginRequest request)
{
Double amount = (Double)request.inputParameters.get('Amount');
Double term = (Double)request.inputParameters.get('Term');
// in addition to to adding the calculation below, to use this in the Visual Workflow Workbook, tutorial #3,
// a third input called "Rate" will need to be defined for the calculate quote step: the screen input field "Interest_Rate".
Double rate = (Double)request.inputParameters.get('Rate');
Double monthlyrate = rate/(12*100);
@sreynard
sreynard / MortgageCalculatorTest.txt
Last active August 29, 2015 14:01
Test class for Apex Plug-In that calculates monthly payment (for Force.com Cloud Flow Designer Workbook)
@isTest
global class MortgageCalculatorTest {
public static testmethod void testAll()
{
MortgageCalculator plugin = new MortgageCalculator();
Map<String,Object> inputParams = new Map<String,Object>();
Double amount = 500000;
Double term = 360;
Double rate = 5;
inputParams.put('Amount', amount);