fix: Handle frozen books while handling
This commit is contained in:
parent
2aea078699
commit
30a647ff80
@ -254,6 +254,8 @@ def book_deferred_income_or_expense(doc, deferred_process, posting_date=None):
|
|||||||
enable_check = "enable_deferred_revenue" \
|
enable_check = "enable_deferred_revenue" \
|
||||||
if doc.doctype=="Sales Invoice" else "enable_deferred_expense"
|
if doc.doctype=="Sales Invoice" else "enable_deferred_expense"
|
||||||
|
|
||||||
|
accounts_frozen_upto = frappe.get_cached_value('Accounts Settings', 'None', 'acc_frozen_upto')
|
||||||
|
|
||||||
def _book_deferred_revenue_or_expense(item, via_journal_entry, submit_journal_entry, book_deferred_entries_based_on):
|
def _book_deferred_revenue_or_expense(item, via_journal_entry, submit_journal_entry, book_deferred_entries_based_on):
|
||||||
start_date, end_date, last_gl_entry = get_booking_dates(doc, item, posting_date=posting_date)
|
start_date, end_date, last_gl_entry = get_booking_dates(doc, item, posting_date=posting_date)
|
||||||
if not (start_date and end_date): return
|
if not (start_date and end_date): return
|
||||||
@ -279,6 +281,10 @@ def book_deferred_income_or_expense(doc, deferred_process, posting_date=None):
|
|||||||
if not amount:
|
if not amount:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# check if books nor frozen till endate:
|
||||||
|
if getdate(end_date) >= getdate(accounts_frozen_upto):
|
||||||
|
end_date = get_last_day(add_days(accounts_frozen_upto, 1))
|
||||||
|
|
||||||
if via_journal_entry:
|
if via_journal_entry:
|
||||||
book_revenue_via_journal_entry(doc, credit_account, debit_account, against, amount,
|
book_revenue_via_journal_entry(doc, credit_account, debit_account, against, amount,
|
||||||
base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process, submit_journal_entry)
|
base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process, submit_journal_entry)
|
||||||
|
|||||||
@ -2509,6 +2509,9 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.save()
|
si.save()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
|
acc_settings.acc_frozen_upto = '2019-01-31'
|
||||||
|
acc_settings.save()
|
||||||
|
|
||||||
pda1 = frappe.get_doc(dict(
|
pda1 = frappe.get_doc(dict(
|
||||||
doctype='Process Deferred Accounting',
|
doctype='Process Deferred Accounting',
|
||||||
posting_date=nowdate(),
|
posting_date=nowdate(),
|
||||||
@ -2522,8 +2525,8 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
pda1.submit()
|
pda1.submit()
|
||||||
|
|
||||||
expected_gle = [
|
expected_gle = [
|
||||||
["Sales - _TC", 0.0, 2089.89, "2019-01-31"],
|
["Sales - _TC", 0.0, 2089.89, "2019-01-28"],
|
||||||
[deferred_account, 2089.89, 0.0, "2019-01-31"],
|
[deferred_account, 2089.89, 0.0, "2019-01-28"],
|
||||||
["Sales - _TC", 0.0, 1887.64, "2019-02-28"],
|
["Sales - _TC", 0.0, 1887.64, "2019-02-28"],
|
||||||
[deferred_account, 1887.64, 0.0, "2019-02-28"],
|
[deferred_account, 1887.64, 0.0, "2019-02-28"],
|
||||||
["Sales - _TC", 0.0, 2022.47, "2019-03-15"],
|
["Sales - _TC", 0.0, 2022.47, "2019-03-15"],
|
||||||
@ -2544,6 +2547,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
acc_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
|
acc_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
|
||||||
acc_settings.book_deferred_entries_via_journal_entry = 0
|
acc_settings.book_deferred_entries_via_journal_entry = 0
|
||||||
acc_settings.submit_journal_entriessubmit_journal_entries = 0
|
acc_settings.submit_journal_entriessubmit_journal_entries = 0
|
||||||
|
acc_settings.acc_frozen_upto = None
|
||||||
acc_settings.save()
|
acc_settings.save()
|
||||||
|
|
||||||
def get_sales_invoice_for_e_invoice():
|
def get_sales_invoice_for_e_invoice():
|
||||||
|
|||||||
@ -185,8 +185,6 @@ class AccountsController(TransactionBase):
|
|||||||
frappe.throw(_("Row #{0}: Service Start Date cannot be greater than Service End Date").format(d.idx))
|
frappe.throw(_("Row #{0}: Service Start Date cannot be greater than Service End Date").format(d.idx))
|
||||||
elif getdate(self.posting_date) > getdate(d.service_end_date):
|
elif getdate(self.posting_date) > getdate(d.service_end_date):
|
||||||
frappe.throw(_("Row #{0}: Service End Date cannot be before Invoice Posting Date").format(d.idx))
|
frappe.throw(_("Row #{0}: Service End Date cannot be before Invoice Posting Date").format(d.idx))
|
||||||
elif getdate(self.posting_date) > getdate(d.service_start_date):
|
|
||||||
frappe.throw(_("Row #{0}: Service Start Date cannot be before Invoice Posting Date").format(d.idx))
|
|
||||||
|
|
||||||
def validate_invoice_documents_schedule(self):
|
def validate_invoice_documents_schedule(self):
|
||||||
self.validate_payment_schedule_dates()
|
self.validate_payment_schedule_dates()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user