[minor] patch for billed in DN and PR
This commit is contained in:
parent
4e0908d055
commit
ed72a28e41
@ -1,4 +1,5 @@
|
|||||||
- Track billed status of a Delivery Note (DN) or Purchase Receipt (PR)
|
- Track billed status of a Delivery Note (DN) or Purchase Receipt (PR)
|
||||||
|
- Added new status **To Bill** and **Completed** in Delivery Note and Purchase Receipt
|
||||||
- The system looks for Invoices directly created from Delivery Note / Purchase Receipt *(Workflow: Order -> DN/PR -> Invoice)* and allocates these amounts directly to the DN/PR
|
- The system looks for Invoices directly created from Delivery Note / Purchase Receipt *(Workflow: Order -> DN/PR -> Invoice)* and allocates these amounts directly to the DN/PR
|
||||||
- Next, it looks for Invoices not created from Delivery Note / Purchase Receipt, but from an Order *(Workflow: Order -> Invoice, Order -> DN/PR)* and the DN/PR is selected based on FIFO for allocating the billed amount
|
- Next, it looks for Invoices not created from Delivery Note / Purchase Receipt, but from an Order *(Workflow: Order -> Invoice, Order -> DN/PR)* and the DN/PR is selected based on FIFO for allocating the billed amount
|
||||||
- In Stock Entry, re-calculate Additional Costs and Amount on changing Quantity or Rate
|
- In Stock Entry, re-calculate Additional Costs and Amount on changing Quantity or Rate
|
||||||
|
@ -10,24 +10,33 @@ def execute():
|
|||||||
frappe.reload_doctype(dt + " Item")
|
frappe.reload_doctype(dt + " Item")
|
||||||
|
|
||||||
# Update billed_amt in DN and PR which are not against any order
|
# Update billed_amt in DN and PR which are not against any order
|
||||||
for d in frappe.db.sql("""select name from `tabDelivery Note Item`
|
for d in frappe.db.sql("""select name from `tabDelivery Note Item` item
|
||||||
where (so_detail is null or so_detail = '') and docstatus=1""", as_dict=1):
|
where (so_detail is null or so_detail = '') and docstatus=1""", as_dict=1):
|
||||||
billed_amt = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
|
|
||||||
where dn_detail=%s and docstatus=1""", d.name)
|
billed_amt = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
|
||||||
billed_amt = billed_amt and billed_amt[0][0] or 0
|
where dn_detail=%s and docstatus=1""", d.name)
|
||||||
frappe.db.set_value("Delivery Note Item", d.name, "billed_amt", billed_amt, update_modified=False)
|
billed_amt = billed_amt and billed_amt[0][0] or 0
|
||||||
|
frappe.db.set_value("Delivery Note Item", d.name, "billed_amt", billed_amt, update_modified=False)
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
# Update billed_amt in DN and PR which are not against any order
|
# Update billed_amt in DN and PR which are not against any order
|
||||||
for d in frappe.db.sql("""select name from `tabPurchase Receipt Item`
|
for d in frappe.db.sql("""select name from `tabPurchase Receipt Item` item
|
||||||
where (prevdoc_detail_docname is null or prevdoc_detail_docname = '') and docstatus=1""", as_dict=1):
|
where (prevdoc_detail_docname is null or prevdoc_detail_docname = '') and docstatus=1""", as_dict=1):
|
||||||
billed_amt = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
|
||||||
where pr_detail=%s and docstatus=1""", d.name)
|
|
||||||
billed_amt = billed_amt and billed_amt[0][0] or 0
|
|
||||||
frappe.db.set_value("Purchase Receipt Item", d.name, "billed_amt", billed_amt, update_modified=False)
|
|
||||||
|
|
||||||
# Update billed amt which are against order or invoice
|
billed_amt = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
||||||
# Update billing status for all
|
where pr_detail=%s and docstatus=1""", d.name)
|
||||||
for d in frappe.db.sql("select name from `tab{0}` where docstatus=1".format(dt), as_dict=1):
|
billed_amt = billed_amt and billed_amt[0][0] or 0
|
||||||
doc = frappe.get_doc(dt, d.name)
|
frappe.db.set_value("Purchase Receipt Item", d.name, "billed_amt", billed_amt, update_modified=False)
|
||||||
doc.update_billing_status(update_modified=False)
|
|
||||||
doc.set_status(update=True, update_modified=False)
|
frappe.db.commit()
|
||||||
|
|
||||||
|
for dt in ("Delivery Note", "Purchase Receipt"):
|
||||||
|
# Update billed amt which are against order or invoice
|
||||||
|
# Update billing status for all
|
||||||
|
for d in frappe.db.sql("select name from `tab{0}` where docstatus=1".format(dt), as_dict=1):
|
||||||
|
doc = frappe.get_doc(dt, d.name)
|
||||||
|
doc.update_billing_status(update_modified=False)
|
||||||
|
doc.set_status(update=True, update_modified=False)
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
|
@ -47,7 +47,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
|||||||
this.show_general_ledger();
|
this.show_general_ledger();
|
||||||
}
|
}
|
||||||
if (this.frm.has_perm("submit") && (doc.status !== "Closed")
|
if (this.frm.has_perm("submit") && (doc.status !== "Closed")
|
||||||
&& this.frm.doc.__onload && this.frm.doc.__onload.has_return_entry) {
|
&& this.frm.doc.__onload && !this.frm.doc.__onload.has_return_entry) {
|
||||||
cur_frm.add_custom_button(__("Close"), this.close_delivery_note)
|
cur_frm.add_custom_button(__("Close"), this.close_delivery_note)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
this.make_purchase_invoice).addClass("btn-primary");
|
this.make_purchase_invoice).addClass("btn-primary");
|
||||||
}
|
}
|
||||||
if (this.frm.has_perm("submit") &&
|
if (this.frm.has_perm("submit") &&
|
||||||
this.frm.doc.__onload && this.frm.doc.__onload.has_return_entry) {
|
this.frm.doc.__onload && !this.frm.doc.__onload.has_return_entry) {
|
||||||
cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt)
|
cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user