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: Phase 2 #616

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions erpnext/accounts/doctype/discount_terms/discount_terms.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"field_order": [
"discount",
"no_of_days",
"discount_date",
"due_date"
"discount_date"
],
"fields": [
{
Expand All @@ -28,17 +27,12 @@
"fieldtype": "Date",
"label": "Discount Date",
"read_only": 1
},
{
"fieldname": "due_date",
"fieldtype": "Date",
"label": "Due Date"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-11-11 20:51:43.101806",
"modified": "2024-11-13 10:13:58.307547",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Discount Terms",
Expand Down
1 change: 0 additions & 1 deletion erpnext/accounts/doctype/discount_terms/discount_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class DiscountTerms(Document):

discount: DF.Float
discount_date: DF.Date | None
due_date: DF.Date | None
no_of_days: DF.Int
parent: DF.Data
parentfield: DF.Data
Expand Down
10 changes: 5 additions & 5 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ frappe.ui.form.on("Payment Entry", {
//If allocate payment amount checkbox is unchecked, set zero to allocate amount
row.allocated_amount = 0;
} else if (
frappe.flags.allocate_payment_amount != 0 &&
!frappe.flags.is_amount_settled && frappe.flags.allocate_payment_amount != 0 &&
(!row.allocated_amount || paid_amount_change)
) {
if (row.outstanding_amount > 0 && allocated_positive_outstanding >= 0) {
Expand All @@ -1134,7 +1134,8 @@ frappe.ui.form.on("Payment Entry", {
}
}
});


if(frappe.flags.is_amount_settled) frappe.flags.is_amount_settled = undefined
frm.refresh_fields();
frm.events.set_total_allocated_amount(frm);
},
Expand Down Expand Up @@ -1942,9 +1943,8 @@ function show_invoice_dialogue() {
party: cur_frm.doc.party,
},
callback:(response)=>{
for(let df in response.message){
cur_frm.set_value(df, response.message[df])
}
for(let df in response.message) cur_frm.set_value(df, response.message[df])
frappe.flags.is_amount_settled = true
dialog.hide();
}
})
Expand Down
12 changes: 7 additions & 5 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2863,6 +2863,7 @@ def calculate_discount_for_multiple_invoice(dt, dn_list_obj, reference_date,part
reference_table = []
deduction_table = []
paid_amount = 0

total_allocated_amount = 0

for dn_obj in dn_list_obj:
Expand Down Expand Up @@ -2890,16 +2891,17 @@ def calculate_discount_for_multiple_invoice(dt, dn_list_obj, reference_date,part
discount_amount = -discount_amount if dt == "Purchase Invoice" else discount_amount
total_allocated_amount += dn_obj.amount_to_be_paid
deduction_table.append({
"account" : discount_account ,
"cost_center" : dn_obj.cost_center ,
"account" : discount_account,
"cost_center" :dn_obj.cost_center,
"amount" : flt(discount_amount) ,
})


return {
"references": reference_table,
"deductions": deduction_table,
"paid_amount": paid_amount,
"total_allocated_amount" : total_allocated_amount
"deductions": deduction_table,
"total_allocated_amount" : total_allocated_amount,
"unallocated_amount":0,
"difference_amount":0

}
23 changes: 5 additions & 18 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,11 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
}

due_date(frm){
if (!frm.payment_discount_terms || (frm.payment_discount_terms && frm.payment_discount_terms.length < 1)){
return
}
for(let row of frm.payment_discount_terms)
{
row.due_date = frm.due_date
}
cur_frm.refresh_field('payment_discount_terms')
cur_frm.set_value("discount_due_date",frm.due_date)
}

discount_due_date(frm){
cur_frm.set_value("due_date",frm.discount_due_date)
}
};

Expand Down Expand Up @@ -770,15 +767,5 @@ frappe.ui.form.on("Discount Terms", {
let discount_date = frappe.datetime.add_days(frappe.datetime.get_today(), frm.selected_doc.no_of_days)
frm.selected_doc.discount_date = discount_date
frm.refresh_field("payment_discount_terms")
},
due_date:(frm)=>{
let due_date = frm.selected_doc.due_date
if (!due_date) return

for(let row of frm.doc.payment_discount_terms) row.due_date = due_date

frm.doc.due_date = due_date
cur_frm.refresh_field('payment_discount_terms')
cur_frm.refresh_field('due_date')
}
})
26 changes: 21 additions & 5 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
"terms_tab",
"payment_schedule_section",
"payment_term",
"column_break_sa8m",
"discount_due_date",
"section_break_wa3t",
"payment_discount_terms",
"payment_terms_template",
"ignore_default_payment_terms_template",
Expand Down Expand Up @@ -1138,18 +1141,18 @@
{
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"hidden": 1,
"label": "Payment Terms Template",
"options": "Payment Terms Template",
"hidden":1
"options": "Payment Terms Template"
},
{
"fieldname": "payment_schedule",
"fieldtype": "Table",
"hidden": 1,
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
"print_hide": 1,
"hidden":1
"print_hide": 1
},
{
"fieldname": "terms_section_break",
Expand Down Expand Up @@ -1639,13 +1642,26 @@
"fieldname": "payment_discount_terms",
"fieldtype": "Table",
"options": "Discount Terms"
},
{
"fieldname": "column_break_sa8m",
"fieldtype": "Column Break"
},
{
"fieldname": "discount_due_date",
"fieldtype": "Date",
"label": "Discount Due Date"
},
{
"fieldname": "section_break_wa3t",
"fieldtype": "Section Break"
}
],
"icon": "fa fa-file-text",
"idx": 204,
"is_submittable": 1,
"links": [],
"modified": "2024-11-05 16:09:42.417227",
"modified": "2024-11-13 10:33:48.607034",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class PurchaseInvoice(BuyingController):
currency: DF.Link | None
disable_rounded_total: DF.Check
discount_amount: DF.Currency
discount_due_date: DF.Date | None
due_date: DF.Date | None
from_date: DF.Date | None
grand_total: DF.Currency
Expand Down
23 changes: 5 additions & 18 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,11 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
}

due_date(frm){
if (!frm.payment_discount_terms || (frm.payment_discount_terms && frm.payment_discount_terms.length < 1)){
return
}
for(let row of frm.payment_discount_terms)
{
row.due_date = frm.due_date
}
cur_frm.refresh_field('payment_discount_terms')
cur_frm.set_value("discount_due_date",frm.due_date)
}

discount_due_date(frm){
cur_frm.set_value("due_date",frm.discount_due_date)
}

};
Expand Down Expand Up @@ -1184,15 +1181,5 @@ frappe.ui.form.on("Discount Terms", {
let discount_date = frappe.datetime.add_days(frappe.datetime.get_today(), frm.selected_doc.no_of_days)
frm.selected_doc.discount_date = discount_date
frm.refresh_field("payment_discount_terms")
},
due_date:(frm)=>{
let due_date = frm.selected_doc.due_date
if (!due_date) return

for(let row of frm.doc.payment_discount_terms) row.due_date = due_date

frm.doc.due_date = due_date
cur_frm.refresh_field('payment_discount_terms')
cur_frm.refresh_field('due_date')
}
})
31 changes: 26 additions & 5 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@
"company_address_display",
"terms_tab",
"payment_schedule_section",
"section_break_kvga",
"payment_term",
"column_break_ccyt",
"discount_due_date",
"section_break_zrni",
"payment_discount_terms",
"ignore_default_payment_terms_template",
"payment_terms_template",
Expand Down Expand Up @@ -1311,25 +1315,25 @@
"depends_on": "eval:(!doc.is_pos && !doc.is_return)",
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"hidden": 1,
"hide_days": 1,
"hide_seconds": 1,
"label": "Payment Terms Template",
"no_copy": 1,
"options": "Payment Terms Template",
"print_hide": 1,
"hidden":1
"print_hide": 1
},
{
"depends_on": "eval:(!doc.is_pos && !doc.is_return)",
"fieldname": "payment_schedule",
"fieldtype": "Table",
"hidden": 1,
"hide_days": 1,
"hide_seconds": 1,
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
"print_hide": 1,
"hidden":1
"print_hide": 1
},
{
"collapsible": 1,
Expand Down Expand Up @@ -2091,6 +2095,23 @@
"fieldtype": "Table",
"label": "Payment Discount Terms",
"options": "Discount Terms"
},
{
"fieldname": "section_break_kvga",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_ccyt",
"fieldtype": "Column Break"
},
{
"fieldname": "discount_due_date",
"fieldtype": "Date",
"label": "Discount Due Date"
},
{
"fieldname": "section_break_zrni",
"fieldtype": "Section Break"
}
],
"icon": "fa fa-file-text",
Expand All @@ -2103,7 +2124,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2024-10-31 13:07:06.470425",
"modified": "2024-11-13 10:20:09.482861",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class SalesInvoice(SellingController):
debit_to: DF.Link
disable_rounded_total: DF.Check
discount_amount: DF.Currency
discount_due_date: DF.Date | None
dispatch_address: DF.SmallText | None
dispatch_address_name: DF.Link | None
due_date: DF.Date | None
Expand Down
Loading