[report][fix] Consider taxes only the tax contributed in invoice total
This commit is contained in:
parent
1e2a3f58c1
commit
b7b7f0062d
@ -119,16 +119,22 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_invoices(filters):
|
def get_invoices(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return frappe.db.sql("""select name, posting_date, credit_to, supplier, supplier_name,
|
return frappe.db.sql("""
|
||||||
bill_no, bill_date, remarks, base_net_total, base_grand_total, outstanding_amount
|
select
|
||||||
from `tabPurchase Invoice` where docstatus = 1 %s
|
name, posting_date, credit_to, supplier, supplier_name,
|
||||||
|
bill_no, bill_date, remarks, base_net_total, base_grand_total, outstanding_amount
|
||||||
|
from `tabPurchase Invoice`
|
||||||
|
where docstatus = 1 %s
|
||||||
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
def get_invoice_expense_map(invoice_list):
|
def get_invoice_expense_map(invoice_list):
|
||||||
expense_details = frappe.db.sql("""select parent, expense_account, sum(base_net_amount) as amount
|
expense_details = frappe.db.sql("""
|
||||||
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" %
|
select parent, expense_account, sum(base_net_amount) as amount
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
from `tabPurchase Invoice Item`
|
||||||
|
where parent in (%s)
|
||||||
|
group by parent, expense_account
|
||||||
|
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
invoice_expense_map = {}
|
invoice_expense_map = {}
|
||||||
for d in expense_details:
|
for d in expense_details:
|
||||||
@ -138,9 +144,12 @@ def get_invoice_expense_map(invoice_list):
|
|||||||
return invoice_expense_map
|
return invoice_expense_map
|
||||||
|
|
||||||
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
||||||
tax_details = frappe.db.sql("""select parent, account_head, sum(base_tax_amount_after_discount_amount) as tax_amount
|
tax_details = frappe.db.sql("""
|
||||||
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
select parent, account_head, sum(base_tax_amount_after_discount_amount) as tax_amount
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
from `tabPurchase Taxes and Charges`
|
||||||
|
where parent in (%s) and category in ('Total', 'Valuation and Total')
|
||||||
|
group by parent, account_head
|
||||||
|
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
invoice_tax_map = {}
|
invoice_tax_map = {}
|
||||||
for d in tax_details:
|
for d in tax_details:
|
||||||
@ -156,10 +165,11 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
|||||||
return invoice_expense_map, invoice_tax_map
|
return invoice_expense_map, invoice_tax_map
|
||||||
|
|
||||||
def get_invoice_po_pr_map(invoice_list):
|
def get_invoice_po_pr_map(invoice_list):
|
||||||
pi_items = frappe.db.sql("""select parent, purchase_order, purchase_receipt, po_detail,
|
pi_items = frappe.db.sql("""
|
||||||
project from `tabPurchase Invoice Item` where parent in (%s)
|
select parent, purchase_order, purchase_receipt, po_detail, project
|
||||||
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
|
from `tabPurchase Invoice Item`
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
where parent in (%s) and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')
|
||||||
|
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
invoice_po_pr_map = {}
|
invoice_po_pr_map = {}
|
||||||
for d in pi_items:
|
for d in pi_items:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user