[Sales Return] Minor fix in patch

This commit is contained in:
Rohit Waghchaure 2016-08-26 12:06:27 +05:30
parent fbe1563101
commit e21e1ebae2
2 changed files with 11 additions and 4 deletions

View File

@ -223,8 +223,15 @@ class SalesInvoice(SellingController):
self.set_paid_amount()
def set_paid_amount(self):
paid_amount = 0.0
base_paid_amount = 0.0
for data in self.payments:
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):
for data in self.timesheets:

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cint
from frappe.utils import cint, flt
def execute():
frappe.reload_doctype("Sales Invoice")
@ -12,13 +12,13 @@ def execute():
filters={"docstatus": 1, "is_pos": 1, "is_return": 1}):
si_doc = frappe.get_doc("Sales Invoice", si.name)
if len(si_doc.payments) > 0:
delete_gle_for_voucher(si_doc.name)
si_doc.set_paid_amount()
si_doc.flags.ignore_validate_update_after_submit = True
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):
frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
{'voucher_no': voucher_no})