Removed old landed cost wizard
This commit is contained in:
parent
b21b6598f1
commit
fe39442c48
@ -76,3 +76,4 @@ erpnext.patches.v4_2.toggle_rounded_total #2014-07-30
|
||||
erpnext.patches.v4_2.fix_account_master_type
|
||||
erpnext.patches.v4_2.update_project_milestones
|
||||
erpnext.patches.v4_2.add_currency_turkish_lira #2014-08-08
|
||||
execute:frappe.delete_doc("DocType", "Landed Cost Wizard")
|
||||
|
@ -1 +0,0 @@
|
||||
Tool to distribute costs as part of Item value after the Item has been received. This is typically in case where bills related to Items are received much later and for multiple Item. (specially Custom Duty)
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,46 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
frappe.provide("erpnext.stock");
|
||||
frappe.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
|
||||
erpnext.stock.LandedCostWizard = erpnext.stock.StockController.extend({
|
||||
setup: function() {
|
||||
var me = this;
|
||||
this.frm.fields_dict.lc_pr_details.grid.get_field('purchase_receipt').get_query =
|
||||
function() {
|
||||
if(!me.frm.doc.company) msgprint(__("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Purchase Receipt', 'docstatus', '=', '1'],
|
||||
['Purchase Receipt', 'company', '=', me.frm.doc.company],
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
this.frm.fields_dict.landed_cost_details.grid.get_field('account_head').get_query = function() {
|
||||
if(!me.frm.doc.company) msgprint(__("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Account', 'group_or_ledger', '=', 'Ledger'],
|
||||
['Account', 'account_type', 'in', 'Tax, Chargeable'],
|
||||
['Account', 'company', '=', me.frm.doc.company]
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
this.frm.fields_dict.landed_cost_details.grid.get_field('cost_center').get_query =
|
||||
function() {
|
||||
if(!me.frm.doc.company) msgprint(__("Please enter company first"));
|
||||
return {
|
||||
filters:[
|
||||
['Cost Center', 'group_or_ledger', '=', 'Ledger'],
|
||||
['Cost Center', 'company', '=', me.frm.doc.company]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cur_frm.script_manager.make(erpnext.stock.LandedCostWizard);
|
@ -1,83 +0,0 @@
|
||||
{
|
||||
"creation": "2013-01-22 16:50:39.000000",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"label": "Company",
|
||||
"options": "Company",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Select Purchase Receipts",
|
||||
"options": "Simple",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "lc_pr_details",
|
||||
"fieldtype": "Table",
|
||||
"label": "Landed Cost Purchase Receipts",
|
||||
"options": "Landed Cost Purchase Receipt",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break1",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Add Taxes and Charges",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "landed_cost_details",
|
||||
"fieldtype": "Table",
|
||||
"label": "Landed Cost Items",
|
||||
"options": "Landed Cost Item",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "update_landed_cost",
|
||||
"fieldtype": "Button",
|
||||
"label": "Update Landed Cost",
|
||||
"options": "update_landed_cost",
|
||||
"permlevel": 0
|
||||
}
|
||||
],
|
||||
"icon": "icon-magic",
|
||||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"modified": "2013-12-20 19:23:18.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Landed Cost Wizard",
|
||||
"owner": "wasim@webnotestech.com",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
}
|
||||
]
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
from frappe import msgprint, _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LandedCostWizard(Document):
|
||||
|
||||
def update_landed_cost(self):
|
||||
"""
|
||||
Add extra cost and recalculate all values in pr,
|
||||
Recalculate valuation rate in all sle after pr posting date
|
||||
"""
|
||||
purchase_receipts = [row.purchase_receipt for row in
|
||||
self.get("lc_pr_details")]
|
||||
|
||||
self.validate_purchase_receipts(purchase_receipts)
|
||||
self.cancel_pr(purchase_receipts)
|
||||
self.add_charges_in_pr(purchase_receipts)
|
||||
self.submit_pr(purchase_receipts)
|
||||
msgprint(_("Landed Cost updated successfully"))
|
||||
|
||||
def validate_purchase_receipts(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
if frappe.db.get_value("Purchase Receipt", pr, "docstatus") != 1:
|
||||
frappe.throw(_("Purchase Receipt {0} is not submitted").format(pr))
|
||||
|
||||
def add_charges_in_pr(self, purchase_receipts):
|
||||
""" Add additional charges in selected pr proportionately"""
|
||||
total_amt = self.get_total_pr_amt(purchase_receipts)
|
||||
|
||||
for pr in purchase_receipts:
|
||||
pr_doc = frappe.get_doc('Purchase Receipt', pr)
|
||||
pr_items = pr_doc.get("purchase_tax_details")
|
||||
|
||||
for lc in self.get("landed_cost_details"):
|
||||
amt = flt(lc.amount) * flt(pr_doc.net_total)/ flt(total_amt)
|
||||
|
||||
matched_row = pr_doc.get("other_charges", {
|
||||
"category": "Valuation",
|
||||
"add_deduct_tax": "Add",
|
||||
"charge_type": "Actual",
|
||||
"account_head": lc.account_head
|
||||
})
|
||||
|
||||
if not matched_row: # add if not exists
|
||||
ch = pr_doc.append("other_charges")
|
||||
ch.category = 'Valuation'
|
||||
ch.add_deduct_tax = 'Add'
|
||||
ch.charge_type = 'Actual'
|
||||
ch.description = lc.description
|
||||
ch.account_head = lc.account_head
|
||||
ch.cost_center = lc.cost_center
|
||||
ch.rate = amt
|
||||
ch.tax_amount = amt
|
||||
ch.docstatus = 1
|
||||
ch.db_insert()
|
||||
else: # overwrite if exists
|
||||
matched_row[0].rate = amt
|
||||
matched_row[0].tax_amount = amt
|
||||
matched_row[0].cost_center = lc.cost_center
|
||||
|
||||
pr_doc.run_method("validate")
|
||||
pr_doc._validate_mandatory()
|
||||
for d in pr_doc.get_all_children():
|
||||
d.db_update()
|
||||
|
||||
def get_total_pr_amt(self, purchase_receipts):
|
||||
return frappe.db.sql("""SELECT SUM(net_total) FROM `tabPurchase Receipt`
|
||||
WHERE name in (%s)""" % ', '.join(['%s']*len(purchase_receipts)),
|
||||
tuple(purchase_receipts))[0][0]
|
||||
|
||||
def cancel_pr(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
pr_doc = frappe.get_doc("Purchase Receipt", pr)
|
||||
|
||||
pr_doc.run_method("update_ordered_qty")
|
||||
|
||||
frappe.db.sql("""delete from `tabStock Ledger Entry`
|
||||
where voucher_type='Purchase Receipt' and voucher_no=%s""", pr)
|
||||
frappe.db.sql("""delete from `tabGL Entry` where voucher_type='Purchase Receipt'
|
||||
and voucher_no=%s""", pr)
|
||||
|
||||
def submit_pr(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
pr_doc = frappe.get_doc("Purchase Receipt", pr)
|
||||
pr_doc.run_method("update_ordered_qty")
|
||||
pr_doc.run_method("update_stock")
|
||||
pr_doc.run_method("make_gl_entries")
|
Loading…
x
Reference in New Issue
Block a user