[Sales Return] Minor fix in patch
This commit is contained in:
parent
fbe1563101
commit
e21e1ebae2
@ -223,8 +223,15 @@ class SalesInvoice(SellingController):
|
|||||||
self.set_paid_amount()
|
self.set_paid_amount()
|
||||||
|
|
||||||
def set_paid_amount(self):
|
def set_paid_amount(self):
|
||||||
|
paid_amount = 0.0
|
||||||
|
base_paid_amount = 0.0
|
||||||
for data in self.payments:
|
for data in self.payments:
|
||||||
data.base_amount = flt(data.amount*self.conversion_rate, self.precision("base_paid_amount"))
|
data.base_amount = flt(data.amount*self.conversion_rate, self.precision("base_paid_amount"))
|
||||||
|
paid_amount += data.amount
|
||||||
|
base_paid_amount += data.base_amount
|
||||||
|
|
||||||
|
self.paid_amount = paid_amount
|
||||||
|
self.base_paid_amount = base_paid_amount
|
||||||
|
|
||||||
def validate_time_sheets_are_submitted(self):
|
def validate_time_sheets_are_submitted(self):
|
||||||
for data in self.timesheets:
|
for data in self.timesheets:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint, flt
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doctype("Sales Invoice")
|
frappe.reload_doctype("Sales Invoice")
|
||||||
@ -12,13 +12,13 @@ def execute():
|
|||||||
filters={"docstatus": 1, "is_pos": 1, "is_return": 1}):
|
filters={"docstatus": 1, "is_pos": 1, "is_return": 1}):
|
||||||
si_doc = frappe.get_doc("Sales Invoice", si.name)
|
si_doc = frappe.get_doc("Sales Invoice", si.name)
|
||||||
if len(si_doc.payments) > 0:
|
if len(si_doc.payments) > 0:
|
||||||
delete_gle_for_voucher(si_doc.name)
|
|
||||||
si_doc.set_paid_amount()
|
si_doc.set_paid_amount()
|
||||||
si_doc.flags.ignore_validate_update_after_submit = True
|
si_doc.flags.ignore_validate_update_after_submit = True
|
||||||
si_doc.save()
|
si_doc.save()
|
||||||
si_doc.run_method("make_gl_entries")
|
if si_doc.grand_total <= si_doc.paid_amount and si_doc.paid_amount < 0:
|
||||||
|
delete_gle_for_voucher(si_doc.name)
|
||||||
|
si_doc.run_method("make_gl_entries")
|
||||||
|
|
||||||
def delete_gle_for_voucher(voucher_no):
|
def delete_gle_for_voucher(voucher_no):
|
||||||
frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
|
frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
|
||||||
{'voucher_no': voucher_no})
|
{'voucher_no': voucher_no})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user