Distribute tax amount between items in stock entry
This commit is contained in:
parent
aa87931172
commit
f6aad5ed2d
@ -369,6 +369,7 @@
|
|||||||
"fieldname": "total_incoming_value",
|
"fieldname": "total_incoming_value",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Total Incoming Value",
|
"label": "Total Incoming Value",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -383,6 +384,7 @@
|
|||||||
"fieldname": "total_outgoing_value",
|
"fieldname": "total_outgoing_value",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Total Outgoing Value",
|
"label": "Total Outgoing Value",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -391,6 +393,7 @@
|
|||||||
"fieldname": "value_difference",
|
"fieldname": "value_difference",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Total Value Difference (Out - In)",
|
"label": "Total Value Difference (Out - In)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -404,6 +407,30 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "taxes_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Taxes and Charges",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "taxes",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Taxes and Charges",
|
||||||
|
"options": "Landed Cost Taxes and Charges",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_taxes_and_charges",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Taxes and Charges",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "fold",
|
"fieldname": "fold",
|
||||||
"fieldtype": "Fold",
|
"fieldtype": "Fold",
|
||||||
@ -678,7 +705,7 @@
|
|||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-07-22 18:47:20.328749",
|
"modified": "2015-07-24 18:47:55.902154",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Entry",
|
"name": "Stock Entry",
|
||||||
|
@ -50,6 +50,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_bom()
|
self.validate_bom()
|
||||||
self.validate_finished_goods()
|
self.validate_finished_goods()
|
||||||
self.validate_with_material_request()
|
self.validate_with_material_request()
|
||||||
|
self.distribute_taxes()
|
||||||
self.validate_valuation_rate()
|
self.validate_valuation_rate()
|
||||||
self.set_total_incoming_outgoing_value()
|
self.set_total_incoming_outgoing_value()
|
||||||
self.set_total_amount()
|
self.set_total_amount()
|
||||||
@ -221,7 +222,7 @@ class StockEntry(StockController):
|
|||||||
if d.s_warehouse and not d.t_warehouse:
|
if d.s_warehouse and not d.t_warehouse:
|
||||||
valuation_at_source += flt(d.amount)
|
valuation_at_source += flt(d.amount)
|
||||||
if d.t_warehouse and not d.s_warehouse:
|
if d.t_warehouse and not d.s_warehouse:
|
||||||
valuation_at_target += flt(d.amount)
|
valuation_at_target += flt(d.amount) + flt(d.tax_amount)
|
||||||
|
|
||||||
if valuation_at_target + 0.001 < valuation_at_source:
|
if valuation_at_target + 0.001 < valuation_at_source:
|
||||||
frappe.throw(_("Total valuation ({0}) for manufactured or repacked item(s) can not be less than total valuation of raw materials ({1})").format(valuation_at_target,
|
frappe.throw(_("Total valuation ({0}) for manufactured or repacked item(s) can not be less than total valuation of raw materials ({1})").format(valuation_at_target,
|
||||||
@ -230,10 +231,10 @@ class StockEntry(StockController):
|
|||||||
def set_total_incoming_outgoing_value(self):
|
def set_total_incoming_outgoing_value(self):
|
||||||
self.total_incoming_value = self.total_outgoing_value = 0.0
|
self.total_incoming_value = self.total_outgoing_value = 0.0
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
if d.s_warehouse:
|
|
||||||
self.total_incoming_value += flt(d.amount)
|
|
||||||
if d.t_warehouse:
|
if d.t_warehouse:
|
||||||
self.total_outgoing_value += flt(d.amount)
|
self.total_incoming_value += flt(d.amount)
|
||||||
|
if d.s_warehouse:
|
||||||
|
self.total_outgoing_value += flt(d.amount) + flt(d.tax_amount)
|
||||||
|
|
||||||
self.value_difference = self.total_outgoing_value - self.total_incoming_value
|
self.value_difference = self.total_outgoing_value - self.total_incoming_value
|
||||||
|
|
||||||
@ -316,7 +317,7 @@ class StockEntry(StockController):
|
|||||||
bom = frappe.db.get_value("BOM", bom_no, ["operating_cost", "quantity"], as_dict=1)
|
bom = frappe.db.get_value("BOM", bom_no, ["operating_cost", "quantity"], as_dict=1)
|
||||||
operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
|
operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
|
||||||
|
|
||||||
return operation_cost_per_unit + (flt(self.additional_operating_cost) / flt(qty))
|
return operation_cost_per_unit
|
||||||
|
|
||||||
def validate_purchase_order(self):
|
def validate_purchase_order(self):
|
||||||
"""Throw exception if more raw material is transferred against Purchase Order than in
|
"""Throw exception if more raw material is transferred against Purchase Order than in
|
||||||
@ -402,22 +403,23 @@ class StockEntry(StockController):
|
|||||||
|
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
tax_amount = flt(d.tax_amount, d.precision("tax_amount"))
|
tax_amount = flt(d.tax_amount, d.precision("tax_amount"))
|
||||||
gl_entries.append(self.get_gl_dict({
|
if tax_amount:
|
||||||
"account": d.expense_account,
|
gl_entries.append(self.get_gl_dict({
|
||||||
"against": expenses_included_in_valuation,
|
"account": expenses_included_in_valuation,
|
||||||
"cost_center": d.cost_center,
|
"against": d.expense_account,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"cost_center": d.cost_center,
|
||||||
"debit": tax_amount
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
}))
|
"credit": tax_amount
|
||||||
|
}))
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": expenses_included_in_valuation,
|
|
||||||
"against": warehouse_account[d.warehouse],
|
|
||||||
"cost_center": d.cost_center,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
|
||||||
"credit": tax_amount
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": d.expense_account,
|
||||||
|
"against": expenses_included_in_valuation,
|
||||||
|
"cost_center": d.cost_center,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
|
"credit": -1 * tax_amount
|
||||||
|
}))
|
||||||
|
|
||||||
return gl_entries
|
return gl_entries
|
||||||
|
|
||||||
def update_production_order(self):
|
def update_production_order(self):
|
||||||
@ -693,6 +695,12 @@ class StockEntry(StockController):
|
|||||||
if expiry_date:
|
if expiry_date:
|
||||||
if getdate(self.posting_date) > getdate(expiry_date):
|
if getdate(self.posting_date) > getdate(expiry_date):
|
||||||
frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
|
frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
|
||||||
|
|
||||||
|
def distribute_taxes(self):
|
||||||
|
self.total_taxes_and_charges = sum([flt(t.amount) for t in self.get("taxes")])
|
||||||
|
for d in self.get("items"):
|
||||||
|
if d.t_warehouse and self.total_incoming_value:
|
||||||
|
d.tax_amount = (flt(d.amount) / flt(self.total_incoming_value)) * self.total_taxes_and_charges
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
@ -160,6 +160,13 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tax_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Tax Amount",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "col_break3",
|
"fieldname": "col_break3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
@ -344,7 +351,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-07-02 05:32:56.511570",
|
"modified": "2015-07-24 17:03:44.214018",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Entry Detail",
|
"name": "Stock Entry Detail",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user