Landed Cost Voucher: Add field and fixed reposting issue
This commit is contained in:
parent
c1a7c3b08b
commit
3f671ea60f
@ -91,3 +91,4 @@ erpnext.patches.v4_2.update_requested_and_ordered_qty
|
|||||||
execute:frappe.delete_doc("DocType", "Contact Control")
|
execute:frappe.delete_doc("DocType", "Contact Control")
|
||||||
erpnext.patches.v4_2.recalculate_bom_costs
|
erpnext.patches.v4_2.recalculate_bom_costs
|
||||||
erpnext.patches.v4_2.discount_amount
|
erpnext.patches.v4_2.discount_amount
|
||||||
|
erpnext.patches.v4_2.update_landed_cost_voucher
|
||||||
|
10
erpnext/patches/v4_2/update_landed_cost_voucher.py
Normal file
10
erpnext/patches/v4_2/update_landed_cost_voucher.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("stock", "doctype", "landed_cost_voucher")
|
||||||
|
frappe.db.sql("""update `tabLanded Cost Voucher` set distribute_charges_based_on = 'Amount'
|
||||||
|
where docstatus=1""")
|
@ -18,17 +18,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"width": "50%"
|
"width": "50%"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Account",
|
|
||||||
"options": "Account",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "amount",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@ -40,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-08-08 13:12:02.594698",
|
"modified": "2015-01-21 11:51:33.964438",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Landed Cost Taxes and Charges",
|
"name": "Landed Cost Taxes and Charges",
|
||||||
|
@ -19,17 +19,6 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.frm.fields_dict.landed_cost_taxes_and_charges.grid.get_field('account').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', 'Expense Account']],
|
|
||||||
['Account', 'company', '=', me.frm.doc.company]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.frm.add_fetch("purchase_receipt", "supplier", "supplier");
|
this.frm.add_fetch("purchase_receipt", "supplier", "supplier");
|
||||||
this.frm.add_fetch("purchase_receipt", "posting_date", "posting_date");
|
this.frm.add_fetch("purchase_receipt", "posting_date", "posting_date");
|
||||||
this.frm.add_fetch("purchase_receipt", "grand_total", "grand_total");
|
this.frm.add_fetch("purchase_receipt", "grand_total", "grand_total");
|
||||||
@ -37,30 +26,32 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var help_content = ['<table class="table table-bordered" style="background-color: #f9f9f9;">',
|
var help_content = [
|
||||||
'<tr><td>',
|
'<br><br>',
|
||||||
'<h4><i class="icon-hand-right"></i> ',
|
'<table class="table table-bordered" style="background-color: #f9f9f9;">',
|
||||||
__('Notes'),
|
'<tr><td>',
|
||||||
':</h4>',
|
'<h4><i class="icon-hand-right"></i> ',
|
||||||
'<ul>',
|
__('Notes'),
|
||||||
'<li>',
|
':</h4>',
|
||||||
__("Charges will be distributed proportionately based on item amount"),
|
'<ul>',
|
||||||
'</li>',
|
'<li>',
|
||||||
'<li>',
|
__("Charges will be distributed proportionately based on item qty or amount, as per your selection"),
|
||||||
__("Remove item if charges is not applicable to that item"),
|
'</li>',
|
||||||
'</li>',
|
'<li>',
|
||||||
'<li>',
|
__("Remove item if charges is not applicable to that item"),
|
||||||
__("Charges are updated in Purchase Receipt against each item"),
|
'</li>',
|
||||||
'</li>',
|
'<li>',
|
||||||
'<li>',
|
__("Charges are updated in Purchase Receipt against each item"),
|
||||||
__("Item valuation rate is recalculated considering landed cost voucher amount"),
|
'</li>',
|
||||||
'</li>',
|
'<li>',
|
||||||
'<li>',
|
__("Item valuation rate is recalculated considering landed cost voucher amount"),
|
||||||
__("Stock Ledger Entries and GL Entries are reposted for the selected Purchase Receipts"),
|
'</li>',
|
||||||
'</li>',
|
'<li>',
|
||||||
'</ul>',
|
__("Stock Ledger Entries and GL Entries are reposted for the selected Purchase Receipts"),
|
||||||
'</td></tr>',
|
'</li>',
|
||||||
'</table>'].join("\n");
|
'</ul>',
|
||||||
|
'</td></tr>',
|
||||||
|
'</table>'].join("\n");
|
||||||
|
|
||||||
set_field_options("landed_cost_help", help_content);
|
set_field_options("landed_cost_help", help_content);
|
||||||
},
|
},
|
||||||
|
@ -44,6 +44,13 @@
|
|||||||
"options": "Landed Cost Taxes and Charges",
|
"options": "Landed Cost Taxes and Charges",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sec_break1",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"options": "Simple",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "total_taxes_and_charges",
|
"fieldname": "total_taxes_and_charges",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@ -53,13 +60,6 @@
|
|||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "landed_cost_help",
|
|
||||||
"fieldtype": "HTML",
|
|
||||||
"label": "Landed Cost Help",
|
|
||||||
"options": "",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -69,11 +69,40 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Amount",
|
||||||
|
"fieldname": "distribute_charges_based_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Distribute Charges Based On",
|
||||||
|
"options": "\nQty\nAmount",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sec_break2",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "landed_cost_help",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Landed Cost Help",
|
||||||
|
"options": "",
|
||||||
|
"permlevel": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-usd",
|
"icon": "icon-usd",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2014-09-01 12:05:46.834513",
|
"modified": "2015-01-21 11:56:37.698326",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Landed Cost Voucher",
|
"name": "Landed Cost Voucher",
|
||||||
|
@ -7,9 +7,6 @@ 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", [])
|
||||||
@ -69,10 +66,11 @@ class LandedCostVoucher(Document):
|
|||||||
self.total_taxes_and_charges = sum([flt(d.amount) for d in self.get("landed_cost_taxes_and_charges")])
|
self.total_taxes_and_charges = sum([flt(d.amount) for d in self.get("landed_cost_taxes_and_charges")])
|
||||||
|
|
||||||
def set_applicable_charges_for_item(self):
|
def set_applicable_charges_for_item(self):
|
||||||
total_item_cost = sum([flt(d.amount) for d in self.get("landed_cost_items")])
|
based_on = self.distribute_charges_based_on.lower()
|
||||||
|
total = sum([flt(d.get(based_on)) for d in self.get("landed_cost_items")])
|
||||||
|
|
||||||
for item in self.get("landed_cost_items"):
|
for item in self.get("landed_cost_items"):
|
||||||
item.applicable_charges = flt(item.amount) * flt(self.total_taxes_and_charges) / flt(total_item_cost)
|
item.applicable_charges = flt(item.get(based_on)) * flt(self.total_taxes_and_charges) / flt(total)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.update_landed_cost()
|
self.update_landed_cost()
|
||||||
@ -92,13 +90,16 @@ class LandedCostVoucher(Document):
|
|||||||
pr.update_valuation_rate("purchase_receipt_details")
|
pr.update_valuation_rate("purchase_receipt_details")
|
||||||
|
|
||||||
# save will update landed_cost_voucher_amount and voucher_amount in PR,
|
# save will update landed_cost_voucher_amount and voucher_amount in PR,
|
||||||
# as those fields are ellowed to edit after submit
|
# as those fields are allowed to edit after submit
|
||||||
pr.save()
|
pr.save()
|
||||||
|
|
||||||
# update stock & gl entries for cancelled state of PR
|
# delete stock ledger entries & gl entries for cancelled state of PR
|
||||||
pr.docstatus = 2
|
|
||||||
pr.update_stock_ledger()
|
frappe.db.sql("""delete from `tabStock Ledger Entry`
|
||||||
pr.make_gl_entries_on_cancel()
|
where voucher_type='Purchase Receipt' and voucher_no=%s""", pr.name)
|
||||||
|
|
||||||
|
frappe.db.sql("""delete from `tabGL Entry`
|
||||||
|
where voucher_type='Purchase Receipt' and voucher_no=%s""", pr.name)
|
||||||
|
|
||||||
# update stock & gl entries for submit state of PR
|
# update stock & gl entries for submit state of PR
|
||||||
pr.docstatus = 1
|
pr.docstatus = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user