|
|
@ -248,19 +248,19 @@ def get_columns(invoice_list, additional_table_columns): |
|
|
|
income_accounts = frappe.db.sql_list("""select distinct income_account |
|
|
|
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s) |
|
|
|
order by income_account""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list)) |
|
|
|
|
|
|
|
tax_accounts = frappe.db.sql_list("""select distinct account_head |
|
|
|
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice' |
|
|
|
and docstatus = 1 and base_tax_amount_after_discount_amount != 0 |
|
|
|
and parent in (%s) order by account_head""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list)) |
|
|
|
|
|
|
|
unrealized_profit_loss_accounts = frappe.db.sql_list("""SELECT distinct unrealized_profit_loss_account |
|
|
|
from `tabSales Invoice` where docstatus = 1 and name in (%s) |
|
|
|
and ifnull(unrealized_profit_loss_account, '') != '' |
|
|
|
order by unrealized_profit_loss_account""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list)) |
|
|
|
|
|
|
|
for account in income_accounts: |
|
|
|
income_columns.append({ |
|
|
@ -406,7 +406,7 @@ def get_invoices(filters, additional_query_columns): |
|
|
|
def get_invoice_income_map(invoice_list): |
|
|
|
income_details = frappe.db.sql("""select parent, income_account, sum(base_net_amount) as amount |
|
|
|
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1) |
|
|
|
|
|
|
|
invoice_income_map = {} |
|
|
|
for d in income_details: |
|
|
@ -419,7 +419,7 @@ def get_internal_invoice_map(invoice_list): |
|
|
|
unrealized_amount_details = frappe.db.sql("""SELECT name, unrealized_profit_loss_account, |
|
|
|
base_net_total as amount from `tabSales Invoice` where name in (%s) |
|
|
|
and is_internal_customer = 1 and company = represents_company""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1) |
|
|
|
|
|
|
|
internal_invoice_map = {} |
|
|
|
for d in unrealized_amount_details: |
|
|
@ -432,7 +432,7 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts): |
|
|
|
tax_details = frappe.db.sql("""select parent, account_head, |
|
|
|
sum(base_tax_amount_after_discount_amount) as tax_amount |
|
|
|
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1) |
|
|
|
|
|
|
|
invoice_tax_map = {} |
|
|
|
for d in tax_details: |
|
|
@ -451,7 +451,7 @@ def get_invoice_so_dn_map(invoice_list): |
|
|
|
si_items = frappe.db.sql("""select parent, sales_order, delivery_note, so_detail |
|
|
|
from `tabSales Invoice Item` where parent in (%s) |
|
|
|
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1) |
|
|
|
|
|
|
|
invoice_so_dn_map = {} |
|
|
|
for d in si_items: |
|
|
@ -475,7 +475,7 @@ def get_invoice_cc_wh_map(invoice_list): |
|
|
|
si_items = frappe.db.sql("""select parent, cost_center, warehouse |
|
|
|
from `tabSales Invoice Item` where parent in (%s) |
|
|
|
and (ifnull(cost_center, '') != '' or ifnull(warehouse, '') != '')""" % |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) |
|
|
|
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1) |
|
|
|
|
|
|
|
invoice_cc_wh_map = {} |
|
|
|
for d in si_items: |
|
|
|