Skip to content
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

feat: include payments in purchase / sales register report #36069

Merged

Conversation

GursheenK
Copy link
Member

@GursheenK GursheenK commented Jul 10, 2023

Added the feature to enable fetching Payment Entries & Journal Entries along with Purchase/Sales Invoice details in Purchase/Sales Register Reports.

The Include Payments checkbox alters the flow in the following manner -

  1. When enabled, all Invoice and Payment details are fetched with their corresponding Tax Account details.

Screenshot 2023-07-14 at 11 23 30 AM

  1. When disabled, only Invoice details are fetched with their corresponding Tax Account details.

Issue #34764

no-docs

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Jul 10, 2023
@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #36069 (b181813) into develop (c16a581) will increase coverage by 0.05%.
Report is 230 commits behind head on develop.
The diff coverage is 80.84%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #36069      +/-   ##
===========================================
+ Coverage    64.20%   64.26%   +0.05%     
===========================================
  Files          785      785              
  Lines        60703    60952     +249     
===========================================
+ Hits         38975    39169     +194     
- Misses       21728    21783      +55     
Files Changed Coverage Δ
...ange_rate_revaluation/exchange_rate_revaluation.py 55.98% <0.00%> (ø)
erpnext/accounts/utils.py 73.44% <ø> (-0.27%) ⬇️
...ext/manufacturing/doctype/work_order/work_order.py 80.41% <ø> (ø)
erpnext/stock/doctype/item/item.py 85.66% <0.00%> (ø)
...xt/assets/doctype/asset_movement/asset_movement.py 75.00% <33.33%> (+2.14%) ⬆️
...e_purchase_register/item_wise_purchase_register.py 58.94% <50.00%> (-0.20%) ⬇️
...em_wise_sales_register/item_wise_sales_register.py 50.66% <50.00%> (-0.01%) ⬇️
erpnext/controllers/stock_controller.py 82.49% <50.00%> (ø)
erpnext/assets/doctype/asset/depreciation.py 83.15% <61.53%> (+1.83%) ⬆️
erpnext/controllers/buying_controller.py 84.66% <66.66%> (ø)
... and 7 more

... and 49 files with indirect coverage changes

Copy link
Member

@deepeshgarg007 deepeshgarg007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be enhanced further to show a holistic ledger view for Supplier and Customer

  • Maybe rename the check to "Show Ledger View" instead of "Include Payments"
  • Show opening balances on the first row
  • Few columns might have to be hidden and rearranged and added as well
    - A balance column should be added
    - Show invoice and payment amount in separate columns (Invoice and Payments)
    - Hide columns like Supplier/Customer Group, Purchase Order, Receipt, Currency, Rounded total, and Outstanding Amount which are common for a specific party
  • Skip the total row for this view (there is a parameter that can be passed for this)

@GursheenK GursheenK marked this pull request as ready for review July 15, 2023 14:36
return query


def get_opening_row(party_type, party, from_date, company):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check for the party in this (query), multiple parties use the same account so this will fetch balance for all parties. Also add a check for cancelled entries, should not pull any cancelled entries

{"fieldname": "currency", "label": _("Currency"), "fieldtype": "Data", "width": 80},
]
else:
columns += [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert these columns to the new format as well?

{"fieldname": "currency", "label": _("Currency"), "fieldtype": "Data", "width": 80},
]
if not include_payments:
columns += [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to new column format?

return payment_entries


def get_conditions(filters, query, docs, payments=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of docs, we can make this more explicit, which would be easier to read and understand. Instead of docs parameter, we can pass the doctype which would be either Sales, Purchase Invoice, or Payment or Journal entry.
child_doc can be an optional parameter and docs[2] (Sales Invoice Payment) can be hard coded since its already inside the Sales Invoice if block

(gle.account.isin(party_account))
& (gle.party == party)
& (gle.posting_date < from_date)
& (gle.docstatus == 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for field is_cancelled = 0, docstatus won't help here

@deepeshgarg007
Copy link
Member

deepeshgarg007 commented Jul 22, 2023

"Opening" label is not visible in the Sales Register report. While viewing the Purchase Register report saw a mismatch in the balance column

image

GST Itemised Sales and Purchase Register also affected by this

@deepeshgarg007
Copy link
Member

image

No payment entries were fetched even though there were payments in the specified period

@deepeshgarg007 deepeshgarg007 merged commit 3db6ac5 into frappe:develop Jul 27, 2023
12 checks passed
@deepeshgarg007 deepeshgarg007 added the backport version-14-hotfix backport to version 14 label Aug 18, 2023
@GursheenK GursheenK added backport version-14-hotfix backport to version 14 and removed backport version-14-hotfix backport to version 14 labels Nov 29, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14 needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants