[minor] added cost center to item wise sales register, fixes #5301
This commit is contained in:
parent
e778e59e4c
commit
6e837599b1
@ -21,7 +21,7 @@ def execute(filters=None):
|
|||||||
"width": 80
|
"width": 80
|
||||||
})
|
})
|
||||||
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
|
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for d in item_list:
|
for d in item_list:
|
||||||
delivery_note = None
|
delivery_note = None
|
||||||
@ -33,7 +33,7 @@ def execute(filters=None):
|
|||||||
|
|
||||||
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name,
|
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name,
|
||||||
d.customer_group, d.debit_to, d.mode_of_payment, d.territory, d.project, d.company, d.sales_order,
|
d.customer_group, d.debit_to, d.mode_of_payment, d.territory, d.project, d.company, d.sales_order,
|
||||||
delivery_note, d.income_account, d.qty, d.base_net_rate, d.base_net_amount]
|
delivery_note, d.income_account, d.cost_center, d.qty, d.base_net_rate, d.base_net_amount]
|
||||||
|
|
||||||
for tax in tax_accounts:
|
for tax in tax_accounts:
|
||||||
row.append(item_row_tax.get(d.name, {}).get(tax, 0))
|
row.append(item_row_tax.get(d.name, {}).get(tax, 0))
|
||||||
@ -51,12 +51,14 @@ def get_columns():
|
|||||||
_("Item Group") + ":Link/Item Group:100", _("Invoice") + ":Link/Sales Invoice:120",
|
_("Item Group") + ":Link/Item Group:100", _("Invoice") + ":Link/Sales Invoice:120",
|
||||||
_("Posting Date") + ":Date:80", _("Customer") + ":Link/Customer:120",
|
_("Posting Date") + ":Date:80", _("Customer") + ":Link/Customer:120",
|
||||||
_("Customer Name") + "::120", _("Customer Group") + ":Link/Customer Group:120",
|
_("Customer Name") + "::120", _("Customer Group") + ":Link/Customer Group:120",
|
||||||
_("Receivable Account") + ":Link/Account:120",
|
_("Receivable Account") + ":Link/Account:120",
|
||||||
_("Mode of Payment") + ":Link/Mode of Payment:80", _("Territory") + ":Link/Territory:80",
|
_("Mode of Payment") + ":Link/Mode of Payment:80", _("Territory") + ":Link/Territory:80",
|
||||||
_("Project") + ":Link/Project:80", _("Company") + ":Link/Company:100",
|
_("Project") + ":Link/Project:80", _("Company") + ":Link/Company:100",
|
||||||
_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
|
_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
|
||||||
_("Income Account") + ":Link/Account:140", _("Qty") + ":Float:120",
|
_("Income Account") + ":Link/Account:140", _("Cost Center") + ":Link/Cost Center:140",
|
||||||
_("Rate") + ":Currency/currency:120", _("Amount") + ":Currency/currency:120"
|
_("Qty") + ":Float:120",
|
||||||
|
_("Rate") + ":Currency/currency:120",
|
||||||
|
_("Amount") + ":Currency/currency:120"
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
@ -78,9 +80,9 @@ def get_items(filters):
|
|||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select
|
select
|
||||||
si_item.name, si_item.parent, si.posting_date, si.debit_to, si.project,
|
si_item.name, si_item.parent, si.posting_date, si.debit_to, si.project,
|
||||||
si.customer, si.remarks, si.territory, si.company, si.base_net_total,
|
si.customer, si.remarks, si.territory, si.company, si.base_net_total,
|
||||||
si_item.item_code, si_item.item_name, si_item.item_group, si_item.sales_order,
|
si_item.item_code, si_item.item_name, si_item.item_group, si_item.sales_order,
|
||||||
si_item.delivery_note, si_item.income_account, si_item.qty,
|
si_item.delivery_note, si_item.income_account, si_item.cost_center, si_item.qty,
|
||||||
si_item.base_net_rate, si_item.base_net_amount, si.customer_name,
|
si_item.base_net_rate, si_item.base_net_amount, si.customer_name,
|
||||||
si.customer_group, si_item.so_detail, si.mode_of_payment
|
si.customer_group, si_item.so_detail, si.mode_of_payment
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||||
@ -98,12 +100,12 @@ def get_tax_accounts(item_list, columns):
|
|||||||
item_row_map.setdefault(d.parent, {}).setdefault(d.item_code, []).append(d)
|
item_row_map.setdefault(d.parent, {}).setdefault(d.item_code, []).append(d)
|
||||||
|
|
||||||
tax_details = frappe.db.sql("""
|
tax_details = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
parent, account_head, item_wise_tax_detail,
|
parent, account_head, item_wise_tax_detail,
|
||||||
charge_type, base_tax_amount_after_discount_amount
|
charge_type, base_tax_amount_after_discount_amount
|
||||||
from `tabSales Taxes and Charges`
|
from `tabSales Taxes and Charges`
|
||||||
where
|
where
|
||||||
parenttype = 'Sales Invoice' and docstatus = 1
|
parenttype = 'Sales Invoice' and docstatus = 1
|
||||||
and (account_head is not null and account_head != '')
|
and (account_head is not null and account_head != '')
|
||||||
and parent in (%s)
|
and parent in (%s)
|
||||||
""" % ', '.join(['%s']*len(invoice_item_row)), tuple(invoice_item_row.keys()))
|
""" % ', '.join(['%s']*len(invoice_item_row)), tuple(invoice_item_row.keys()))
|
||||||
@ -111,21 +113,21 @@ def get_tax_accounts(item_list, columns):
|
|||||||
for parent, account_head, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
for parent, account_head, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
||||||
if account_head not in tax_accounts:
|
if account_head not in tax_accounts:
|
||||||
tax_accounts.append(account_head)
|
tax_accounts.append(account_head)
|
||||||
|
|
||||||
if item_wise_tax_detail:
|
if item_wise_tax_detail:
|
||||||
try:
|
try:
|
||||||
item_wise_tax_detail = json.loads(item_wise_tax_detail)
|
item_wise_tax_detail = json.loads(item_wise_tax_detail)
|
||||||
|
|
||||||
for item_code, tax_amount in item_wise_tax_detail.items():
|
for item_code, tax_amount in item_wise_tax_detail.items():
|
||||||
tax_amount = flt(tax_amount[1]) if isinstance(tax_amount, list) else flt(tax_amount)
|
tax_amount = flt(tax_amount[1]) if isinstance(tax_amount, list) else flt(tax_amount)
|
||||||
|
|
||||||
item_net_amount = sum([flt(d.base_net_amount)
|
item_net_amount = sum([flt(d.base_net_amount)
|
||||||
for d in item_row_map.get(parent, {}).get(item_code, [])])
|
for d in item_row_map.get(parent, {}).get(item_code, [])])
|
||||||
|
|
||||||
for d in item_row_map.get(parent, {}).get(item_code, []):
|
for d in item_row_map.get(parent, {}).get(item_code, []):
|
||||||
item_tax_amount = flt((tax_amount * d.base_net_amount) / item_net_amount) if item_net_amount else 0
|
item_tax_amount = flt((tax_amount * d.base_net_amount) / item_net_amount) if item_net_amount else 0
|
||||||
item_row_tax.setdefault(d.name, {})[account_head] = item_tax_amount
|
item_row_tax.setdefault(d.name, {})[account_head] = item_tax_amount
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
elif charge_type == "Actual" and tax_amount:
|
elif charge_type == "Actual" and tax_amount:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user