chore: Fix Received/Delivered Items to Billed Logic

This commit is contained in:
marination 2020-09-09 16:24:11 +05:30
parent 52e87d1a4f
commit efb211af6d
4 changed files with 42 additions and 17 deletions

View File

@ -14,11 +14,19 @@ def execute(filters=None):
def get_column(): def get_column():
return [ return [
_("Delivery Note") + ":Link/Delivery Note:120", _("Status") + "::120", _("Date") + ":Date:100", _("Delivery Note") + ":Link/Delivery Note:160",
_("Suplier") + ":Link/Customer:120", _("Customer Name") + "::120", _("Date") + ":Date:100",
_("Project") + ":Link/Project:120", _("Item Code") + ":Link/Item:120", _("Customer") + ":Link/Customer:120",
_("Amount") + ":Currency:100", _("Billed Amount") + ":Currency:100", _("Pending Amount") + ":Currency:100", _("Customer Name") + "::120",
_("Item Name") + "::120", _("Description") + "::120", _("Company") + ":Link/Company:120", _("Item Code") + ":Link/Item:120",
_("Amount") + ":Currency:100",
_("Billed Amount") + ":Currency:100",
_("Returned Amount") + ":Currency:120",
_("Pending Amount") + ":Currency:100",
_("Item Name") + "::120",
_("Description") + "::120",
_("Project") + ":Link/Project:120",
_("Company") + ":Link/Company:120",
] ]
def get_args(): def get_args():

View File

@ -17,18 +17,26 @@ def get_ordered_to_be_billed_data(args):
return frappe.db.sql(""" return frappe.db.sql("""
Select Select
`{parent_tab}`.name, `{parent_tab}`.status, `{parent_tab}`.{date_field}, `{parent_tab}`.{party}, `{parent_tab}`.{party}_name, `{parent_tab}`.name, `{parent_tab}`.{date_field},
{project_field}, `{child_tab}`.item_code, `{child_tab}`.base_amount, `{parent_tab}`.{party}, `{parent_tab}`.{party}_name,
`{child_tab}`.item_code,
`{child_tab}`.base_amount,
(`{child_tab}`.billed_amt * ifnull(`{parent_tab}`.conversion_rate, 1)), (`{child_tab}`.billed_amt * ifnull(`{parent_tab}`.conversion_rate, 1)),
(`{child_tab}`.base_amount - (`{child_tab}`.billed_amt * ifnull(`{parent_tab}`.conversion_rate, 1))), (`{child_tab}`.base_rate * ifnull(`{child_tab}`.returned_qty, 0)),
`{child_tab}`.item_name, `{child_tab}`.description, `{parent_tab}`.company (`{child_tab}`.base_amount -
(`{child_tab}`.billed_amt * ifnull(`{parent_tab}`.conversion_rate, 1)) -
(`{child_tab}`.base_rate * ifnull(`{child_tab}`.returned_qty, 0))),
`{child_tab}`.item_name, `{child_tab}`.description,
{project_field}, `{parent_tab}`.company
from from
`{parent_tab}`, `{child_tab}` `{parent_tab}`, `{child_tab}`
where where
`{parent_tab}`.name = `{child_tab}`.parent and `{parent_tab}`.docstatus = 1 `{parent_tab}`.name = `{child_tab}`.parent and `{parent_tab}`.docstatus = 1
and `{parent_tab}`.status not in ('Closed', 'Completed') and `{parent_tab}`.status not in ('Closed', 'Completed')
and `{child_tab}`.amount > 0 and round(`{child_tab}`.billed_amt * and `{child_tab}`.amount > 0
ifnull(`{parent_tab}`.conversion_rate, 1), {precision}) < `{child_tab}`.base_amount and (`{child_tab}`.base_amount -
round(`{child_tab}`.billed_amt * ifnull(`{parent_tab}`.conversion_rate, 1), {precision}) -
(`{child_tab}`.base_rate * ifnull(`{child_tab}`.returned_qty, 0))) > 0
order by order by
`{parent_tab}`.{order} {order_by} `{parent_tab}`.{order} {order_by}
""".format(parent_tab = 'tab' + doctype, child_tab = 'tab' + child_tab, precision= precision, party = party, """.format(parent_tab = 'tab' + doctype, child_tab = 'tab' + child_tab, precision= precision, party = party,

View File

@ -14,11 +14,19 @@ def execute(filters=None):
def get_column(): def get_column():
return [ return [
_("Purchase Receipt") + ":Link/Purchase Receipt:120", _("Status") + "::120", _("Date") + ":Date:100", _("Purchase Receipt") + ":Link/Purchase Receipt:160",
_("Supplier") + ":Link/Supplier:120", _("Supplier Name") + "::120", _("Date") + ":Date:100",
_("Project") + ":Link/Project:120", _("Item Code") + ":Link/Item:120", _("Supplier") + ":Link/Supplier:120",
_("Amount") + ":Currency:100", _("Billed Amount") + ":Currency:100", _("Amount to Bill") + ":Currency:100", _("Supplier Name") + "::120",
_("Item Name") + "::120", _("Description") + "::120", _("Company") + ":Link/Company:120", _("Item Code") + ":Link/Item:120",
_("Amount") + ":Currency:100",
_("Billed Amount") + ":Currency:100",
_("Returned Amount") + ":Currency:120",
_("Pending Amount") + ":Currency:120",
_("Item Name") + "::120",
_("Description") + "::120",
_("Project") + ":Link/Project:120",
_("Company") + ":Link/Company:120",
] ]
def get_args(): def get_args():

View File

@ -851,6 +851,7 @@
"fieldname": "returned_qty", "fieldname": "returned_qty",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Returned Qty in Stock UOM", "label": "Returned Qty in Stock UOM",
"no_copy": 1,
"print_hide": 1, "print_hide": 1,
"read_only": 1 "read_only": 1
} }
@ -858,7 +859,7 @@
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2020-07-30 21:02:17.912628", "modified": "2020-09-09 13:39:46.452817",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Purchase Receipt Item", "name": "Purchase Receipt Item",