Call calculate_taxes_and_totals after mapping

This commit is contained in:
Anand Doshi 2014-04-22 20:35:22 +05:30
parent 4bb87373dc
commit b054eb7a4f
14 changed files with 119 additions and 157 deletions

View File

@ -12,6 +12,7 @@ from frappe import _, msgprint, throw
from erpnext.accounts.party import get_party_account, get_due_date
from erpnext.controllers.stock_controller import update_gl_entries_after
from frappe.model.mapper import get_mapped_doc
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
@ -781,10 +782,9 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
@frappe.whitelist()
def make_delivery_note(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.run_method("onload_post_render")
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
def update_item(source_doc, target_doc, source_parent):
target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \

View File

@ -15,10 +15,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.setup_queries();
this._super();
},
setup_queries: function() {
var me = this;
if(this.frm.fields_dict.buying_price_list) {
this.frm.set_query("buying_price_list", function() {
return{
@ -26,20 +26,20 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
});
}
$.each([["supplier", "supplier"],
$.each([["supplier", "supplier"],
["contact_person", "supplier_filter"],
["supplier_address", "supplier_filter"]],
["supplier_address", "supplier_filter"]],
function(i, opts) {
if(me.frm.fields_dict[opts[0]])
if(me.frm.fields_dict[opts[0]])
me.frm.set_query(opts[0], erpnext.queries[opts[1]]);
});
if(this.frm.fields_dict.supplier) {
this.frm.set_query("supplier", function() {
return{ query: "erpnext.controllers.queries.supplier_query" }});
}
this.frm.set_query("item_code", this.frm.cscript.fname, function() {
if(me.frm.doc.is_subcontracted == "Yes") {
return{
@ -50,61 +50,61 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
return{
query: "erpnext.controllers.queries.item_query",
filters: { 'is_purchase_item': 'Yes' }
}
}
}
});
},
refresh: function(doc) {
this.frm.toggle_display("supplier_name",
this.frm.toggle_display("supplier_name",
(this.supplier_name && this.frm.doc.supplier_name!==this.frm.doc.supplier));
this._super();
},
supplier: function() {
erpnext.utils.get_party_details(this.frm);
},
supplier_address: function() {
erpnext.utils.get_address_display(this.frm);
},
contact_person: function() {
contact_person: function() {
this.supplier_address();
},
buying_price_list: function() {
this.get_price_list_currency("Buying");
},
price_list_rate: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("rate", item));
this.calculate_taxes_and_totals();
},
discount_percentage: function(doc, cdt, cdn) {
this.price_list_rate(doc, cdt, cdn);
},
rate: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["rate", "discount_percentage"]);
if(item.price_list_rate) {
item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
} else {
item.discount_percentage = 0.0;
}
this.calculate_taxes_and_totals();
},
uom: function(doc, cdt, cdn) {
var me = this;
var item = frappe.get_doc(cdt, cdn);
@ -124,12 +124,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
}
},
qty: function(doc, cdt, cdn) {
this._super(doc, cdt, cdn);
this.conversion_factor(doc, cdt, cdn);
},
conversion_factor: function(doc, cdt, cdn) {
if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = frappe.get_doc(cdt, cdn);
@ -138,7 +138,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
refresh_field("stock_qty", item.name, item.parentfield);
}
},
warehouse: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
if(item.item_code && item.warehouse) {
@ -152,12 +152,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
}
},
project_name: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
if(item.project_name) {
$.each(this.frm.doc[this.fname],
function(i, other_item) {
function(i, other_item) {
if(!other_item.project_name) {
other_item.project_name = item.project_name;
refresh_field("project_name", other_item.name, other_item.parentfield);
@ -165,35 +165,35 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
}
},
category: function(doc, cdt, cdn) {
// should be the category field of tax table
if(cdt != doc.doctype) {
this.calculate_taxes_and_totals();
}
},
calculate_taxes_and_totals: function() {
this._super();
this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
this.frm.refresh_fields();
},
calculate_item_values: function() {
var me = this;
$.each(this.frm.item_doclist, function(i, item) {
frappe.model.round_floats_in(item);
item.amount = flt(item.rate * item.qty, precision("amount", item));
item.item_tax_amount = 0.0;
me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate");
me._set_in_company_currency(item, "rate", "base_rate");
me._set_in_company_currency(item, "amount", "base_amount");
});
},
calculate_net_total: function() {
var me = this;
@ -202,57 +202,57 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
me.frm.doc.net_total += item.base_amount;
me.frm.doc.net_total_import += item.amount;
});
frappe.model.round_floats_in(this.frm.doc, ["net_total", "net_total_import"]);
},
calculate_totals: function() {
var tax_count = this.frm.tax_doclist.length;
this.frm.doc.grand_total = flt(tax_count ?
this.frm.doc.grand_total = flt(tax_count ?
this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
precision("grand_total"));
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total /
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total /
this.frm.doc.conversion_rate, precision("grand_total_import"));
this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
precision("total_tax"));
// rounded totals
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
}
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total_import", this.frm.doc.name)) {
this.frm.doc.rounded_total_import = Math.round(this.frm.doc.grand_total_import);
}
// other charges added/deducted
this.frm.doc.other_charges_added = 0.0
this.frm.doc.other_charges_deducted = 0.0
if(tax_count) {
this.frm.doc.other_charges_added = frappe.utils.sum($.map(this.frm.tax_doclist,
function(tax) { return (tax.add_deduct_tax == "Add"
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
this.frm.doc.other_charges_added = frappe.utils.sum($.map(this.frm.tax_doclist,
function(tax) { return (tax.add_deduct_tax == "Add"
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
tax.tax_amount : 0.0; }));
this.frm.doc.other_charges_deducted = frappe.utils.sum($.map(this.frm.tax_doclist,
function(tax) { return (tax.add_deduct_tax == "Deduct"
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
this.frm.doc.other_charges_deducted = frappe.utils.sum($.map(this.frm.tax_doclist,
function(tax) { return (tax.add_deduct_tax == "Deduct"
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
tax.tax_amount : 0.0; }));
frappe.model.round_floats_in(this.frm.doc,
["other_charges_added", "other_charges_deducted"]);
}
this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added /
this.frm.doc.conversion_rate, precision("other_charges_added_import"));
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted /
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted /
this.frm.doc.conversion_rate, precision("other_charges_deducted_import"));
},
_cleanup: function() {
this._super();
this.frm.doc.in_words = this.frm.doc.in_words_import = "";
if(this.frm.item_doclist.length) {
if(!frappe.meta.get_docfield(this.frm.item_doclist[0].doctype, "item_tax_amount", this.frm.doctype)) {
$.each(this.frm.item_doclist, function(i, item) {
@ -269,7 +269,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
}
},
calculate_outstanding_amount: function() {
if(this.frm.doc.doctype == "Purchase Invoice" && this.frm.doc.docstatus < 2) {
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
@ -279,11 +279,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
precision("outstanding_amount"));
}
},
set_item_tax_amount: function(item, tax, current_tax_amount) {
// item_tax_amount is the total tax amount applied on that item
// stored for valuation
//
// stored for valuation
//
// TODO: rename item_tax_amount to valuation_tax_amount
if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1 &&
frappe.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) {
@ -291,11 +291,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
item.item_tax_amount += flt(current_tax_amount, precision("item_tax_amount", item));
}
},
change_form_labels: function(company_currency) {
var me = this;
var field_label_map = {};
var setup_field_label_map = function(fields_list, currency) {
$.each(fields_list, function(i, fname) {
var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
@ -305,31 +305,31 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
});
};
setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words",
"other_charges_added", "other_charges_deducted",
"other_charges_added", "other_charges_deducted",
"outstanding_amount", "total_advance", "total_amount_to_pay", "rounded_total"],
company_currency);
setup_field_label_map(["net_total_import", "grand_total_import", "in_words_import",
"other_charges_added_import", "other_charges_deducted_import"], this.frm.doc.currency);
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
+ " = [?] " + company_currency);
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
+ " = [?] " + company_currency);
}
// toggle fields
this.frm.toggle_display(["conversion_rate", "net_total", "grand_total",
this.frm.toggle_display(["conversion_rate", "net_total", "grand_total",
"in_words", "other_charges_added", "other_charges_deducted"],
this.frm.doc.currency !== company_currency);
this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
this.frm.doc.price_list_currency !== company_currency);
this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
this.frm.doc.price_list_currency !== company_currency);
// set labels
$.each(field_label_map, function(fname, label) {
@ -337,46 +337,46 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
},
change_grid_labels: function(company_currency) {
var me = this;
var field_label_map = {};
var setup_field_label_map = function(fields_list, currency, parentfield) {
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
$.each(fields_list, function(i, fname) {
var docfield = frappe.meta.docfield_map[grid_doctype][fname];
if(docfield) {
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[grid_doctype + "-" + fname] =
field_label_map[grid_doctype + "-" + fname] =
label.trim() + " (" + currency + ")";
}
});
};
setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"],
company_currency, this.fname);
setup_field_label_map(["rate", "price_list_rate", "amount"],
this.frm.doc.currency, this.fname);
if(this.frm.fields_dict[this.other_fname]) {
setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
}
if(this.frm.fields_dict["advance_allocation_details"]) {
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
"advance_allocation_details");
}
// toggle columns
var item_grid = this.frm.fields_dict[this.fname].grid;
var fieldnames = $.map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], function(fname) {
return frappe.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
});
item_grid.set_column_disp(fieldnames, this.frm.doc.currency != company_currency);
// set labels
var $wrapper = $(this.frm.wrapper);
$.each(field_label_map, function(fname, label) {

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt
from frappe import msgprint, _, throw
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController
class PurchaseOrder(BuyingController):
@ -180,10 +181,9 @@ class PurchaseOrder(BuyingController):
@frappe.whitelist()
def make_purchase_receipt(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
def update_item(obj, target, source_parent):
target.qty = flt(obj.qty) - flt(obj.received_qty)
@ -218,10 +218,9 @@ def make_purchase_receipt(source_name, target_doc=None):
@frappe.whitelist()
def make_purchase_invoice(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
def update_item(obj, target, source_parent):
target.amount = flt(obj.amount) - flt(obj.billed_amt)

View File

@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController
class SupplierQuotation(BuyingController):
@ -52,11 +53,10 @@ class SupplierQuotation(BuyingController):
@frappe.whitelist()
def make_purchase_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.run_method("set_missing_values")
target.run_method("get_schedule_dates")
target.run_method("calculate_taxes_and_totals")
def update_item(obj, target, source_parent):
target.conversion_factor = 1

View File

@ -11,10 +11,6 @@ from erpnext.accounts.party import get_party_details
from erpnext.controllers.stock_controller import StockController
class BuyingController(StockController):
def onload_post_render(self):
# contact, address, item details
self.set_missing_values()
def validate(self):
super(BuyingController, self).validate()
if getattr(self, "supplier", None) and not self.supplier_name:

View File

@ -10,10 +10,6 @@ from frappe import _, throw
from erpnext.controllers.stock_controller import StockController
class SellingController(StockController):
def onload_post_render(self):
# contact, address, item details and pos details (if applicable)
self.set_missing_values()
def validate(self):
super(SellingController, self).validate()
self.validate_max_discount()

View File

@ -39,20 +39,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
onload_post_render: function() {
var me = this;
if(this.frm.doc.__islocal && this.frm.doc.company && !this.frm.doc.is_pos) {
if(!this.frm.doc.customer || !this.frm.doc.supplier) {
return this.frm.call({
doc: this.frm.doc,
method: "onload_post_render",
freeze: true,
callback: function(r) {
// remove this call when using client side mapper
me.set_dynamic_labels();
me.calculate_taxes_and_totals();
}
});
} else {
this.calculate_taxes_and_totals();
}
this.calculate_taxes_and_totals();
}
},

View File

@ -6,7 +6,7 @@ import frappe
from frappe import _
from frappe.utils import cstr, validate_email_add, cint, comma_and
from frappe import session
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.selling_controller import SellingController
@ -76,8 +76,6 @@ def make_customer(source_name, target_doc=None):
return _make_customer(source_name, target_doc)
def _make_customer(source_name, target_doc=None, ignore_permissions=False):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
if source.company_name:
target.customer_type = "Company"
@ -103,8 +101,6 @@ def _make_customer(source_name, target_doc=None, ignore_permissions=False):
@frappe.whitelist()
def make_opportunity(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
doclist = get_mapped_doc("Lead", source_name,
{"Lead": {
"doctype": "Opportunity",

View File

@ -3,11 +3,9 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint
from frappe import msgprint, _
from frappe.model.mapper import get_mapped_doc
from erpnext.utilities.transaction_base import TransactionBase
@ -129,11 +127,9 @@ class Opportunity(TransactionBase):
@frappe.whitelist()
def make_quotation(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
quotation = frappe.get_doc(target)
quotation.run_method("onload_post_render")
quotation.run_method("set_missing_values")
quotation.run_method("calculate_taxes_and_totals")
doclist = get_mapped_doc("Opportunity", source_name, {

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr
from frappe.model.mapper import get_mapped_doc
from frappe import _
from erpnext.controllers.selling_controller import SellingController
@ -96,8 +96,6 @@ def make_sales_order(source_name, target_doc=None):
return _make_sales_order(source_name, target_doc)
def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
from frappe.model.mapper import get_mapped_doc
customer = _make_customer(source_name, ignore_permissions)
def set_missing_values(source, target):
@ -105,9 +103,9 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
target.customer = customer.name
target.customer_name = customer.customer_name
si = frappe.get_doc(target)
si.ignore_permissions = ignore_permissions
si.run_method("onload_post_render")
target.ignore_permissions = ignore_permissions
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
doclist = get_mapped_doc("Quotation", source_name, {
"Quotation": {

View File

@ -247,7 +247,8 @@ class SalesOrder(SellingController):
return "order" if self.docstatus==1 else None
def set_missing_values(source, target):
target.run_method("onload_post_render")
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@frappe.whitelist()
def make_material_request(source_name, target_doc=None):
@ -316,7 +317,8 @@ def make_delivery_note(source_name, target_doc=None):
def make_sales_invoice(source_name, target_doc=None):
def set_missing_values(source, target):
target.is_pos = 0
target.run_method("onload_post_render")
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
def update_item(source, target, source_parent):
target.amount = flt(source.amount) - flt(source.billed_amt)

View File

@ -275,13 +275,14 @@ def make_sales_invoice(source_name, target_doc=None):
invoiced_qty_map = get_invoiced_qty_map(source_name)
def update_accounts(source, target):
si = frappe.get_doc(target)
si.is_pos = 0
si.run_method("onload_post_render")
target.is_pos = 0
target.run_method("set_missing_values")
if len(si.get("entries")) == 0:
if len(target.get("entries")) == 0:
frappe.throw(_("All these items have already been invoiced"))
target.run_method("calculate_taxes_and_totals")
def update_item(source_doc, target_doc, source_parent):
target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0)

View File

@ -9,6 +9,7 @@ import frappe
from frappe.utils import cstr, flt
from frappe import _
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController
class MaterialRequest(BuyingController):
@ -208,8 +209,8 @@ def _update_requested_qty(doc, mr_obj, mr_items):
})
def set_missing_values(source, target_doc):
po = frappe.get_doc(target_doc)
po.run_method("set_missing_values")
target_doc.run_method("set_missing_values")
target_doc.run_method("calculate_taxes_and_totals")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
@ -217,8 +218,6 @@ def update_item(obj, target, source_parent):
@frappe.whitelist()
def make_purchase_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
doclist = get_mapped_doc("Material Request", source_name, {
"Material Request": {
"doctype": "Purchase Order",
@ -244,23 +243,19 @@ def make_purchase_order(source_name, target_doc=None):
@frappe.whitelist()
def make_purchase_order_based_on_supplier(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
if target_doc:
if isinstance(target_doc, basestring):
import json
target_doc = frappe.get_doc(json.loads(target_doc))
target_doc = target_doc.get({"parentfield": ["!=", "po_details"]})
target_doc.set("po_details", [])
material_requests, supplier_items = get_material_requests_based_on_supplier(source_name)
def postprocess(source, target_doc):
target_doc[0].supplier = source_name
target_doc.supplier = source_name
set_missing_values(source, target_doc)
po_items = target_doc.get({"parentfield": "po_details"})
target_doc = target_doc.get({"parentfield": ["!=", "po_details"]}) + \
[d for d in po_items
if d.get("item_code") in supplier_items and d.get("qty") > 0]
target_doc.set("po_details", [d for d in target_doc.get("po_details")
if d.get("item_code") in supplier_items and d.get("qty" > 0)])
return target_doc
@ -282,7 +277,7 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None):
}
}, target_doc, postprocess)
return target_doc.as_dict()
return target_doc
def get_material_requests_based_on_supplier(supplier):
supplier_items = [d[0] for d in frappe.db.get_values("Item",
@ -300,8 +295,6 @@ def get_material_requests_based_on_supplier(supplier):
@frappe.whitelist()
def make_supplier_quotation(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
doclist = get_mapped_doc("Material Request", source_name, {
"Material Request": {
"doctype": "Supplier Quotation",
@ -324,8 +317,6 @@ def make_supplier_quotation(source_name, target_doc=None):
@frappe.whitelist()
def make_stock_entry(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.qty = flt(obj.qty) - flt(obj.ordered_qty)
@ -333,8 +324,7 @@ def make_stock_entry(source_name, target_doc=None):
def set_missing_values(source, target):
target.purpose = "Material Transfer"
se = frappe.get_doc(target)
se.run_method("get_stock_and_rate")
target.run_method("get_stock_and_rate")
doclist = get_mapped_doc("Material Request", source_name, {
"Material Request": {

View File

@ -294,6 +294,7 @@ def make_purchase_invoice(source_name, target_doc=None):
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("set_missing_values")
doc.run_method("calculate_taxes_and_totals")
doclist = get_mapped_doc("Purchase Receipt", source_name, {
"Purchase Receipt": {