Skip to content

Commit

Permalink
feat: Auto allocate advance payments only against orders (#34727)
Browse files Browse the repository at this point in the history
* feat: Auto allocate advance payments only against orders (#34727)

feat: Auto allocate advance payments only againt orders
(cherry picked from commit fd3fb64)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/sales_invoice.json

* chore: Resolve conflicts

---------

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
  • Loading branch information
mergify[bot] and deepeshgarg007 authored Apr 5, 2023
1 parent 3c0cc02 commit 05d24e3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
12 changes: 10 additions & 2 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"paid_amount",
"advances_section",
"allocate_advances_automatically",
"only_include_allocated_payments",
"get_advances",
"advances",
"advance_tax",
Expand Down Expand Up @@ -1550,17 +1551,24 @@
"fieldname": "named_place",
"fieldtype": "Data",
"label": "Named Place"
},
{
"default": "0",
"depends_on": "allocate_advances_automatically",
"description": "Advance payments allocated against orders will only be fetched",
"fieldname": "only_include_allocated_payments",
"fieldtype": "Check",
"label": "Only Include Allocated Payments"
}
],
"icon": "fa fa-file-text",
"idx": 204,
"is_submittable": 1,
"links": [],
"modified": "2023-01-28 19:18:56.586321",
"modified": "2023-04-03 22:57:14.074982",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
"name_case": "Title Case",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
Expand Down
10 changes: 9 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"account_for_change_amount",
"advances_section",
"allocate_advances_automatically",
"only_include_allocated_payments",
"get_advances",
"advances",
"write_off_section",
Expand Down Expand Up @@ -2126,6 +2127,13 @@
"label": "Repost Required",
"no_copy": 1,
"read_only": 1
},
{
"depends_on": "allocate_advances_automatically",
"description": "Advance payments allocated against orders will only be fetched",
"fieldname": "only_include_allocated_payments",
"fieldtype": "Check",
"label": "Only Include Allocated Payments"
}
],
"icon": "fa fa-file-text",
Expand All @@ -2138,7 +2146,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2023-03-13 11:43:15.883055",
"modified": "2023-04-03 22:55:14.206473",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
4 changes: 3 additions & 1 deletion erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ def get_shipping_address(self):
def set_advances(self):
"""Returns list of advances against Account, Party, Reference"""

res = self.get_advance_entries()
res = self.get_advance_entries(
include_unallocated=not cint(self.get("only_include_allocated_payments"))
)

self.set("advances", [])
advance_allocated = 0
Expand Down
8 changes: 8 additions & 0 deletions erpnext/public/js/controllers/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ frappe.ui.form.on(cur_frm.doctype, {
},

allocate_advances_automatically: function(frm) {
frm.trigger('fetch_advances');
},

only_include_allocated_payments: function(frm) {
frm.trigger('fetch_advances');
},

fetch_advances: function(frm) {
if(frm.doc.allocate_advances_automatically) {
frappe.call({
doc: frm.doc,
Expand Down

0 comments on commit 05d24e3

Please sign in to comment.