-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Payment System Enchancements: Generalizing invoices and payments #15362
Conversation
…ount balance is calculated based on GL Entries instead of 'Journal Entry Account' to fix incorrect amounts being allowed to reference Journal Entries
-Updated Payment Entry to include all types of negative invoices -Payment against Journal Entry for foreign currency accounts will fetch average party-account-journal-entry exchange rate -Set all exchange_rate DocFields' precision to 9 -Payment Entry update outstanding amount on validate to make sure validation of allocated values is done on the most recent values
-Generalized against_voucher entries such that payable/receivable entries are made without against_voucher and against_voucher entries are treated as adjusting entries (such as a payment or returns) -Generalized balance on voucher -Simplified update_balance_amt, now it is called at the end of make_gl_entries
… paying account currencies are different
…ent-System-Enhancement # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.py # erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json # erpnext/accounts/doctype/payment_entry/payment_entry.json # erpnext/accounts/doctype/payment_entry/payment_entry.py # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py # erpnext/accounts/doctype/sales_invoice/sales_invoice.py
… to reload invoices
…nt Entry' in get_oustanding_invoices
…on (frappe#15426) * fix(translations): Replace translations by keyword with indexed version Keywords in the translation also gets translated which results in an error because python cannot find the key * Update buying_controller.py
* fix(desktop_icon): remove land unit icon if exists Patch to delete the 'Land Unit' icon form 'Desktop Icon' doctype if exists, since 'Land Unit' has been merged with 'Location' Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com> * Update remove_land_unit_icon.py
The patch move_item_defaults_to_child_table_for_multicompany used to fail since the doctypes Item and Item Defaults weren't reloaded properly Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
* Removed test letter head from Consolidated Financial Statement * Removed incorrect role permissions
* added section for deferred expense in item master * added default expense account field in Company master * added deferred expense section in purchase invoice item * validation and getter code added * scheduler event to book expense every month * codacy, import fix and other minor fixes * rectify debit credit logic for expense * commonify js code for deferred expense and revenue * remove deferred calculation and validation * common file to calculate deferred revenue and expense * codacy fixes * expense account root_type - Asset, specific method naming
…ent-System-Enhancement # Conflicts: # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
-Removed manual update_outstanding_amt in invoices since it's no longer required
Add coverage badge to README.md
…appe#15457) * feature(chart-of-accounts): Rebuild HSM Tree after bulk insertion * Update chart_of_accounts.py
…frappe#15453) __init__.py in apps/erpnext directory confuses vs code. Causing all erpnext dotted paths to need an extra `erpnext.` for suggestion and completion to work properly. This commit fixes this issue.
* Commission For Sales Person * Changes Made * Changes made in sales person dashboard and commission report * Update sales_person_commission_summary.py
- syntax fix for using super class - check "All Departments" in department name with translations
fix(multiple): syntax and patch
…ent-System-Enhancement
@SaiFi0102 thanks for taking this on. But a good explanation via screenshots will be very helpful. It is really hard to review 67 files without an overall understanding of what you are trying to achieve. Can you ping me separately via email so we can discuss this via a call? |
Hey @rmehta. Sure I'll post some screenshots. And yeah it'd be nice to discuss this over a call, however, I'll have to get back to you in a week since I'm giving exams, so yeah I'll email you! By the way for some reason GitHub is showing commits from other users since I merged from staging rather than develop (since develop is now v12). So I'm closing this and opening another pull request #15542. You will see that I have modified 26 files, not 67! |
Problem
Journal Entry's advance payment balance is calculated from
Journal Entry Account
which can result in an invalid unallocated amount. When a Payment Entry or reverse Journal Entry is made against a Journal Entry that debits Creditors or credits Debtors (makes a payment), the unallocated amount is not updated.To fix this problem of being able to reverse payable/receivable entry I had to modify the payment system such that Journal Entry's balance is calculated from the GL Entries made by and against the Journal Entry. To do that I had to change and generalize payable/receivable entries from voucher documents.
Modifications
Voucher Documents (the ones that credit/debit payables/receivables):
against_voucher
to reference themselves. In my opinion Journal Entry follows a more logical scheme as it setsagainst_voucher
as empty rather than referencing itself when not referencing another voucher.GL Entry:against_voucher
's values consistent with all voucher documents such thatagainst_voucher
is set as empty when making a party payable/receivable entry and is set to reference another voucher only when adjusting a previously made payable/receivable GL Entry (for payments and returns etc). This simplifies and generalizes queries for calculating invoices and unallocated payments.get_balance_on_voucher
that calculates a balance for a(voucher_type, voucher_no, account, party_type, party)
tuple.GL Entry and General Ledger:
GL Entry:against_voucher_type
since invoice/payment queries filter through this field often.update_outstanding_amt
fromsave_gl_entries
anddelete_gl_entries
instead ofon_update_with_args
so that one query is required to updateoutstanding_amount
rather than calling a query for each and every GL Entry.party_type
andparty
both must be set or both must be unset. Same foragainst_voucher
andagainst_voucher_type
Journal Entry:
update_reference_in_journal_entry
so that it updates references in multiple Journal Entry Accounts if the first entry's amount is less than theallocated_amount
is_advance
field from Journal Entry Account as it becomes impossible to getis_advance
field when calculating advance payments from GL Entries. And also because in my opinion an unallocated payment should always be allocatable from Advance Payments in Purchase/Sales Invoice.reference_due_date
from Journal Entry Account since it wasn't being used for anything.exchange_rate
for entries referencing Purchase Invoice, Sales Invoice or Journal Entry.exchange_rate
read-only when referencing voucher documents, however, frappe doesn't allow setting a specific row in a child table as read-only, so if the user changes exchange rate manually for such entries, he/she could see errors for debit != credit!Payment Entry:
allocated_amount > outstanding_amount
since the client may not show the updated outstanding amount.paid_amount
instead ofreceived_amount
and vice-versa when receiving currency and paying currency is different, replaced an incorrect payment_type == 'Internal Transfer' with 'Receive', display depends on forexchange_rate
field when it's not 1Payment Reconciliation:
get_advance_payment_entries
to filter byagainst_account
for Bank/Cash account fieldExchange Rate fields
exchange_rate
field's precision to 9purchase_invoice.json modified date
What's Left?
Writing a patch:
Setting read-only on specific child table row field
Validation fail due to old outstanding balance not updated in client:
Possibly create a child table for Journal Entry Outstanding Balances
update_outstanding_amt
function called from make_gl_entries and querying from that child table instead of GL Entry.Bank Statment Transaction Entry
reconcile_against_document
because I have no idea how it works.reconcile_against_document
?Use precision based threshold to check if monetary value > 0 or < 0
>= 1.0 / (10 ** (precision("field")))
< 1.0 / (10 ** (precision("field")))