test: get_outstanding_reference_documents
(triggered via UI)
This commit is contained in:
parent
6bd56d2d5f
commit
162c0497d1
@ -6,10 +6,11 @@ import unittest
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||||
from frappe.utils import flt, nowdate
|
from frappe.utils import add_days, flt, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.payment_entry.payment_entry import (
|
from erpnext.accounts.doctype.payment_entry.payment_entry import (
|
||||||
InvalidPaymentEntry,
|
InvalidPaymentEntry,
|
||||||
|
get_outstanding_reference_documents,
|
||||||
get_payment_entry,
|
get_payment_entry,
|
||||||
get_reference_details,
|
get_reference_details,
|
||||||
)
|
)
|
||||||
@ -1262,6 +1263,42 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
so.reload()
|
so.reload()
|
||||||
self.assertEqual(so.advance_paid, so.rounded_total)
|
self.assertEqual(so.advance_paid, so.rounded_total)
|
||||||
|
|
||||||
|
def test_outstanding_invoices_api(self):
|
||||||
|
"""
|
||||||
|
Test if `get_outstanding_reference_documents` fetches invoices in the right order.
|
||||||
|
"""
|
||||||
|
customer = create_customer("Max Mustermann", "INR")
|
||||||
|
create_payment_terms_template()
|
||||||
|
|
||||||
|
si = create_sales_invoice(qty=1, rate=100, customer=customer)
|
||||||
|
si2 = create_sales_invoice(do_not_save=1, qty=1, rate=100, customer=customer)
|
||||||
|
si2.payment_terms_template = "Test Receivable Template"
|
||||||
|
si2.submit()
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"posting_date": nowdate(),
|
||||||
|
"company": "_Test Company",
|
||||||
|
"party_type": "Customer",
|
||||||
|
"payment_type": "Pay",
|
||||||
|
"party": customer,
|
||||||
|
"party_account": "Debtors - _TC",
|
||||||
|
}
|
||||||
|
args.update(
|
||||||
|
{
|
||||||
|
"get_outstanding_invoices": True,
|
||||||
|
"from_posting_date": nowdate(),
|
||||||
|
"to_posting_date": add_days(nowdate(), 7),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
references = get_outstanding_reference_documents(args)
|
||||||
|
|
||||||
|
self.assertEqual(len(references), 3)
|
||||||
|
self.assertEqual(references[0].voucher_no, si.name)
|
||||||
|
self.assertEqual(references[1].voucher_no, si2.name)
|
||||||
|
self.assertEqual(references[2].voucher_no, si2.name)
|
||||||
|
self.assertEqual(references[1].payment_term, "Basic Amount Receivable")
|
||||||
|
self.assertEqual(references[2].payment_term, "Tax Receivable")
|
||||||
|
|
||||||
|
|
||||||
def create_payment_entry(**args):
|
def create_payment_entry(**args):
|
||||||
payment_entry = frappe.new_doc("Payment Entry")
|
payment_entry = frappe.new_doc("Payment Entry")
|
||||||
@ -1322,6 +1359,9 @@ def create_payment_terms_template():
|
|||||||
def create_payment_terms_template_with_discount(
|
def create_payment_terms_template_with_discount(
|
||||||
name=None, discount_type=None, discount=None, template_name=None
|
name=None, discount_type=None, discount=None, template_name=None
|
||||||
):
|
):
|
||||||
|
"""
|
||||||
|
Create a Payment Terms Template with % or amount discount.
|
||||||
|
"""
|
||||||
create_payment_term(name or "30 Credit Days with 10% Discount")
|
create_payment_term(name or "30 Credit Days with 10% Discount")
|
||||||
template_name = template_name or "Test Discount Template"
|
template_name = template_name or "Test Discount Template"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user