fix: Unlink Depreciation Entry made on sale if the Asset is returned

(cherry picked from commit f51bd44929)
This commit is contained in:
GangaManoj
2021-10-06 01:18:05 +05:30
committed by mergify-bot
parent d189ea8d37
commit 4735162bdc

View File

@@ -1051,10 +1051,15 @@ class SalesInvoice(SellingController):
if schedule.schedule_date == posting_date_of_original_invoice:
if not self.sale_was_made_on_original_schedule_date(asset, schedule, row, posting_date_of_original_invoice) \
or self.sale_happens_in_the_future(posting_date_of_original_invoice):
reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
reverse_journal_entry.posting_date = nowdate()
reverse_journal_entry.submit()
asset.flags.ignore_validate_update_after_submit = True
schedule.journal_entry = None
asset.save()
def get_posting_date_of_sales_invoice(self):
return frappe.db.get_value('Sales Invoice', self.return_against, 'posting_date')