[fixes] code clean-up
This commit is contained in:
parent
e29248bcb3
commit
130c57b201
@ -136,10 +136,6 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
this.frm.refresh_fields();
|
this.frm.refresh_fields();
|
||||||
},
|
},
|
||||||
|
|
||||||
tc_name: function() {
|
|
||||||
this.get_terms();
|
|
||||||
},
|
|
||||||
|
|
||||||
items_add: function(doc, cdt, cdn) {
|
items_add: function(doc, cdt, cdn) {
|
||||||
var row = frappe.get_doc(cdt, cdn);
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
this.frm.script_manager.copy_from_first_row("items", row,
|
this.frm.script_manager.copy_from_first_row("items", row,
|
||||||
|
@ -53,18 +53,11 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
# validate stock items
|
# validate stock items
|
||||||
if (self.update_stock == 1):
|
if (self.update_stock == 1):
|
||||||
pc_obj = frappe.get_doc('Purchase Common')
|
|
||||||
pc_obj.validate_for_items(self)
|
|
||||||
|
|
||||||
self.validate_purchase_return()
|
self.validate_purchase_return()
|
||||||
self.validate_rejected_warehouse()
|
self.validate_rejected_warehouse()
|
||||||
self.validate_accepted_rejected_qty()
|
self.validate_accepted_rejected_qty()
|
||||||
|
pc_obj = frappe.get_doc('Purchase Common')
|
||||||
# sub-contracting
|
pc_obj.validate_for_items(self)
|
||||||
# self.validate_for_subcontracting()
|
|
||||||
# self.create_raw_materials_supplied("supplied_items")
|
|
||||||
# self.set_landed_cost_voucher_amount()
|
|
||||||
# self.update_valuation_rate("items")
|
|
||||||
|
|
||||||
self.check_active_purchase_items()
|
self.check_active_purchase_items()
|
||||||
self.check_conversion_rate()
|
self.check_conversion_rate()
|
||||||
@ -88,37 +81,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
- flt(self.base_grand_total) > 1/(10**(self.precision("base_grand_total") + 1)):
|
- flt(self.base_grand_total) > 1/(10**(self.precision("base_grand_total") + 1)):
|
||||||
frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))
|
frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))
|
||||||
|
|
||||||
def validate_purchase_return(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if self.is_return and flt(d.rejected_qty) != 0:
|
|
||||||
frappe.throw(_("Row #{0}: Rejected Qty can not be entered in Purchase Return").format(d.idx))
|
|
||||||
|
|
||||||
# validate rate with ref PR
|
|
||||||
|
|
||||||
def validate_rejected_warehouse(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if flt(d.rejected_qty) and not d.rejected_warehouse:
|
|
||||||
d.rejected_warehouse = self.rejected_warehouse
|
|
||||||
if not d.rejected_warehouse:
|
|
||||||
frappe.throw(_("Row #{0}: Rejected Warehouse is mandatory against rejected Item {1}").format(d.idx, d.item_code))
|
|
||||||
|
|
||||||
# validate accepted and rejected qty
|
|
||||||
def validate_accepted_rejected_qty(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if not flt(d.received_qty) and flt(d.qty):
|
|
||||||
d.received_qty = flt(d.qty) - flt(d.rejected_qty)
|
|
||||||
|
|
||||||
elif not flt(d.qty) and flt(d.rejected_qty):
|
|
||||||
d.qty = flt(d.received_qty) - flt(d.rejected_qty)
|
|
||||||
|
|
||||||
elif not flt(d.rejected_qty):
|
|
||||||
d.rejected_qty = flt(d.received_qty) - flt(d.qty)
|
|
||||||
|
|
||||||
# Check Received Qty = Accepted Qty + Rejected Qty
|
|
||||||
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
|
||||||
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
|
|
||||||
|
|
||||||
|
|
||||||
def create_remarks(self):
|
def create_remarks(self):
|
||||||
if not self.remarks:
|
if not self.remarks:
|
||||||
if self.bill_no and self.bill_date:
|
if self.bill_no and self.bill_date:
|
||||||
|
@ -117,7 +117,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && doc.update_stock)) {
|
if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && doc.update_stock)) {
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
|
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||||
|
|
||||||
if(!(item.received_qty || item.rejected_qty) && item.qty) {
|
if(!(item.received_qty || item.rejected_qty) && item.qty) {
|
||||||
item.received_qty = item.qty;
|
item.received_qty = item.qty;
|
||||||
}
|
}
|
||||||
@ -153,6 +152,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
|
__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
|
||||||
item.qty = item.rejected_qty = 0.0;
|
item.qty = item.rejected_qty = 0.0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
|
item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +235,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
|
|
||||||
erpnext.utils.get_address_display(this.frm, "shipping_address",
|
erpnext.utils.get_address_display(this.frm, "shipping_address",
|
||||||
"shipping_address_display", is_your_company_address=true)
|
"shipping_address_display", is_your_company_address=true)
|
||||||
|
},
|
||||||
|
|
||||||
|
tc_name: function() {
|
||||||
|
this.get_terms();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -262,6 +262,36 @@ class BuyingController(StockController):
|
|||||||
frappe.throw(_("Row {0}: Conversion Factor is mandatory").format(d.idx))
|
frappe.throw(_("Row {0}: Conversion Factor is mandatory").format(d.idx))
|
||||||
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
|
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
|
||||||
|
|
||||||
|
def validate_purchase_return(self):
|
||||||
|
for d in self.get("items"):
|
||||||
|
if self.is_return and flt(d.rejected_qty) != 0:
|
||||||
|
frappe.throw(_("Row #{0}: Rejected Qty can not be entered in Purchase Return").format(d.idx))
|
||||||
|
|
||||||
|
# validate rate with ref PR
|
||||||
|
|
||||||
|
def validate_rejected_warehouse(self):
|
||||||
|
for d in self.get("items"):
|
||||||
|
if flt(d.rejected_qty) and not d.rejected_warehouse:
|
||||||
|
d.rejected_warehouse = self.rejected_warehouse
|
||||||
|
if not d.rejected_warehouse:
|
||||||
|
frappe.throw(_("Row #{0}: Rejected Warehouse is mandatory against rejected Item {1}").format(d.idx, d.item_code))
|
||||||
|
|
||||||
|
# validate accepted and rejected qty
|
||||||
|
def validate_accepted_rejected_qty(self):
|
||||||
|
for d in self.get("items"):
|
||||||
|
if not flt(d.received_qty) and flt(d.qty):
|
||||||
|
d.received_qty = flt(d.qty) - flt(d.rejected_qty)
|
||||||
|
|
||||||
|
elif not flt(d.qty) and flt(d.rejected_qty):
|
||||||
|
d.qty = flt(d.received_qty) - flt(d.rejected_qty)
|
||||||
|
|
||||||
|
elif not flt(d.rejected_qty):
|
||||||
|
d.rejected_qty = flt(d.received_qty) - flt(d.qty)
|
||||||
|
|
||||||
|
# Check Received Qty = Accepted Qty + Rejected Qty
|
||||||
|
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
||||||
|
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
|
||||||
|
|
||||||
def update_stock_ledger(self, allow_negative_stock=False, via_landed_cost_voucher=False):
|
def update_stock_ledger(self, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||||
sl_entries = []
|
sl_entries = []
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
|
@ -24,7 +24,6 @@ frappe.ui.form.on("Purchase Receipt", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
this._super();
|
this._super();
|
||||||
@ -90,10 +89,6 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
tc_name: function() {
|
|
||||||
this.get_terms();
|
|
||||||
},
|
|
||||||
|
|
||||||
close_purchase_receipt: function() {
|
close_purchase_receipt: function() {
|
||||||
cur_frm.cscript.update_status("Closed");
|
cur_frm.cscript.update_status("Closed");
|
||||||
},
|
},
|
||||||
@ -200,8 +195,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
cur_frm.email_doc(frappe.boot.notification_settings.purchase_receipt_message);
|
cur_frm.email_doc(frappe.boot.notification_settings.purchase_receipt_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frappe.provide("erpnext.buying");
|
frappe.provide("erpnext.buying");
|
||||||
|
|
||||||
frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) {
|
frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) {
|
||||||
|
@ -77,37 +77,6 @@ class PurchaseReceipt(BuyingController):
|
|||||||
where docstatus = 1 and purchase_receipt_item = %s""", d.name)
|
where docstatus = 1 and purchase_receipt_item = %s""", d.name)
|
||||||
d.landed_cost_voucher_amount = lc_voucher_amount[0][0] if lc_voucher_amount else 0.0
|
d.landed_cost_voucher_amount = lc_voucher_amount[0][0] if lc_voucher_amount else 0.0
|
||||||
|
|
||||||
def validate_purchase_return(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if self.is_return and flt(d.rejected_qty) != 0:
|
|
||||||
frappe.throw(_("Row #{0}: Rejected Qty can not be entered in Purchase Return").format(d.idx))
|
|
||||||
|
|
||||||
# validate rate with ref PR
|
|
||||||
|
|
||||||
def validate_rejected_warehouse(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if flt(d.rejected_qty) and not d.rejected_warehouse:
|
|
||||||
d.rejected_warehouse = self.rejected_warehouse
|
|
||||||
if not d.rejected_warehouse:
|
|
||||||
frappe.throw(_("Row #{0}: Rejected Warehouse is mandatory against rejected Item {1}").format(d.idx, d.item_code))
|
|
||||||
|
|
||||||
# validate accepted and rejected qty
|
|
||||||
def validate_accepted_rejected_qty(self):
|
|
||||||
for d in self.get("items"):
|
|
||||||
if not flt(d.received_qty) and flt(d.qty):
|
|
||||||
d.received_qty = flt(d.qty) - flt(d.rejected_qty)
|
|
||||||
|
|
||||||
elif not flt(d.qty) and flt(d.rejected_qty):
|
|
||||||
d.qty = flt(d.received_qty) - flt(d.rejected_qty)
|
|
||||||
|
|
||||||
elif not flt(d.rejected_qty):
|
|
||||||
d.rejected_qty = flt(d.received_qty) - flt(d.qty)
|
|
||||||
|
|
||||||
# Check Received Qty = Accepted Qty + Rejected Qty
|
|
||||||
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
|
||||||
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
|
|
||||||
|
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
super(PurchaseReceipt, self).validate_with_previous_doc({
|
super(PurchaseReceipt, self).validate_with_previous_doc({
|
||||||
"Purchase Order": {
|
"Purchase Order": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user