fix: handle zero net pay in payroll entry while linking journal entry.#4183
fix: handle zero net pay in payroll entry while linking journal entry.#4183krishna-254 wants to merge 3 commits intofrappe:developfrom
Conversation
…case for same fixes frappe#3972
WalkthroughAdds an override mapping to use a new HRMSJournalEntry class for Journal Entry doctypes, introducing custom debit/credit validation that exempts payroll rows and Exchange Gain Or Loss multi-currency vouchers. Adjusts payroll entry accounting to append payroll-payable rows when amount is zero for payable entries. Adds a test covering payroll entries with zero net pay and related journal entry creation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
hrms/payroll/doctype/payroll_entry/test_payroll_entry.py (1)
1109-1115: Assert the zero debit/credit payroll-payable row explicitly.The current check confirms linkage, but not the exact zero-amount row behavior introduced by this fix. Please assert
debit == 0andcredit == 0on the payroll-payable reference row.✅ Suggested test tightening
- journal_entry_name = frappe.db.get_value( - "Journal Entry Account", - {"reference_type": "Payroll Entry", "reference_name": payroll_entry.name}, - "parent", - ) - self.assertIsNotNone(journal_entry_name, "Journal Entry should be created for zero net pay") + payable_row = frappe.db.get_value( + "Journal Entry Account", + { + "reference_type": "Payroll Entry", + "reference_name": payroll_entry.name, + "account": company.default_payroll_payable_account, + }, + ["parent", "debit", "credit"], + as_dict=True, + ) + self.assertIsNotNone(payable_row, "Payroll payable row should be linked to Payroll Entry") + self.assertEqual(flt(payable_row.debit), 0) + self.assertEqual(flt(payable_row.credit), 0)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hrms/payroll/doctype/payroll_entry/test_payroll_entry.py` around lines 1109 - 1115, Update the test in test_payroll_entry.py to not only assert that a Journal Entry was linked (journal_entry_name) but also fetch the specific "Journal Entry Account" row for the payroll-payable reference and assert its debit and credit are zero; you can locate the row via the same query keys {"reference_type": "Payroll Entry", "reference_name": payroll_entry.name} (use frappe.db.get_value to retrieve "debit, credit" or frappe.get_doc on the parent Journal Entry and find the child row) and add assertions self.assertEqual(debit, 0) and self.assertEqual(credit, 0) to confirm the zero-amount payroll-payable row.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@hrms/payroll/doctype/payroll_entry/payroll_entry.py`:
- Around line 855-856: The current condition (if amt or (amt >= 0 and account ==
self.payroll_payable_account):) can append zero-amount earnings/deductions when
their account equals self.payroll_payable_account; change the check so
zero-value rows are appended only when they are explicit payroll-payable rows —
e.g. replace the condition with an explicit test like: if amt != 0 or (amt == 0
and account == self.payroll_payable_account and row.get('is_payroll_payable')):
(ensure the code that builds row sets row['is_payroll_payable'] for genuine
payable entries), referencing amt, account, self.payroll_payable_account and
accounts.append(row).
---
Nitpick comments:
In `@hrms/payroll/doctype/payroll_entry/test_payroll_entry.py`:
- Around line 1109-1115: Update the test in test_payroll_entry.py to not only
assert that a Journal Entry was linked (journal_entry_name) but also fetch the
specific "Journal Entry Account" row for the payroll-payable reference and
assert its debit and credit are zero; you can locate the row via the same query
keys {"reference_type": "Payroll Entry", "reference_name": payroll_entry.name}
(use frappe.db.get_value to retrieve "debit, credit" or frappe.get_doc on the
parent Journal Entry and find the child row) and add assertions
self.assertEqual(debit, 0) and self.assertEqual(credit, 0) to confirm the
zero-amount payroll-payable row.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
hrms/hooks.pyhrms/overrides/journal_entry.pyhrms/payroll/doctype/payroll_entry/payroll_entry.pyhrms/payroll/doctype/payroll_entry/test_payroll_entry.py
|
This pull request is being marked as inactive because of no recent activity. It will be closed in 3 days if no further activity occurs. |
|
This pull request is being marked as inactive because of no recent activity. It will be closed in 3 days if no further activity occurs. |
fixes #3972
Depends on frappe/erpnext#53002
Summary by CodeRabbit
Bug Fixes
Tests