landed cost voucher design changed #1921
This commit is contained in:
parent
4436157da1
commit
f6ea21c8ae
@ -36,15 +36,6 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "warehouse",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Warehouse",
|
||||
"options": "Warehouse",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break2",
|
||||
"fieldtype": "Column Break",
|
||||
@ -53,6 +44,7 @@
|
||||
{
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Qty",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
@ -60,6 +52,7 @@
|
||||
{
|
||||
"fieldname": "rate",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 0,
|
||||
"label": "Rate",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
@ -77,27 +70,23 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "old_valuation_rate",
|
||||
"fieldname": "applicable_charges",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 1,
|
||||
"label": "Old Valuation Rate",
|
||||
"label": "Applicable Charges",
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"width": ""
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "new_valuation_rate",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 1,
|
||||
"label": "New Valuation Rate",
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"width": ""
|
||||
"fieldname": "pr_item_row_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "PR Item Row Id",
|
||||
"permlevel": 0
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2014-07-11 15:20:53.714633",
|
||||
"modified": "2014-07-15 18:01:26.152422",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Landed Cost Item",
|
||||
|
@ -50,7 +50,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
||||
|
||||
amount: function() {
|
||||
this.set_total_taxes_and_charges();
|
||||
this.set_new_valuation_rate();
|
||||
this.set_applicable_charges_for_item();
|
||||
},
|
||||
|
||||
set_total_taxes_and_charges: function() {
|
||||
@ -61,7 +61,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
||||
cur_frm.set_value("total_taxes_and_charges", total_taxes_and_charges);
|
||||
},
|
||||
|
||||
set_new_valuation_rate: function() {
|
||||
set_applicable_charges_for_item: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.landed_cost_taxes_and_charges.length) {
|
||||
var total_item_cost = 0.0;
|
||||
@ -70,8 +70,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
||||
});
|
||||
|
||||
$.each(this.frm.doc.landed_cost_items, function(i, item) {
|
||||
var charges_for_item = flt(item.amount) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)
|
||||
item.new_valuation_rate = flt(item.old_valuation_rate) + charges_for_item
|
||||
item.applicable_charges = flt(item.amount) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)
|
||||
});
|
||||
refresh_field("landed_cost_items");
|
||||
}
|
||||
|
@ -7,11 +7,15 @@ from frappe import _
|
||||
from frappe.utils import flt
|
||||
from frappe.model.document import Document
|
||||
|
||||
from erpnext.stock.utils import get_valuation_method
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
|
||||
class LandedCostVoucher(Document):
|
||||
def get_items_from_purchase_receipts(self):
|
||||
self.set("landed_cost_items", [])
|
||||
for pr in self.get("landed_cost_purchase_receipts"):
|
||||
pr_items = frappe.db.sql("""select item_code, description, qty, rate, amount, valuation_rate, warehouse
|
||||
pr_items = frappe.db.sql("""select pr_tem.item_code, pr_tem.description,
|
||||
pr_tem.qty, pr_tem.rate, pr_tem.amount, pr_tem.name
|
||||
from `tabPurchase Receipt Item` where parent = %s""", pr.purchase_receipt, as_dict=True)
|
||||
for d in pr_items:
|
||||
item = self.append("landed_cost_items")
|
||||
@ -20,12 +24,12 @@ class LandedCostVoucher(Document):
|
||||
item.qty = d.qty
|
||||
item.rate = d.rate
|
||||
item.amount = d.amount
|
||||
item.old_valuation_rate = d.valuation_rate
|
||||
item.purchase_receipt = pr.purchase_receipt
|
||||
item.warehouse = d.warehouse
|
||||
item.pr_item_row_id = d.name
|
||||
|
||||
if self.get("landed_cost_taxes_and_charges"):
|
||||
self.set_applicable_charges_for_item()
|
||||
|
||||
if self.total_taxes_and_charges:
|
||||
self.set_new_valuation_rate()
|
||||
|
||||
def validate(self):
|
||||
self.check_mandatory()
|
||||
@ -34,7 +38,7 @@ class LandedCostVoucher(Document):
|
||||
if not self.get("landed_cost_items"):
|
||||
self.get_items_from_purchase_receipts()
|
||||
else:
|
||||
self.set_new_valuation_rate()
|
||||
self.set_applicable_charges_for_item()
|
||||
|
||||
def check_mandatory(self):
|
||||
if not self.get("landed_cost_purchase_receipts"):
|
||||
@ -55,29 +59,21 @@ class LandedCostVoucher(Document):
|
||||
if not item.purchase_receipt:
|
||||
frappe.throw(_("Item must be added using 'Get Items from Purchase Receipts' button"))
|
||||
elif item.purchase_receipt not in purchase_receipts:
|
||||
frappe.throw(_("Item Row {0}: Purchase Reciept {1} does not exist in above 'Purchase Receipts' table")
|
||||
frappe.throw(_("Item Row {0}: Purchase Receipt {1} does not exist in above 'Purchase Receipts' table")
|
||||
.format(item.idx, item.purchase_receipt))
|
||||
|
||||
def set_total_taxes_and_charges(self):
|
||||
total_taxes_and_charges = 0.0
|
||||
for d in self.get("landed_cost_taxes_and_charges"):
|
||||
total_taxes_and_charges += flt(d.amount)
|
||||
|
||||
self.total_taxes_and_charges = total_taxes_and_charges
|
||||
self.total_taxes_and_charges = sum([flt(d.amount) for d in self.get("landed_cost_taxes_and_charges")])
|
||||
|
||||
def set_new_valuation_rate(self):
|
||||
def set_applicable_charges_for_item(self):
|
||||
total_item_cost = sum([flt(d.amount) for d in self.get("landed_cost_items")])
|
||||
|
||||
for item in self.get("landed_cost_items"):
|
||||
charges_for_item = flt(item.amount) * flt(self.total_taxes_and_charges) / flt(total_item_cost)
|
||||
item.new_valuation_rate = flt(item.old_valuation_rate) + charges_for_item
|
||||
item.applicable_charges = flt(item.amount) * flt(self.total_taxes_and_charges) / flt(total_item_cost)
|
||||
|
||||
def on_submit(self):
|
||||
self.make_stock_ledger_entries()
|
||||
self.make_gl_entries()
|
||||
purchase_receipts = list(set([d.purchase_receipt for d in self.get("landed_cost_items")]))
|
||||
|
||||
def make_stock_ledger_entries(self):
|
||||
pass
|
||||
|
||||
def make_gl_entries(self):
|
||||
pass
|
||||
for purchase_receipt in purchase_receipts:
|
||||
pr = frappe.get_doc("Purchase Receipt", purchase_receipt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user