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