mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 18:45:20 +00:00
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -78,7 +78,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
const me = this;
|
const me = this;
|
||||||
super.refresh();
|
super.refresh();
|
||||||
|
|
||||||
hide_fields(this.frm.doc);
|
hide_fields(this.frm);
|
||||||
// Show / Hide button
|
// Show / Hide button
|
||||||
this.show_general_ledger();
|
this.show_general_ledger();
|
||||||
erpnext.accounts.ledger_preview.show_accounting_ledger_preview(this.frm);
|
erpnext.accounts.ledger_preview.show_accounting_ledger_preview(this.frm);
|
||||||
@@ -418,7 +418,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_paid() {
|
is_paid() {
|
||||||
hide_fields(this.frm.doc);
|
hide_fields(this.frm);
|
||||||
if (cint(this.frm.doc.is_paid)) {
|
if (cint(this.frm.doc.is_paid)) {
|
||||||
this.frm.set_value("allocate_advances_automatically", 0);
|
this.frm.set_value("allocate_advances_automatically", 0);
|
||||||
this.frm.set_value("payment_terms_template", "");
|
this.frm.set_value("payment_terms_template", "");
|
||||||
@@ -482,28 +482,26 @@ cur_frm.script_manager.make(erpnext.accounts.PurchaseInvoice);
|
|||||||
|
|
||||||
// Hide Fields
|
// Hide Fields
|
||||||
// ------------
|
// ------------
|
||||||
function hide_fields(doc) {
|
function hide_fields(frm) {
|
||||||
var parent_fields = ["due_date", "is_opening", "advances_section", "from_date", "to_date"];
|
const doc = frm.doc;
|
||||||
|
const parent_fields = ["due_date", "is_opening", "advances_section", "from_date", "to_date"];
|
||||||
|
|
||||||
if (cint(doc.is_paid) == 1) {
|
if (cint(doc.is_paid) == 1) {
|
||||||
hide_field(parent_fields);
|
frm.toggle_display(parent_fields, false);
|
||||||
} else {
|
} else {
|
||||||
for (var i in parent_fields) {
|
for (const fieldname of parent_fields) {
|
||||||
var docfield = frappe.meta.docfield_map[doc.doctype][parent_fields[i]];
|
const docfield = frappe.meta.docfield_map[doc.doctype][fieldname];
|
||||||
if (!docfield.hidden) unhide_field(parent_fields[i]);
|
if (!docfield.hidden) frm.toggle_display(fieldname, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var item_fields_stock = ["warehouse_section", "received_qty", "rejected_qty"];
|
const item_fields_stock = ["warehouse_section", "received_qty", "rejected_qty"];
|
||||||
|
|
||||||
if (cur_frm.fields_dict["items"]) {
|
if (frm.fields_dict["items"]) {
|
||||||
cur_frm.fields_dict["items"].grid.set_column_disp(
|
frm.fields_dict["items"].grid.set_column_disp(item_fields_stock, cint(doc.update_stock) == 1);
|
||||||
item_fields_stock,
|
|
||||||
cint(doc.update_stock) == 1 || cint(doc.is_return) == 1 ? true : false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict.cash_bank_account.get_query = function (doc) {
|
cur_frm.fields_dict.cash_bank_account.get_query = function (doc) {
|
||||||
@@ -716,7 +714,7 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
update_stock: function (frm) {
|
update_stock: function (frm) {
|
||||||
hide_fields(frm.doc);
|
hide_fields(frm);
|
||||||
frm.fields_dict.items.grid.toggle_reqd("item_code", frm.doc.update_stock ? true : false);
|
frm.fields_dict.items.grid.toggle_reqd("item_code", frm.doc.update_stock ? true : false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -3052,6 +3052,23 @@ class TestPurchaseInvoice(ERPNextTestSuite, StockTestMixin):
|
|||||||
|
|
||||||
self.assertRaises(StockOverReturnError, return_doc.save)
|
self.assertRaises(StockOverReturnError, return_doc.save)
|
||||||
|
|
||||||
|
def test_partial_returns_ignore_received_qty_without_update_stock(self):
|
||||||
|
from erpnext.controllers.sales_and_purchase_return import make_return_doc
|
||||||
|
|
||||||
|
invoice = make_purchase_invoice(qty=10, received_qty=10)
|
||||||
|
|
||||||
|
first_return = make_return_doc(invoice.doctype, invoice.name)
|
||||||
|
first_return.items[0].qty = -4
|
||||||
|
first_return.save().submit()
|
||||||
|
|
||||||
|
self.assertEqual(first_return.items[0].received_qty, -10)
|
||||||
|
|
||||||
|
second_return = make_return_doc(invoice.doctype, invoice.name)
|
||||||
|
second_return.items[0].qty = -6
|
||||||
|
second_return.save().submit()
|
||||||
|
|
||||||
|
self.assertEqual(second_return.docstatus, 1)
|
||||||
|
|
||||||
def test_apply_discount_on_grand_total(self):
|
def test_apply_discount_on_grand_total(self):
|
||||||
"""
|
"""
|
||||||
To test if after applying discount on grand total,
|
To test if after applying discount on grand total,
|
||||||
|
|||||||
@@ -191,7 +191,12 @@ def validate_quantity(doc, key, args, ref, valid_items, already_returned_items):
|
|||||||
if (doc.doctype == "Purchase Invoice" or doc.doctype == "Sales Invoice") and not doc.update_stock:
|
if (doc.doctype == "Purchase Invoice" or doc.doctype == "Sales Invoice") and not doc.update_stock:
|
||||||
fields = ["qty"]
|
fields = ["qty"]
|
||||||
|
|
||||||
if doc.doctype in ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"]:
|
tracks_accepted_rejected_split = doc.doctype in (
|
||||||
|
"Purchase Receipt",
|
||||||
|
"Subcontracting Receipt",
|
||||||
|
) or (doc.doctype == "Purchase Invoice" and doc.update_stock)
|
||||||
|
|
||||||
|
if tracks_accepted_rejected_split:
|
||||||
if not args.get("return_qty_from_rejected_warehouse"):
|
if not args.get("return_qty_from_rejected_warehouse"):
|
||||||
fields.extend(["received_qty", "rejected_qty"])
|
fields.extend(["received_qty", "rejected_qty"])
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user