-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Allocate tax loss to tax account head on early payment discount #34287
Conversation
- Deductions in payment entry must be split into income loss and tax loss - Compute total discount in percentage, makes discounting different amounts proportionately easier
- Use field precision to get more accurate values
- Discount value was always trated as a percentage on back updation
…n discount % test
- Even via JS, deductions amount is always in company currency - Since there is nothing dynamic about this field, set it in the doctype spec itself - fixed: Inconsistency between label currency and field currency formatted value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to create PE from a SI in company currency
- ... with multiple tax rows and early payment discount
- ... with a single tax row and no early payment discount
This worked very well 👍🏼
What didn't work correctly was to create a SI in another currency, while the GL entries use base amounts / company currency. In this case, the paid amount (in company currency) was wrong.
- misc: better docstring
- Accounting is in the same currency if party currency and company currency is the same - If accounting is in the same currency, paid and recvd amount is in the base currency - Then, discount amount must also be in the base currency as it is deducted from paid amount - Received amount must be in base currency if not multi currency - cleanup: Deductions setting broken into smaller functions
- Return total discount loss in base currency - Allocate payment based on terms: Set allocated amount in references table in base currency if accounting is in that currency - Allocate payment based on terms: While back updating set paid amount (payment schedule) in transaction currency always - minor: discount msgprint in correct currency
…rency accounting + Early payment discount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issues from the last review have been resolved. 👍🏼
Something that should go into the docs is that this feature (currently) only works when mapping a payment from an invoice, not when creating a payment and then fetching outstanding invoices.
One small annoyance I encountered was that with odd amounts I can get an additional deduction of 0.01
. For example, when two deductions have been rounded down but the difference adds up to > 0,005
. This deduction of 0.01
has no account set. We could either set the company's Default Round Off Account here or change the calculation method to avoid rounding differences. This can be recreated with the example SI and PE from the last review.
- Round off pending discount loss to avoid miniscule losses rounded to 0.0 that are added in deductions - Use base amounts to calculate base losses instead of using conversion factor which increases rounding error - Round of total base loss instead of individual income and tax losses to reduce rounding error - Use default round off account for pending rounding loss in deductions
… late - Party could have paid on time but payment is recorded late - Prompt for reference date so that discount is applied while mapping - Prompt only if discount in payment schedule of valid doctypes - test: Reference date and impact on PE - `make_payment_entry` (JS) must be able to access `this`
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #34287 +/- ##
===========================================
+ Coverage 63.80% 63.83% +0.03%
===========================================
Files 810 810
Lines 59524 59596 +72
===========================================
+ Hits 37977 38045 +68
- Misses 21547 21551 +4
|
@deepeshgarg007 Mind taking a look 👀? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tax loss booking should be optional IMO. In most case this is Non Trade (Cash Discount) and don't affect tax, at least this how it is in India
Also the docs link says v13, should be v14
A supplier can reduce their GST liability when granting a cash discount, provided certain conditions are met. According to Section 15(3) of the CGST Act, 2017, the value of the supply shall not include any discount if:
By meeting these conditions, the supplier can effectively reduce the taxable value of the supply, resulting in a lower GST liability. However, it is essential to ensure that all applicable conditions are met and necessary documentation is maintained to support the reduction in GST liability. Summarized from https://carajput.com/learn/whether-liable-to-gst-on-discount-received-for-early-payments.html Under the GST regime, Section 15 of the CGST Act, 2017 governs discounts. Discounts given before or at the time of supply can be reduced from the taxable value if mentioned on the invoice. Discounts given after the supply can also be reduced from the taxable value if the discount is agreed upon before the supply, linked to a specific supply invoice, and the Input Tax Credit (ITC) attributable to the discount is reversed by the buyer. GST liability of the supplier can be reduced if both the supplier and receiver are aware of the discount before supply. There is no differentiation between trade and cash discounts in GST; instead, they are segregated into two categories: those given before or at the time of supply, and those given after the time of supply. Summarized from https://taxguru.in/goods-and-service-tax/tax-treatment-tradecash-discounts-gst-regime.html |
@barredterra Didn't exactly get your last response, are you suggesting the tax loss booking should not be optional? |
I couldn't access the information you pointed to (blocked in Europe), but the articles I found seemed to support our use case. ("GST liability of the supplier can be reduced if both the supplier and receiver are aware of the discount before supply. There is no differentiation between trade and cash discounts in GST") Anyway, making it configurable shouldn't be an obstacle. First rule of ERPs: everything must be configurable. 😅 |
- Checkbox in Accounts Settings - Apply checkbox in PE deductions setting logic - Adjust tests
@deepeshgarg007 It is configurable now in the Accounts Settings (see description). Do let me know if any other major changes are needed |
…34287) * fix: Taxes aren't discounted on early payment discount - Deductions in payment entry must be split into income loss and tax loss - Compute total discount in percentage, makes discounting different amounts proportionately easier (cherry picked from commit 768c3a4) * fix: Recalculate difference amount after setting deductions (cherry picked from commit 75ec0a0) * fix: Set deductions in base currency - Use field precision to get more accurate values (cherry picked from commit dc2998f) * fix: Back update discounted amount in Invoice based on discount type - Discount value was always trated as a percentage on back updation (cherry picked from commit 2ae5834) * test: PE from SI with early payment discount amount & PE assertions in discount % test (cherry picked from commit c217bb2) * fix: Set deduction amount in company currency on Doctype - Even via JS, deductions amount is always in company currency - Since there is nothing dynamic about this field, set it in the doctype spec itself - fixed: Inconsistency between label currency and field currency formatted value (cherry picked from commit 7f2e7ba) * fix: Don't add to deductions if amount is 0 - misc: better docstring (cherry picked from commit f02fc8a) * fix: Paid amount must be discounted considering accounting currency - Accounting is in the same currency if party currency and company currency is the same - If accounting is in the same currency, paid and recvd amount is in the base currency - Then, discount amount must also be in the base currency as it is deducted from paid amount - Received amount must be in base currency if not multi currency - cleanup: Deductions setting broken into smaller functions (cherry picked from commit 761f68d) * fix: Multi-currency SI with base currency PE - Return total discount loss in base currency - Allocate payment based on terms: Set allocated amount in references table in base currency if accounting is in that currency - Allocate payment based on terms: While back updating set paid amount (payment schedule) in transaction currency always - minor: discount msgprint in correct currency (cherry picked from commit b09c238) * test: Multi currency SI with multi-currency accounting and single currency accounting + Early payment discount (cherry picked from commit 9abf0ef) * fix: Handle rounding more gracefully - Round off pending discount loss to avoid miniscule losses rounded to 0.0 that are added in deductions - Use base amounts to calculate base losses instead of using conversion factor which increases rounding error - Round of total base loss instead of individual income and tax losses to reduce rounding error - Use default round off account for pending rounding loss in deductions (cherry picked from commit caa1a3d) * fix: Provision to apply early payment discount if payment is recorded late - Party could have paid on time but payment is recorded late - Prompt for reference date so that discount is applied while mapping - Prompt only if discount in payment schedule of valid doctypes - test: Reference date and impact on PE - `make_payment_entry` (JS) must be able to access `this` (cherry picked from commit d6d0163) * feat: Make Tax loss booking optional - Checkbox in Accounts Settings - Apply checkbox in PE deductions setting logic - Adjust tests (cherry picked from commit 216a46b) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json * fix: Merge conflicts --------- Co-authored-by: marination <[email protected]>
…34287) * fix: Taxes aren't discounted on early payment discount - Deductions in payment entry must be split into income loss and tax loss - Compute total discount in percentage, makes discounting different amounts proportionately easier (cherry picked from commit 768c3a4) * fix: Recalculate difference amount after setting deductions (cherry picked from commit 75ec0a0) * fix: Set deductions in base currency - Use field precision to get more accurate values (cherry picked from commit dc2998f) * fix: Back update discounted amount in Invoice based on discount type - Discount value was always trated as a percentage on back updation (cherry picked from commit 2ae5834) * test: PE from SI with early payment discount amount & PE assertions in discount % test (cherry picked from commit c217bb2) * fix: Set deduction amount in company currency on Doctype - Even via JS, deductions amount is always in company currency - Since there is nothing dynamic about this field, set it in the doctype spec itself - fixed: Inconsistency between label currency and field currency formatted value (cherry picked from commit 7f2e7ba) * fix: Don't add to deductions if amount is 0 - misc: better docstring (cherry picked from commit f02fc8a) * fix: Paid amount must be discounted considering accounting currency - Accounting is in the same currency if party currency and company currency is the same - If accounting is in the same currency, paid and recvd amount is in the base currency - Then, discount amount must also be in the base currency as it is deducted from paid amount - Received amount must be in base currency if not multi currency - cleanup: Deductions setting broken into smaller functions (cherry picked from commit 761f68d) * fix: Multi-currency SI with base currency PE - Return total discount loss in base currency - Allocate payment based on terms: Set allocated amount in references table in base currency if accounting is in that currency - Allocate payment based on terms: While back updating set paid amount (payment schedule) in transaction currency always - minor: discount msgprint in correct currency (cherry picked from commit b09c238) * test: Multi currency SI with multi-currency accounting and single currency accounting + Early payment discount (cherry picked from commit 9abf0ef) # Conflicts: # erpnext/accounts/doctype/payment_entry/test_payment_entry.py * fix: Handle rounding more gracefully - Round off pending discount loss to avoid miniscule losses rounded to 0.0 that are added in deductions - Use base amounts to calculate base losses instead of using conversion factor which increases rounding error - Round of total base loss instead of individual income and tax losses to reduce rounding error - Use default round off account for pending rounding loss in deductions (cherry picked from commit caa1a3d) * fix: Provision to apply early payment discount if payment is recorded late - Party could have paid on time but payment is recorded late - Prompt for reference date so that discount is applied while mapping - Prompt only if discount in payment schedule of valid doctypes - test: Reference date and impact on PE - `make_payment_entry` (JS) must be able to access `this` (cherry picked from commit d6d0163) # Conflicts: # erpnext/accounts/doctype/payment_entry/payment_entry.py # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js # erpnext/buying/doctype/purchase_order/purchase_order.js # erpnext/public/js/controllers/transaction.js * feat: Make Tax loss booking optional - Checkbox in Accounts Settings - Apply checkbox in PE deductions setting logic - Adjust tests (cherry picked from commit 216a46b) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json * fix: Merge conflicts * fix: 'Donation' does not have `company_currency` field - Make sure check uses this field only for eligible documents --------- Co-authored-by: marination <[email protected]>
# [14.21.0](v14.20.3...v14.21.0) (2023-04-11) ### Bug Fixes * `payment entry is already created` on posawesome. (backport [#34712](#34712)) ([#34752](#34752)) ([8ba1e0f](8ba1e0f)) * add german translation of "Partly Paid" ([#34776](#34776)) ([3023dbb](3023dbb)) * Allocate tax loss to tax account head on early payment discount ([#34287](#34287)) ([be2990e](be2990e)) * asset monthly WDV and DD schedule [v14] ([#34644](#34644)) ([88c8c36](88c8c36)) * Bank clearance for case loan (disburstment/repayment) ([#34586](#34586)) ([f1687cf](f1687cf)) * BOM Update Cost, when no actual qty ([8757435](8757435)) * bom update log not working for large batch size ([551190a](551190a)) * Column value mismatch in COA blank template ([#34658](#34658)) ([5e03a4e](5e03a4e)) * consider qty field precision ([2c54e76](2c54e76)) * customer selection not mandatory in purchase invoice to fetch item details ([#34810](#34810)) ([994272b](994272b)) * don't include cancelled JVs in assdeprledger report ([3896d41](3896d41)) * enclose ternary operator in parentheses ([b835760](b835760)) * incorrect arg name in asset value adjustment ([8d9305e](8d9305e)) * incorrect balance qty in the stock ledger report ([3494c9c](3494c9c)) * incorrect stock balance quantity for batch item ([d817c50](d817c50)) * Item tax validity comparison fixes ([#34784](#34784)) ([cc21241](cc21241)) * lost opportunity report issue ([#34626](#34626)) ([3e67994](3e67994)) * Multiple issues in purchase invoice submission ([#34600](#34600)) ([5677f25](5677f25)) * plaid log_error syntax issue (backport [#34642](#34642)) ([#34667](#34667)) ([61858a6](61858a6)) * posting time issue ([bb5eeb6](bb5eeb6)) * provide filter by depreciable assets in fixed asset register ([#34803](#34803)) ([fee4cd5](fee4cd5)) * reposting record not created for backdated stock reco ([9b90323](9b90323)) * serial no with zero quantity issue in stock reco ([f47be46](f47be46)) * Shop by category fixes (backport [#34688](#34688)) ([#34750](#34750)) ([3ad5d67](3ad5d67)) * Subcontracting Receipt incorrect `status` ([99226d3](99226d3)) * Supplier RFQ email link ([#34338](#34338)) ([a00459a](a00459a)) * Total debit and credit while importing via Data Import ([#34659](#34659)) ([5e28d02](5e28d02)) * **ui:** recalculate difference amount on allocation change ([#34694](#34694)) ([6b866e2](6b866e2)) * Unable to create payment request against purchase invoice ([#34762](#34762)) ([a1f7e35](a1f7e35)) * use stock qty to calculate POS reserved stock ([c0f7f7d](c0f7f7d)) * UX for stock entry, bom and work order ([d4a6035](d4a6035)) ### Features * add `Received Qty` field in `Delivery Note Item` ([1c5e36c](1c5e36c)) * Auto allocate advance payments only against orders ([#34727](#34727)) ([05d24e3](05d24e3)) ### Reverts * remove frappe.send_message (v14) ([#34816](#34816)) ([8a331e0](8a331e0))
## [13.49.12](v13.49.11...v13.49.12) (2023-04-11) ### Bug Fixes * `payment entry is already created` on posawesome. (backport [#34712](#34712)) ([#34753](#34753)) ([b48fca3](b48fca3)) * Allocate tax loss to tax account head on early payment discount ([#34287](#34287)) ([92a26dd](92a26dd)) * asset monthly WDV and DD schedule [v13] ([#34645](#34645)) ([fed43ae](fed43ae)) * BOM Update Cost, when no actual qty ([9725698](9725698)) * bom update log not working for large batch size ([9cf30d7](9cf30d7)) * don't include cancelled JVs in assdeprledger report ([#34737](#34737)) ([3007ac3](3007ac3)) * enclose ternary operator in parentheses ([198830a](198830a)) * filter out old allocation's cf leaves while fetching leave details ([#34723](#34723)) ([50de045](50de045)) * format currency/float as per number format in work history ([#34545](#34545)) ([892c480](892c480)) * incorrect arg name in asset value adjustment ([545807a](545807a)) * incorrect balance qty in the stock ledger report ([dab1f1a](dab1f1a)) * Item tax validity comparison fixes ([#34784](#34784)) ([71bafab](71bafab)) * lost opportunity report issue ([#34626](#34626)) ([ab06cb4](ab06cb4)) * posting time issue ([f22e777](f22e777)) * provide filter by depreciable assets in fixed asset register ([#34803](#34803)) ([8609bf4](8609bf4)) * serial no with zero quantity issue in stock reco ([46638b1](46638b1)) * Shop by category fixes (backport [#34688](#34688)) ([#34751](#34751)) ([af828e4](af828e4)) ### Reverts * Revert "fix: `payment entry is already created` on posawesome. (#34712)" ([034e35e](034e35e)), closes [#34712](#34712) [#34712](#34712) [#34753](#34753) * remove frappe.send_message (v13) ([#34820](#34820)) ([77f1322](77f1322)), closes [#34816](#34816)
# [14.21.0](frappe/erpnext@v14.20.3...v14.21.0) (2023-04-11) ### Bug Fixes * `payment entry is already created` on posawesome. (backport [#34712](frappe/erpnext#34712)) ([#34752](frappe/erpnext#34752)) ([8ba1e0f](frappe/erpnext@8ba1e0f)) * add german translation of "Partly Paid" ([#34776](frappe/erpnext#34776)) ([3023dbb](frappe/erpnext@3023dbb)) * Allocate tax loss to tax account head on early payment discount ([#34287](frappe/erpnext#34287)) ([be2990e](frappe/erpnext@be2990e)) * asset monthly WDV and DD schedule [v14] ([#34644](frappe/erpnext#34644)) ([88c8c36](frappe/erpnext@88c8c36)) * Bank clearance for case loan (disburstment/repayment) ([#34586](frappe/erpnext#34586)) ([f1687cf](frappe/erpnext@f1687cf)) * BOM Update Cost, when no actual qty ([8757435](frappe/erpnext@8757435)) * bom update log not working for large batch size ([551190a](frappe/erpnext@551190a)) * Column value mismatch in COA blank template ([#34658](frappe/erpnext#34658)) ([5e03a4e](frappe/erpnext@5e03a4e)) * consider qty field precision ([2c54e76](frappe/erpnext@2c54e76)) * customer selection not mandatory in purchase invoice to fetch item details ([#34810](frappe/erpnext#34810)) ([994272b](frappe/erpnext@994272b)) * don't include cancelled JVs in assdeprledger report ([3896d41](frappe/erpnext@3896d41)) * enclose ternary operator in parentheses ([b835760](frappe/erpnext@b835760)) * incorrect arg name in asset value adjustment ([8d9305e](frappe/erpnext@8d9305e)) * incorrect balance qty in the stock ledger report ([3494c9c](frappe/erpnext@3494c9c)) * incorrect stock balance quantity for batch item ([d817c50](frappe/erpnext@d817c50)) * Item tax validity comparison fixes ([#34784](frappe/erpnext#34784)) ([cc21241](frappe/erpnext@cc21241)) * lost opportunity report issue ([#34626](frappe/erpnext#34626)) ([3e67994](frappe/erpnext@3e67994)) * Multiple issues in purchase invoice submission ([#34600](frappe/erpnext#34600)) ([5677f25](frappe/erpnext@5677f25)) * plaid log_error syntax issue (backport [#34642](frappe/erpnext#34642)) ([#34667](frappe/erpnext#34667)) ([61858a6](frappe/erpnext@61858a6)) * posting time issue ([bb5eeb6](frappe/erpnext@bb5eeb6)) * provide filter by depreciable assets in fixed asset register ([#34803](frappe/erpnext#34803)) ([fee4cd5](frappe/erpnext@fee4cd5)) * reposting record not created for backdated stock reco ([9b90323](frappe/erpnext@9b90323)) * serial no with zero quantity issue in stock reco ([f47be46](frappe/erpnext@f47be46)) * Shop by category fixes (backport [#34688](frappe/erpnext#34688)) ([#34750](frappe/erpnext#34750)) ([3ad5d67](frappe/erpnext@3ad5d67)) * Subcontracting Receipt incorrect `status` ([99226d3](frappe/erpnext@99226d3)) * Supplier RFQ email link ([#34338](frappe/erpnext#34338)) ([a00459a](frappe/erpnext@a00459a)) * Total debit and credit while importing via Data Import ([#34659](frappe/erpnext#34659)) ([5e28d02](frappe/erpnext@5e28d02)) * **ui:** recalculate difference amount on allocation change ([#34694](frappe/erpnext#34694)) ([6b866e2](frappe/erpnext@6b866e2)) * Unable to create payment request against purchase invoice ([#34762](frappe/erpnext#34762)) ([a1f7e35](frappe/erpnext@a1f7e35)) * use stock qty to calculate POS reserved stock ([c0f7f7d](frappe/erpnext@c0f7f7d)) * UX for stock entry, bom and work order ([d4a6035](frappe/erpnext@d4a6035)) ### Features * add `Received Qty` field in `Delivery Note Item` ([1c5e36c](frappe/erpnext@1c5e36c)) * Auto allocate advance payments only against orders ([#34727](frappe/erpnext#34727)) ([05d24e3](frappe/erpnext@05d24e3)) ### Reverts * remove frappe.send_message (v14) ([#34816](frappe/erpnext#34816)) ([8a331e0](frappe/erpnext@8a331e0))
Docs update:
https://docs.erpnext.com/docs/v14/user/manual/en/accounts/payment-terms/edit-wiki?wiki_page_patch=9f963e285a
https://docs.erpnext.com/docs/v14/user/manual/en/accounts/accounts-settings/edit-wiki?wiki_page_patch=7b3e920d00
Early Payment Discount: Loss Allocation
Early Payment Discount Deductions in payment entry can be split into income loss and tax loss by enabling Book Tax Loss on Early Payment Discount in the Accounts Settings:
Consider the foll.g Sales Invoice:
Payment Entry Before:
Payment Entry After:
Other Fixes
discounted amount
in Invoice's Payment Schedule rows based on Discount Type: Discounted Amount was always calculated in percentages on submitting a Payment Entry which gave the wrong value if it was an amount based discount.Amount
in deductions as base currency/company currency: For multi-currency SI and PE, the deductions table's amount field label showed the company currency but the value was formatted in the Customer/Supplier currencyAllocate Payment Based on Payment Terms
is checked, then handle payment schedule amount extraction and back updation in the right currency:TODO: