[fixes] fix perpetual inventory
This commit is contained in:
parent
bd5fc8ecbe
commit
4bd34a58ba
@ -25,99 +25,50 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
// Show / Hide button
|
// Show / Hide button
|
||||||
this.show_general_ledger();
|
this.show_general_ledger();
|
||||||
|
|
||||||
if(!doc.is_return) {
|
if(!doc.is_return && doc.docstatus==1) {
|
||||||
if(doc.docstatus==1) {
|
if(doc.outstanding_amount > 0) {
|
||||||
if(doc.outstanding_amount > 0) {
|
this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
|
||||||
this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("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)) {
|
||||||
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'),
|
||||||
cur_frm.add_custom_button(__('Debit Note'), this.make_debit_note, __("Make"));
|
this.make_debit_note, __("Make"));
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cur_frm.add_custom_button(__('Return'), this.make_debit_note, __("Make"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus===0) {
|
if(doc.update_stock==1) {
|
||||||
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) {
|
|
||||||
this.show_stock_ledger();
|
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) {
|
cur_frm.add_custom_button(__('Purchase Receipt'), function() {
|
||||||
msgprint(__("Error: {0} > {1}", [__(frappe.meta.get_label(item.doctype, "qty", item.name)),
|
frappe.model.map_current_doc({
|
||||||
__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]))
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||||
item.qty = item.rejected_qty = 0.0;
|
source_doctype: "Purchase Receipt",
|
||||||
} else {
|
get_query_filters: {
|
||||||
item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
|
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() {
|
supplier: function() {
|
||||||
@ -156,11 +107,11 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
is_cash: function() {
|
is_paid: function() {
|
||||||
cur_frm.cscript.hide_fields(this.frm.doc);
|
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) {
|
if(!this.frm.doc.company) {
|
||||||
this.frm.set_value("is_cash", 0);
|
this.frm.set_value("x", 0);
|
||||||
msgprint(__("Please specify Company to proceed"));
|
msgprint(__("Please specify Company to proceed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +167,7 @@ cur_frm.script_manager.make(erpnext.accounts.PurchaseInvoice);
|
|||||||
cur_frm.cscript.hide_fields = function(doc) {
|
cur_frm.cscript.hide_fields = function(doc) {
|
||||||
par_flds = ['due_date', 'is_opening', 'advances_section', 'from_date', 'to_date'];
|
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);
|
hide_field(par_flds);
|
||||||
} else {
|
} else {
|
||||||
for (i in par_flds) {
|
for (i in par_flds) {
|
||||||
@ -226,21 +177,21 @@ cur_frm.cscript.hide_fields = function(doc) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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']
|
//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,
|
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.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.hide_fields(doc, dt, dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.mode_of_payment = function(doc) {
|
cur_frm.cscript.mode_of_payment = function(doc) {
|
||||||
if(doc.is_cash) {
|
if(doc.is_paid) {
|
||||||
return cur_frm.call({
|
return cur_frm.call({
|
||||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
|
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
|
||||||
args: {
|
args: {
|
||||||
|
@ -276,14 +276,15 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "is_return",
|
"default": "0",
|
||||||
|
"fieldname": "is_paid",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Is Return",
|
"label": "Is Paid",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -805,14 +806,14 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "make_receipt",
|
"fieldname": "update_stock",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Make Receipt (Update Stock)",
|
"label": "Update Stock",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -1691,8 +1692,8 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
"collapsible_depends_on": "paid_amount",
|
"collapsible_depends_on": "paid_amount",
|
||||||
"depends_on": "eval:doc.is_cash===1",
|
"depends_on": "eval:doc.is_paid===1",
|
||||||
"fieldname": "sc_br_payments",
|
"fieldname": "payments_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -2440,33 +2441,6 @@
|
|||||||
"unique": 0,
|
"unique": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"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,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -2953,7 +2927,7 @@
|
|||||||
],
|
],
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"read_only_onload": 1,
|
"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_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"timeline_field": "supplier",
|
"timeline_field": "supplier",
|
||||||
|
@ -12,6 +12,7 @@ from erpnext.controllers.buying_controller import BuyingController
|
|||||||
from erpnext.accounts.party import get_party_account, get_due_date
|
from erpnext.accounts.party import get_party_account, get_due_date
|
||||||
from erpnext.accounts.utils import get_account_currency, get_fiscal_year
|
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.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 = {
|
form_grid_templates = {
|
||||||
@ -47,11 +48,11 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.validate_advance_jv("Purchase Order")
|
self.validate_advance_jv("Purchase Order")
|
||||||
|
|
||||||
# validate cash purchase
|
# validate cash purchase
|
||||||
if (self.is_cash == 1):
|
if (self.is_paid == 1):
|
||||||
self.validate_cash()
|
self.validate_cash()
|
||||||
|
|
||||||
# validate stock items
|
# validate stock items
|
||||||
if (self.make_receipt == 1):
|
if (self.update_stock == 1):
|
||||||
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()
|
||||||
@ -286,7 +287,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst)
|
||||||
|
|
||||||
def update_status_updater_args(self):
|
def update_status_updater_args(self):
|
||||||
if cint(self.make_receipt):
|
if cint(self.update_stock):
|
||||||
self.status_updater.extend([{
|
self.status_updater.extend([{
|
||||||
'source_dt': 'Purchase Invoice Item',
|
'source_dt': 'Purchase Invoice Item',
|
||||||
'target_dt': 'Purchase Order Item',
|
'target_dt': 'Purchase Order Item',
|
||||||
@ -300,7 +301,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
# 'percent_join_field': 'prevdoc_docname',
|
# 'percent_join_field': 'prevdoc_docname',
|
||||||
'overflow_type': 'receipt',
|
'overflow_type': 'receipt',
|
||||||
'extra_cond': """ and exists(select name from `tabPurchase Invoice`
|
'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',
|
'source_dt': 'Purchase Invoice Item',
|
||||||
@ -362,17 +363,17 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.company, self.base_grand_total)
|
self.company, self.base_grand_total)
|
||||||
|
|
||||||
# make purchase receipt
|
# 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
|
# from erpnext.stock.doctype.purchase_receipt.purchase_receipt import update_stock_ledger
|
||||||
self.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
|
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit
|
||||||
update_serial_nos_after_submit(self, "items")
|
update_serial_nos_after_submit(self, "items")
|
||||||
self.update_status_updater_args()
|
self.update_status_updater_args()
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
|
|
||||||
# this sequence because outstanding may get -negative
|
# this sequence because outstanding may get -negative
|
||||||
self.make_gl_entries1()
|
self.make_gl_entries()
|
||||||
|
|
||||||
if not self.is_return:
|
if not self.is_return:
|
||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
@ -380,6 +381,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.update_billing_status_in_pr()
|
self.update_billing_status_in_pr()
|
||||||
|
|
||||||
self.update_project()
|
self.update_project()
|
||||||
|
<<<<<<< 1b49ed56bdbd4a6cdf93ede3bfa252e5a954ed41
|
||||||
|
|
||||||
def validate_asset(self):
|
def validate_asset(self):
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
@ -408,6 +410,22 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if self.docstatus==1 and not asset.supplier:
|
if self.docstatus==1 and not asset.supplier:
|
||||||
frappe.db.set_value("Asset", asset.name, "supplier", self.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):
|
def make_gl_entries(self):
|
||||||
auto_accounting_for_stock = \
|
auto_accounting_for_stock = \
|
||||||
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||||
@ -418,7 +436,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries = []
|
gl_entries = []
|
||||||
|
|
||||||
# Make Cash 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)
|
bank_account_currency = get_account_currency(self.cash_bank_account)
|
||||||
# CASH, make payment entries
|
# CASH, make payment entries
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
@ -434,6 +452,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
}, self.party_account_currency)
|
}, self.party_account_currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": self.cash_bank_account,
|
"account": self.cash_bank_account,
|
||||||
@ -443,7 +462,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if bank_account_currency==self.company_currency else self.paid_amount
|
if bank_account_currency==self.company_currency else self.paid_amount
|
||||||
}, bank_account_currency)
|
}, bank_account_currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
# parent's gl entry
|
# parent's gl entry
|
||||||
if self.grand_total:
|
if self.grand_total:
|
||||||
# Didnot use base_grand_total to book rounding loss gle
|
# Didnot use base_grand_total to book rounding loss gle
|
||||||
@ -463,7 +482,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
}, self.party_account_currency)
|
}, self.party_account_currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
@ -483,7 +501,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
}, account_currency)
|
}, account_currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
# accumulate valuation tax
|
# 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 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:
|
if auto_accounting_for_stock and not tax.cost_center:
|
||||||
@ -491,16 +508,17 @@ class PurchaseInvoice(BuyingController):
|
|||||||
valuation_tax.setdefault(tax.cost_center, 0)
|
valuation_tax.setdefault(tax.cost_center, 0)
|
||||||
valuation_tax[tax.cost_center] += \
|
valuation_tax[tax.cost_center] += \
|
||||||
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
|
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
|
||||||
|
|
||||||
# item gl entries
|
# item gl entries
|
||||||
negative_expense_to_be_booked = 0.0
|
negative_expense_to_be_booked = 0.0
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
|
warehouse_account = get_warehouse_account()
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount):
|
if flt(item.base_net_amount):
|
||||||
account_currency = get_account_currency(item.expense_account)
|
account_currency = get_account_currency(item.expense_account)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
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,
|
"against": self.supplier,
|
||||||
"debit": item.base_net_amount,
|
"debit": item.base_net_amount,
|
||||||
"debit_in_account_currency": item.base_net_amount \
|
"debit_in_account_currency": item.base_net_amount \
|
||||||
@ -508,7 +526,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center
|
"cost_center": item.cost_center
|
||||||
}, account_currency)
|
}, account_currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
if auto_accounting_for_stock and self.is_opening == "No" and \
|
if auto_accounting_for_stock and self.is_opening == "No" and \
|
||||||
item.item_code in stock_items and item.item_tax_amount:
|
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
|
# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
|
||||||
@ -583,7 +601,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": self.write_off_cost_center
|
"cost_center": self.write_off_cost_center
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
if gl_entries:
|
if gl_entries:
|
||||||
from erpnext.accounts.general_ledger import make_gl_entries
|
from erpnext.accounts.general_ledger import make_gl_entries
|
||||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
||||||
|
@ -221,6 +221,7 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Received Qty",
|
"label": "Received Qty",
|
||||||
@ -271,6 +272,7 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Rejected Qty",
|
"label": "Rejected Qty",
|
||||||
@ -815,10 +817,11 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "sc_wh",
|
"fieldname": "warehouse_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Warehouse",
|
"label": "Warehouse",
|
||||||
@ -844,6 +847,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Accepted Warehouse",
|
"label": "Accepted Warehouse",
|
||||||
@ -869,6 +873,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Rejected Warehouse",
|
"label": "Rejected Warehouse",
|
||||||
@ -894,6 +899,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Batch No",
|
"label": "Batch No",
|
||||||
@ -919,6 +925,7 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "",
|
"label": "",
|
||||||
@ -943,6 +950,7 @@
|
|||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Serial No",
|
"label": "Serial No",
|
||||||
@ -967,6 +975,7 @@
|
|||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Rejected Serial No",
|
"label": "Rejected Serial No",
|
||||||
|
@ -42,7 +42,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
|
|
||||||
this.frm.set_query("item_code", "items", function() {
|
this.frm.set_query("item_code", "items", function() {
|
||||||
if(me.frm.doc.is_subcontracted == "Yes") {
|
if(me.frm.doc.is_subcontracted == "Yes") {
|
||||||
return{
|
return{
|
||||||
query: "erpnext.controllers.queries.item_query",
|
query: "erpnext.controllers.queries.item_query",
|
||||||
filters:{ 'is_sub_contracted_item': 1 }
|
filters:{ 'is_sub_contracted_item': 1 }
|
||||||
}
|
}
|
||||||
@ -114,8 +114,49 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
qty: function(doc, cdt, cdn) {
|
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._super(doc, cdt, cdn);
|
||||||
this.conversion_factor(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) {
|
conversion_factor: function(doc, cdt, cdn) {
|
||||||
|
@ -519,7 +519,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") {
|
if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") {
|
||||||
frappe.model.round_floats_in(this.frm.doc, ["paid_amount"]);
|
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) {
|
if(!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount) {
|
||||||
this.frm.doc.paid_amount = flt(total_amount_to_pay);
|
this.frm.doc.paid_amount = flt(total_amount_to_pay);
|
||||||
}
|
}
|
||||||
|
@ -76,48 +76,6 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
|
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() {
|
make_purchase_invoice: function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user