Landed cost voucher fixes
This commit is contained in:
parent
9cbcf96aeb
commit
f3e1181ad9
@ -82,16 +82,25 @@ class LandedCostVoucher(Document):
|
|||||||
|
|
||||||
def update_landed_cost(self):
|
def update_landed_cost(self):
|
||||||
purchase_receipts = list(set([d.purchase_receipt for d in self.get("landed_cost_items")]))
|
purchase_receipts = list(set([d.purchase_receipt for d in self.get("landed_cost_items")]))
|
||||||
self.delete_sle_and_gle(purchase_receipts)
|
|
||||||
for purchase_receipt in purchase_receipts:
|
for purchase_receipt in purchase_receipts:
|
||||||
pr = frappe.get_doc("Purchase Receipt", purchase_receipt)
|
pr = frappe.get_doc("Purchase Receipt", purchase_receipt)
|
||||||
|
|
||||||
|
# set landed cost voucher amount in pr item
|
||||||
pr.set_landed_cost_voucher_amount()
|
pr.set_landed_cost_voucher_amount()
|
||||||
|
|
||||||
|
# set valuation amount in pr item
|
||||||
pr.update_valuation_rate("purchase_receipt_details")
|
pr.update_valuation_rate("purchase_receipt_details")
|
||||||
|
|
||||||
|
# save will update landed_cost_voucher_amount and voucher_amount in PR,
|
||||||
|
# as those fields are ellowed to edit after submit
|
||||||
pr.save()
|
pr.save()
|
||||||
|
|
||||||
|
# update stock & gl entries for cancelled state of PR
|
||||||
|
pr.docstatus = 2
|
||||||
|
pr.update_stock()
|
||||||
|
pr.make_gl_entries_on_cancel()
|
||||||
|
|
||||||
|
# update stock & gl entries for submit state of PR
|
||||||
|
pr.docstatus = 1
|
||||||
pr.update_stock()
|
pr.update_stock()
|
||||||
pr.make_gl_entries()
|
pr.make_gl_entries()
|
||||||
|
|
||||||
def delete_sle_and_gle(self, purchase_receipts):
|
|
||||||
for doctype in ["Stock Ledger Entry", "GL Entry"]:
|
|
||||||
frappe.db.sql("""delete from `tab%s` where voucher_type='Purchase Receipt'
|
|
||||||
and voucher_no in (%s)""" % (doctype, ', '.join(['%s']*len(purchase_receipts))), purchase_receipts)
|
|
Loading…
x
Reference in New Issue
Block a user