I currently have a (script-runner) scripted field in an "Order Request" called "Total Order Expense($)" which calculates the sum of all linked "line item orders".
I have added an RMA issue type which is also linked to the "Order Request" which is how we track returned items. This has a calculated field called "Return Amount" which needs to be subtracted from the "Total Order Expense ($) field in the order request.
Below is the script i use to calculate the "Total Order Expense ($) now. How would I include the ability to subtract the "Return Amount" from that number?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def csExpense = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Expense")
return issue.getSubTaskObjects().sum{it ->((Issue) it).getCustomFieldValue(csExpense)};