Skip to content

fix: add party and party type for receivable & payable accounts#3876

Closed
elshafei-developer wants to merge 7 commits intofrappe:developfrom
elshafei-developer:add-party-and-party-type-for-receivable-&-payable-account
Closed

fix: add party and party type for receivable & payable accounts#3876
elshafei-developer wants to merge 7 commits intofrappe:developfrom
elshafei-developer:add-party-and-party-type-for-receivable-&-payable-account

Conversation

@elshafei-developer
Copy link
Copy Markdown
Contributor

@elshafei-developer elshafei-developer commented Dec 18, 2025

This PR addresses an issue that occurs when process_payroll_accounting_entry_based_on_employee is enabled and the salary component uses an Account with type Receivable or Payable.

In ERPNext, accounts of type Receivable or Payable require both party and party_type to be set in the corresponding GL Entry. However, the current payroll accounting entry logic does not assign party and party_type when such accounts are used.

As a result, the Payroll Entry fails to submit, and the accounting entry cannot be posted due to missing mandatory party information.

This PR ensures that when payroll accounting entries are generated against Receivable or Payable accounts while process_payroll_accounting_entry_based_on_employee is enabled, the required party and party_type values are properly set, allowing the Payroll Entry to be submitted and posted successfully.

issue

backport version-15-hotfix
backport version-16-hotfix

Summary by CodeRabbit

  • Enhancement

    • Improved payroll calculation logic to better handle employee-specific accounting scenarios. Salary component totals now aggregate per employee, providing more granular tracking when employee-wise accounting is enabled.
  • Bug Fixes

    • Fixed account assignment logic to properly validate and apply employee-specific accounting based on system configuration settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 18, 2025

Walkthrough

This change modifies the PayrollEntry class to support employee-wise accounting. The get_account method signature is updated to accept an employee_wise_accounting_enabled parameter. Component aggregation keys are expanded to include the employee identifier alongside salary component and cost center. Account lookup logic is adjusted to conditionally preserve or clear employee scoping based on the accounting mode. The employee_wise_accounting_enabled flag is propagated through related method calls, and accounting entry calculations now pass employee information as the party parameter in payable amount computations.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: adding party and party type for receivable and payable accounts, which aligns with the PR's core objective of fixing accounting entries for Receivable/Payable accounts.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@iamkhanraheel
Copy link
Copy Markdown
Collaborator

Hello @elshafei-developer,
Salary component Accounts represent cost (expense) to company, so by accounting principles they fall under Expense account. Their purpose is to classify what kind of salary is being earned (Basic, HRA, Allowance, etc).

The total of all these components is then credited to Payroll Payable account which is of Type: Payable as this becomes a liability to a company.
All salary components whether earning or deduction they come under expense, tax or charge type account mostly except advance as it is already handled.

If you have a valid use case where a salary component is set as payable or receivable, please share it so that this case can be handle

@elshafei-developer
Copy link
Copy Markdown
Contributor Author

Hi @iamkhanraheel

We do not have any earning salary components configured as Payable or Receivable.

Our use case is limited strictly to two deduction components:

Payable (Salary Withholding) Account – used to deduct a portion of the employee’s salary that is recorded as a payable (liability) until it is settled.

Receivable (Loan) Account – used to deduct installments for an employee loan, which reduces an existing receivable balance owed by the employee to the company.

In both cases, these components are deductions, not earnings. They do not classify salary expenses; instead, they represent either the settlement of an existing liability or the recovery of an existing receivable that is already recognized on the balance sheet.

This is the specific scenario where allowing deduction of salary components to post against Payable or Receivable accounts is required.

@github-actions
Copy link
Copy Markdown

This pull request is being marked as inactive because of no recent activity.
If your PR hasn't been reviewed, it's likely because it doesn't fullfill the contribution guidelines. Please read them carefully and fix the pull request. When you are sure all items are checked, please ping relevant codeowner in the comment. Be nice, they have a lot on their plate too.

It will be closed in 3 days if no further activity occurs.
Thank you for contributing!

@github-actions github-actions Bot removed the Inactive label Feb 15, 2026
@elshafei-developer
Copy link
Copy Markdown
Contributor Author

@iamkhanraheel
The awaiting response from contributor label is still present.
please let me know if any further changes are required from my side.

@iamkhanraheel
Copy link
Copy Markdown
Collaborator

@iamkhanraheel The awaiting response from contributor label is still present. please let me know if any further changes are required from my side.

Hello @elshafei-developer
The changes in this PR will leads to add party type & party for the other accounts also where we should not reveal this data.
For loan deduction we can implement similar flow of employee advance deduction and for salary withholding I am checking with the team on what should be the right approach.

@elshafei-developer
Copy link
Copy Markdown
Contributor Author

@iamkhanraheel

Just to confirm, this PR does not add party_type and party to all accounts.
The change is strictly conditional and only applies when:

  • Process Payroll Accounting Entry Based on Employee is enabled in Payroll Settings, and
  • The selected Salary Component account has Account Type = Receivable or Payable.

For all other account types (e.g., Expense), the existing behavior remains unchanged, and no party information is added.

This adjustment simply ensures compliance with ERPNext’s GL validation rules, where Receivable and Payable accounts require party_type and party, and prevents submission failure in such cases.

Additionally, by correctly setting the party information, the entries become properly traceable in the General Ledger report. This allows filtering and reviewing Receivable/Payable balances per Employee, consistent with how ERPNext handles party-based accounts across the Accounts module.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 7, 2026

This pull request is being marked as inactive because of no recent activity.
If your PR hasn't been reviewed, it's likely because it doesn't fullfill the contribution guidelines. Please read them carefully and fix the pull request. When you are sure all items are checked, please ping relevant codeowner in the comment. Be nice, they have a lot on their plate too.

It will be closed in 3 days if no further activity occurs.
Thank you for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants