Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate discount date in payment schedule (backport #44646) #44726

Open
wants to merge 1 commit into
base: version-14-hotfix
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 17, 2024

Early payment discount only makes sense if the discount date is earlier than the due date.

Bildschirmfoto 2024-12-10 um 17 24 35


This is an automatic backport of pull request #44646 done by [Mergify](https://mergify.com).

@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Dec 17, 2024
@ruthra-kumar
Copy link
Member


erpnext.accounts.doctype.coupon_code.test_coupon_code.TestCouponCode
   ✔  test_sales_order_with_coupon_code
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/runner/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/runner/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/runner/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/runner/frappe-bench/apps/frappe/frappe/commands/utils.py", line 857, in run_parallel_tests
    ParallelTestRunner(
  File "/home/runner/frappe-bench/apps/frappe/frappe/parallel_test_runner.py", line 28, in __init__
    self.run_tests()
  File "/home/runner/frappe-bench/apps/frappe/frappe/parallel_test_runner.py", line 62, in run_tests
    self.run_tests_for_file(test_file_info)
  File "/home/runner/frappe-bench/apps/frappe/frappe/parallel_test_runner.py", line 77, in run_tests_for_file
    self.create_test_dependency_records(module, path, filename)
  File "/home/runner/frappe-bench/apps/frappe/frappe/parallel_test_runner.py", line 96, in create_test_dependency_records
    make_test_records(doctype, commit=True)
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 360, in make_test_records
    make_test_records(options, verbose, force, commit=commit)
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 360, in make_test_records
    make_test_records(options, verbose, force, commit=commit)
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 360, in make_test_records
    make_test_records(options, verbose, force, commit=commit)
  [Previous line repeated 8 more times]
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 361, in make_test_records
    make_test_records_for_doctype(options, verbose, force, commit=commit)
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 415, in make_test_records_for_doctype
    frappe.local.test_objects[doctype] += make_test_objects(
  File "/home/runner/frappe-bench/apps/frappe/frappe/test_runner.py", line 474, in make_test_objects
    d.insert(ignore_if_duplicate=True)
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 265, in insert
    self.run_before_save_methods()
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 1061, in run_before_save_methods
    self.run_method("validate")
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 931, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 1283, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 1265, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 928, in fn
    return method_object(*args, **kwargs)
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/buying/doctype/purchase_order/purchase_order.py", line 57, in validate
    super().validate()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/buying_controller.py", line 37, in validate
    super().validate()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 52, in validate
    super().validate()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py", line 44, in validate
    super().validate()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 190, in validate
    self.validate_all_documents_schedule()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 440, in validate_all_documents_schedule
    self.validate_non_invoice_documents_schedule()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 433, in validate_non_invoice_documents_schedule
    self.validate_payment_schedule_dates()
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 2184, in validate_payment_schedule_dates
    d.validate_from_to_dates("discount_date", "due_date")
  File "/home/runner/frappe-bench/apps/frappe/frappe/model/document.py", line 1544, in validate_from_to_dates
    frappe.throw(
  File "/home/runner/frappe-bench/apps/frappe/frappe/__init__.py", line 548, in throw
    msgprint(
  File "/home/runner/frappe-bench/apps/frappe/frappe/__init__.py", line 509, in msgprint
    _raise_exception()
  File "/home/runner/frappe-bench/apps/frappe/frappe/__init__.py", line 455, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.InvalidDates: <strong>Due Date</strong> must be after <strong>Discount Date</strong>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accounts needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants