actionID()
Last updated 31/01/2024
The function calculates the total using the values in the Quantity
, Price
, and Fees
fields. If the action ID returns Buys
the fees are added, otherwise the fees will be
deducted.
Check if the action ID equals Buys
function CalculateTotal(five, context, result) {
if (five.actionID() === 'Buys') {
five.field.Total = five.field.Quantity * five.field.Price + five.field.Fees;
} else {
five.field.Total = five.field.Quantity * five.field.Price - five.field.Fees;
}
return five.success();
}
Check if the action ID equals Buys
function CalculateTotal(five: Five, context: any, result: FiveError) : FiveError {
if (five.actionID() === 'Buys') {
five.field.Total = five.field.Quantity * five.field.Price + five.field.Fees;
} else {
five.field.Total = five.field.Quantity * five.field.Price - five.field.Fees;
}
return five.success();
}