Skip to main content

Revenue Cloud Credit Memo API: Choosing the Right Tax Strategy

When creating Credit Memos programmatically through the Salesforce Commerce Invoicing API, one of the most consequential decisions is the taxStrategy parameter. Choosing the wrong strategy -- particularly for partial credits -- can result in over-crediting tax, under-crediting tax, or bypassing tax treatment entirely. Each option has specific behavior that is not immediately obvious from the API documentation.

The Three Tax Strategy Options

CopyFromInvoiceLine

This strategy copies the tax amount directly from the referenced Invoice Line to the Credit Memo Line.

Critical gotcha: CopyFromInvoiceLine does not prorate tax for partial credits. If the original Invoice Line has $100 in charges and $8.25 in tax, and you issue a credit for $50 (half the amount), the API still copies the full $8.25 tax to the Credit Memo Line.

This means a 50% partial credit would actually credit $50.00 + $8.25 = $58.25 instead of the expected $50.00 + $4.13 = $54.13. Over time, this discrepancy compounds and creates reconciliation problems.

When to use: Only when issuing a full credit for the entire Invoice Line amount, where the full tax amount is also being reversed.

Ignore

This strategy sets the tax amount on the Credit Memo Line to zero, regardless of the original Invoice Line's tax.

When to use: When tax is handled externally -- for example, when a downstream ERP system calculates and manages tax independently, or when the credit is for a non-taxable adjustment. This is also appropriate when an external tax engine will recalculate after the Credit Memo is created.

ManualOverride

This strategy allows you to specify the exact tax amount on each Credit Memo Line. The API accepts whatever value you provide without validation against the original Invoice Line.

When to use: For partial credits where tax must be prorated proportionally. You calculate the correct tax amount in your code and pass it explicitly.

Why ManualOverride Is Usually Correct

Most real-world credit scenarios involve partial credits: a customer is credited for a portion of an invoice due to a quantity adjustment, a pricing correction, or a partial return. In all of these cases, tax must be credited proportionally to the amount being credited.

The proportional tax calculation is straightforward:

creditTaxAmount = originalTaxAmount * (creditAmount / originalChargeAmount)

For example, crediting $50 of a $100 line with $8.25 tax:

creditTaxAmount = 8.25 * (50.00 / 100.00) = 4.13 (rounded)

API Request Example

The following JSON shows a Credit Memo creation request using ManualOverride with a proportionally calculated tax amount:

{
"invoiceId": "0Bt000000000001AAA",
"creditMemoLines": [
{
"invoiceLineId": "0Bv000000000001AAA",
"quantity": 5,
"amount": 50.00,
"taxAmount": 4.13,
"taxStrategy": "ManualOverride",
"description": "Partial credit - quantity adjustment"
},
{
"invoiceLineId": "0Bv000000000002AAA",
"quantity": 2,
"amount": 200.00,
"taxAmount": 16.50,
"taxStrategy": "ManualOverride",
"description": "Partial credit - pricing correction"
}
]
}

Each line in the creditMemoLines array references a specific Invoice Line and specifies the credited quantity, amount, and the manually calculated tax.

Decision Matrix

ScenarioRecommended StrategyReason
Full credit of entire Invoice LineCopyFromInvoiceLineFull tax reversal matches original
Partial credit (quantity or amount)ManualOverrideTax must be prorated; Copy does not prorate
Tax handled by external systemIgnoreAvoid double-counting tax
Non-taxable credit adjustmentIgnoreNo tax component to credit
Mixed partial and full creditsManualOverride on all linesConsistent handling; works for both cases

Implementation Considerations

  • Rounding: When calculating proportional tax, round to 2 decimal places. Use Decimal.setScale(2, RoundingMode.HALF_UP) in Apex to ensure consistent rounding.
  • Validation: Before issuing credits, query the original Invoice Line to get the current charge amount and tax amount. Do not rely on cached or stale values.
  • Audit trail: Store the calculation inputs (original amount, original tax, credit amount) in a description or custom field for traceability during reconciliation.

Getting the tax strategy right on the first implementation avoids painful retroactive corrections to already-posted Credit Memos.