[fixes] fix perpetual inventory
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 7ac5400..7b1b8b1 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -25,99 +25,50 @@
// Show / Hide button
this.show_general_ledger();
- if(!doc.is_return) {
- if(doc.docstatus==1) {
- if(doc.outstanding_amount > 0) {
- this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
- cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
- }
+ if(!doc.is_return && doc.docstatus==1) {
+ if(doc.outstanding_amount > 0) {
+ this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
+ cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
+ }
- if (!doc.make_receipt) {
- if(doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
- cur_frm.add_custom_button(__('Debit Note'), this.make_debit_note, __("Make"));
- }
- }
- else {
- cur_frm.add_custom_button(__('Return'), this.make_debit_note, __("Make"));
- }
-
+ if(doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
+ cur_frm.add_custom_button(doc.update_stock ? __('Purchase Return') : __('Debit Note'),
+ this.make_debit_note, __("Make"));
}
-
- if(doc.docstatus===0) {
- cur_frm.add_custom_button(__('Purchase Order'), function() {
- frappe.model.map_current_doc({
- method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
- source_doctype: "Purchase Order",
- get_query_filters: {
- supplier: cur_frm.doc.supplier || undefined,
- docstatus: 1,
- status: ["!=", "Closed"],
- per_billed: ["<", 99.99],
- company: cur_frm.doc.company
- }
- })
- }, __("Get items from"));
-
- cur_frm.add_custom_button(__('Purchase Receipt'), function() {
- frappe.model.map_current_doc({
- method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
- source_doctype: "Purchase Receipt",
- get_query_filters: {
- supplier: cur_frm.doc.supplier || undefined,
- docstatus: 1,
- status: ["!=", "Closed"],
- company: cur_frm.doc.company
- }
- })
- }, __("Get items from"));
- }
- }
- if(doc.docstatus==1 && doc.make_receipt==1) {
+
+ if(doc.update_stock==1) {
this.show_stock_ledger();
}
-
- },
-
- received_qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["qty", "received_qty"]);
-
- item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
- this.qty(doc, cdt, cdn);
- },
-
- qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["qty", "received_qty"]);
-
- if(!(item.received_qty || item.rejected_qty) && item.qty) {
- item.received_qty = item.qty;
}
+
+ if(doc.docstatus===0) {
+ cur_frm.add_custom_button(__('Purchase Order'), function() {
+ frappe.model.map_current_doc({
+ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
+ source_doctype: "Purchase Order",
+ get_query_filters: {
+ supplier: cur_frm.doc.supplier || undefined,
+ docstatus: 1,
+ status: ["!=", "Closed"],
+ per_billed: ["<", 99.99],
+ company: cur_frm.doc.company
+ }
+ })
+ }, __("Get items from"));
- if(item.qty > item.received_qty) {
- msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "qty", item.name)),
- __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]))
- item.qty = item.rejected_qty = 0.0;
- } else {
- item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
+ cur_frm.add_custom_button(__('Purchase Receipt'), function() {
+ frappe.model.map_current_doc({
+ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
+ source_doctype: "Purchase Receipt",
+ get_query_filters: {
+ supplier: cur_frm.doc.supplier || undefined,
+ docstatus: 1,
+ status: ["!=", "Closed"],
+ company: cur_frm.doc.company
+ }
+ })
+ }, __("Get items from"));
}
-
- this._super(doc, cdt, cdn);
- },
-
- rejected_qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
-
- if(item.rejected_qty > item.received_qty) {
- msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "rejected_qty", item.name)),
- __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
- item.qty = item.rejected_qty = 0.0;
- } else {
- item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
- }
-
- this.qty(doc, cdt, cdn);
},
supplier: function() {
@@ -156,11 +107,11 @@
}
},
- is_cash: function() {
+ is_paid: function() {
cur_frm.cscript.hide_fields(this.frm.doc);
- if(cint(this.frm.doc.is_cash)) {
+ if(cint(this.frm.doc.is_paid)) {
if(!this.frm.doc.company) {
- this.frm.set_value("is_cash", 0);
+ this.frm.set_value("x", 0);
msgprint(__("Please specify Company to proceed"));
}
}
@@ -216,7 +167,7 @@
cur_frm.cscript.hide_fields = function(doc) {
par_flds = ['due_date', 'is_opening', 'advances_section', 'from_date', 'to_date'];
- if(cint(doc.is_cash) == 1) {
+ if(cint(doc.is_paid) == 1) {
hide_field(par_flds);
} else {
for (i in par_flds) {
@@ -226,21 +177,21 @@
}
- item_flds_stock = ['sc_wh', 'received_qty', 'rejected_qty'];
+ item_flds_stock = ['warehouse_section', 'received_qty', 'rejected_qty'];
//item_flds_stock = ['serial_no', 'batch_no', 'actual_qty', 'expense_account', 'warehouse', 'expense_account', 'warehouse']
cur_frm.fields_dict['items'].grid.set_column_disp(item_flds_stock,
- (cint(doc.make_receipt)==1 ? true : false));
+ (cint(doc.update_stock)==1 ? true : false));
cur_frm.refresh_fields();
}
-cur_frm.cscript.make_receipt = function(doc, dt, dn) {
+cur_frm.cscript.update_stock = function(doc, dt, dn) {
cur_frm.cscript.hide_fields(doc, dt, dn);
}
cur_frm.cscript.mode_of_payment = function(doc) {
- if(doc.is_cash) {
+ if(doc.is_paid) {
return cur_frm.call({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
args: {
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index d35d0c4..7f6a7f1 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -276,14 +276,15 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "is_return",
+ "default": "0",
+ "fieldname": "is_paid",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
- "label": "Is Return",
+ "label": "Is Paid",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -805,14 +806,14 @@
"bold": 0,
"collapsible": 0,
"default": "0",
- "fieldname": "make_receipt",
+ "fieldname": "update_stock",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
- "label": "Make Receipt (Update Stock)",
+ "label": "Update Stock",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -1691,8 +1692,8 @@
"bold": 0,
"collapsible": 1,
"collapsible_depends_on": "paid_amount",
- "depends_on": "eval:doc.is_cash===1",
- "fieldname": "sc_br_payments",
+ "depends_on": "eval:doc.is_paid===1",
+ "fieldname": "payments_section",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -2444,33 +2445,6 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "fiscal_year",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 1,
- "in_list_view": 0,
- "label": "Fiscal Year",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "fiscal_year",
- "oldfieldtype": "Select",
- "options": "Fiscal Year",
- "permlevel": 0,
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
"fieldname": "remarks",
"fieldtype": "Small Text",
"hidden": 0,
@@ -2953,7 +2927,7 @@
],
"read_only": 0,
"read_only_onload": 1,
- "search_fields": "posting_date, supplier, fiscal_year, bill_no, base_grand_total, outstanding_amount",
+ "search_fields": "posting_date, supplier, bill_no, base_grand_total, outstanding_amount",
"sort_field": "modified",
"sort_order": "DESC",
"timeline_field": "supplier",
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index ba80bcf..fcf2667 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -12,6 +12,7 @@
from erpnext.accounts.party import get_party_account, get_due_date
from erpnext.accounts.utils import get_account_currency, get_fiscal_year
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import update_billed_amount_based_on_po
+from erpnext.controllers.stock_controller import get_warehouse_account
form_grid_templates = {
@@ -47,11 +48,11 @@
self.validate_advance_jv("Purchase Order")
# validate cash purchase
- if (self.is_cash == 1):
+ if (self.is_paid == 1):
self.validate_cash()
# validate stock items
- if (self.make_receipt == 1):
+ if (self.update_stock == 1):
self.validate_purchase_return()
self.validate_rejected_warehouse()
self.validate_accepted_rejected_qty()
@@ -286,7 +287,7 @@
reconcile_against_document(lst)
def update_status_updater_args(self):
- if cint(self.make_receipt):
+ if cint(self.update_stock):
self.status_updater.extend([{
'source_dt': 'Purchase Invoice Item',
'target_dt': 'Purchase Order Item',
@@ -300,7 +301,7 @@
# 'percent_join_field': 'prevdoc_docname',
'overflow_type': 'receipt',
'extra_cond': """ and exists(select name from `tabPurchase Invoice`
- where name=`tabPurchase Invoice Item`.parent and make_receipt = 1)"""
+ where name=`tabPurchase Invoice Item`.parent and update_stock = 1)"""
},
{
'source_dt': 'Purchase Invoice Item',
@@ -362,17 +363,17 @@
self.company, self.base_grand_total)
# make purchase receipt
- if (self.make_receipt == 1):
+ if (self.update_stock == 1):
# from erpnext.stock.doctype.purchase_receipt.purchase_receipt import update_stock_ledger
self.update_stock_ledger()
- self.make_gl_entries()
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit
update_serial_nos_after_submit(self, "items")
self.update_status_updater_args()
self.update_prevdoc_status()
# this sequence because outstanding may get -negative
- self.make_gl_entries1()
+ self.make_gl_entries()
+
if not self.is_return:
self.update_against_document_in_jv()
self.update_prevdoc_status()
@@ -380,6 +381,7 @@
self.update_billing_status_in_pr()
self.update_project()
+<<<<<<< 1b49ed56bdbd4a6cdf93ede3bfa252e5a954ed41
def validate_asset(self):
for d in self.get("items"):
@@ -408,6 +410,22 @@
if self.docstatus==1 and not asset.supplier:
frappe.db.set_value("Asset", asset.name, "supplier", self.supplier)
+=======
+
+ def on_cancel(self):
+ if not self.is_return:
+ from erpnext.accounts.utils import remove_against_link_from_jv
+ remove_against_link_from_jv(self.doctype, self.name)
+
+ self.update_prevdoc_status()
+ self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
+ self.update_billing_status_in_pr()
+
+ self.update_stock_ledger()
+ self.make_gl_entries_on_cancel()
+ self.update_project()
+
+>>>>>>> [fixes] fix perpetual inventory
def make_gl_entries(self):
auto_accounting_for_stock = \
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
@@ -418,7 +436,7 @@
gl_entries = []
# Make Cash GL Entries
- if cint(self.is_cash) and self.cash_bank_account and self.paid_amount:
+ if cint(self.is_paid) and self.cash_bank_account and self.paid_amount:
bank_account_currency = get_account_currency(self.cash_bank_account)
# CASH, make payment entries
gl_entries.append(
@@ -434,6 +452,7 @@
"against_voucher_type": self.doctype,
}, self.party_account_currency)
)
+
gl_entries.append(
self.get_gl_dict({
"account": self.cash_bank_account,
@@ -443,7 +462,7 @@
if bank_account_currency==self.company_currency else self.paid_amount
}, bank_account_currency)
)
-
+
# parent's gl entry
if self.grand_total:
# Didnot use base_grand_total to book rounding loss gle
@@ -463,7 +482,6 @@
"against_voucher_type": self.doctype,
}, self.party_account_currency)
)
-
# tax table gl entries
valuation_tax = {}
for tax in self.get("taxes"):
@@ -483,7 +501,6 @@
"cost_center": tax.cost_center
}, account_currency)
)
-
# accumulate valuation tax
if self.is_opening == "No" and tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
if auto_accounting_for_stock and not tax.cost_center:
@@ -491,16 +508,17 @@
valuation_tax.setdefault(tax.cost_center, 0)
valuation_tax[tax.cost_center] += \
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
-
# item gl entries
negative_expense_to_be_booked = 0.0
stock_items = self.get_stock_items()
+ warehouse_account = get_warehouse_account()
+
for item in self.get("items"):
if flt(item.base_net_amount):
account_currency = get_account_currency(item.expense_account)
gl_entries.append(
self.get_gl_dict({
- "account": item.expense_account,
+ "account": item.expense_account if not self.update_stock else warehouse_account[item.warehouse]["name"],
"against": self.supplier,
"debit": item.base_net_amount,
"debit_in_account_currency": item.base_net_amount \
@@ -508,7 +526,7 @@
"cost_center": item.cost_center
}, account_currency)
)
-
+
if auto_accounting_for_stock and self.is_opening == "No" and \
item.item_code in stock_items and item.item_tax_amount:
# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
@@ -583,7 +601,7 @@
"cost_center": self.write_off_cost_center
})
)
-
+
if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index cc9e1d3..28b84eb 100755
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -221,6 +221,7 @@
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Received Qty",
@@ -271,6 +272,7 @@
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Rejected Qty",
@@ -815,10 +817,11 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "sc_wh",
+ "fieldname": "warehouse_section",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Warehouse",
@@ -844,6 +847,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Accepted Warehouse",
@@ -869,6 +873,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Rejected Warehouse",
@@ -894,6 +899,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Batch No",
@@ -919,6 +925,7 @@
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "",
@@ -943,6 +950,7 @@
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Serial No",
@@ -967,6 +975,7 @@
"fieldtype": "Text",
"hidden": 1,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Rejected Serial No",
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 2f1959b..5dcb012 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -42,7 +42,7 @@
this.frm.set_query("item_code", "items", function() {
if(me.frm.doc.is_subcontracted == "Yes") {
- return{
+ return{
query: "erpnext.controllers.queries.item_query",
filters:{ 'is_sub_contracted_item': 1 }
}
@@ -114,8 +114,49 @@
},
qty: function(doc, cdt, cdn) {
+ if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && doc.update_stock)) {
+ var item = frappe.get_doc(cdt, cdn);
+ frappe.model.round_floats_in(item, ["qty", "received_qty"]);
+
+ if(!(item.received_qty || item.rejected_qty) && item.qty) {
+ item.received_qty = item.qty;
+ }
+
+ if(item.qty > item.received_qty) {
+ msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "qty", item.name)),
+ __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]))
+ item.qty = item.rejected_qty = 0.0;
+ } else {
+ item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
+ }
+ }
+
this._super(doc, cdt, cdn);
this.conversion_factor(doc, cdt, cdn);
+
+ },
+
+ received_qty: function(doc, cdt, cdn) {
+ var item = frappe.get_doc(cdt, cdn);
+ frappe.model.round_floats_in(item, ["qty", "received_qty"]);
+
+ item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
+ this.qty(doc, cdt, cdn);
+ },
+
+ rejected_qty: function(doc, cdt, cdn) {
+ var item = frappe.get_doc(cdt, cdn);
+ frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
+
+ if(item.rejected_qty > item.received_qty) {
+ msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "rejected_qty", item.name)),
+ __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
+ item.qty = item.rejected_qty = 0.0;
+ } else {
+ item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
+ }
+
+ this.qty(doc, cdt, cdn);
},
conversion_factor: function(doc, cdt, cdn) {
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index b93857d..b4e712a 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -519,7 +519,7 @@
if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") {
frappe.model.round_floats_in(this.frm.doc, ["paid_amount"]);
- if(this.frm.doc.is_pos || this.frm.doc.is_cash) {
+ if(this.frm.doc.is_pos || this.frm.doc.is_paid) {
if(!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount) {
this.frm.doc.paid_amount = flt(total_amount_to_pay);
}
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 2a7629e..c2bbfbf 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -76,48 +76,6 @@
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
},
- received_qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["qty", "received_qty"]);
-
- item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
- this.qty(doc, cdt, cdn);
- },
-
- qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["qty", "received_qty"]);
-
- if(!(item.received_qty || item.rejected_qty) && item.qty) {
- item.received_qty = item.qty;
- }
-
- if(item.qty > item.received_qty) {
- msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "qty", item.name)),
- __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]))
- item.qty = item.rejected_qty = 0.0;
- } else {
- item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
- }
-
- this._super(doc, cdt, cdn);
- },
-
- rejected_qty: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
-
- if(item.rejected_qty > item.received_qty) {
- msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "rejected_qty", item.name)),
- __(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
- item.qty = item.rejected_qty = 0.0;
- } else {
- item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
- }
-
- this.qty(doc, cdt, cdn);
- },
-
make_purchase_invoice: function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",