Create an ad-hoc credit memo from an invoice, and enable 'Apply to this invoice upon posting'. Fail to post this credit memo due to 'The balance on the target item wit id X is 0, cannot be applied. Please update your request and try again.' or 'The apply amount X is greater than the balance X on the target item with id X. Please update your request and try again.'
Solved! Go to Solution.
The behavior when posting a credit memo with "applyUponPosting" true, the credit memo will be auto applied to the invoice. And we have a rule that each credit memo item will be applied to the invoice item from which it is created from.
Following is an example:
1. Invoice1($300) with InvoiceItem1($100) and InvoiceItem2($200).
2. We assume a payment is applied to InvoiceItem1 with $100 making its balance 0. Now InvoiceItem1_balance = 0 and InvoiceItem2_balance=$200.
3. A credit memo CM1 is created from Invoice1. CMI1($10) is created from InvoiceItem1, and CMI2($20) is created from InvoiceItem2.
4. When posting CM1 with applyUponPosting=true, CMI1 will be applied to InvoiceItem1 and CMI2 will be applied to InvoiceItem2.
5. Because InvoiceItem1_balance=0, CMI1 can not be applied to InvoiceItem1.
Error message will be like "The balance on the target item with id IdofInvoiceItem1 is 0, cannot be applied. Please update your request and try again."
That is the reason why the total balance of Invoice1 is $200, CM1's total amount is $30, but it failed to apply CM1 to invoice1.
Please set 'Apply to this invoice upon posting' flag to false. Post the credit memo first. And then apply this credit memo to the invoice.