Ejemplo n.º 1
0
	def test_accounts_receivable(self):
		frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company 2'")
		frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 2'")

		filters = {
			'company': '_Test Company 2',
			'based_on_payment_terms': 1
		}

		name = make_sales_invoice()
		report = execute(filters)

		expected_data = [[100,30], [100,50], [100,20]]

		self.assertEqual(expected_data[0], report[1][0][7:9])
		self.assertEqual(expected_data[1], report[1][1][7:9])
		self.assertEqual(expected_data[2], report[1][2][7:9])

		make_payment(name)
		report = execute(filters)

		expected_data_after_payment = [[100,50], [100,20]]

		self.assertEqual(expected_data_after_payment[0], report[1][0][7:9])
		self.assertEqual(expected_data_after_payment[1], report[1][1][7:9])

		make_credit_note(name)
		report = execute(filters)

		expected_data_after_credit_note = [[100,100,30,100,-30]]

		self.assertEqual(expected_data_after_credit_note[0], report[1][0][7:12])
    def test_accounts_receivable(self):
        frappe.db.sql(
            "delete from `tabSales Invoice` where company='_Test Company 2'")
        frappe.db.sql(
            "delete from `tabGL Entry` where company='_Test Company 2'")

        filters = {'company': '_Test Company 2', 'based_on_payment_terms': 1}

        name = make_sales_invoice()
        report = execute(filters)

        expected_data = [{
            'invoice_grand_total': 100,
            'invoiced_amount': 30
        }, {
            'invoice_grand_total': 100,
            'invoiced_amount': 50
        }, {
            'invoice_grand_total': 100,
            'invoiced_amount': 20
        }]

        for i, row in enumerate(expected_data):
            for col, value in iteritems(row):
                self.assertEqual(value, report[1][i][col])

        make_payment(name)
        report = execute(filters)

        expected_data_after_payment = [{
            'invoice_grand_total': 100,
            'invoiced_amount': 50
        }, {
            'invoice_grand_total': 100,
            'invoiced_amount': 20
        }]

        for i, row in enumerate(expected_data_after_payment):
            for col, value in iteritems(row):
                self.assertEqual(value, report[1][i][col])

        make_credit_note(name)
        report = execute(filters)

        expected_data_after_credit_note = [{
            'invoice_grand_total': 100,
            'invoiced_amount': 100,
            'paid_amount': 30,
            'return_amount': 100,
            'outstanding_amount': -30
        }]

        for i, row in enumerate(expected_data_after_credit_note):
            for col, value in iteritems(row):
                self.assertEqual(value, report[1][i][col])
Ejemplo n.º 3
0
    def test_accounts_receivable(self):
        frappe.db.sql(
            "delete from `tabSales Invoice` where company='_Test Company 2'")
        frappe.db.sql(
            "delete from `tabGL Entry` where company='_Test Company 2'")

        filters = {
            'company': '_Test Company 2',
            'based_on_payment_terms': 1,
            'report_date': today(),
            'range1': 30,
            'range2': 60,
            'range3': 90,
            'range4': 120
        }

        # check invoice grand total and invoiced column's value for 3 payment terms
        name = make_sales_invoice()
        report = execute(filters)

        expected_data = [[100, 30], [100, 50], [100, 20]]

        for i in range(3):
            row = report[1][i - 1]
            self.assertEqual(expected_data[i - 1],
                             [row.invoice_grand_total, row.invoiced])

        # check invoice grand total, invoiced, paid and outstanding column's value after payment
        make_payment(name)
        report = execute(filters)

        expected_data_after_payment = [[100, 50, 10, 40], [100, 20, 0, 20]]

        for i in range(2):
            row = report[1][i - 1]
            self.assertEqual(expected_data_after_payment[i - 1], [
                row.invoice_grand_total, row.invoiced, row.paid,
                row.outstanding
            ])

        # check invoice grand total, invoiced, paid and outstanding column's value after credit note
        make_credit_note(name)
        report = execute(filters)

        expected_data_after_credit_note = [100, 0, 0, 40, -40]

        row = report[1][0]
        self.assertEqual(expected_data_after_credit_note, [
            row.invoice_grand_total, row.invoiced, row.paid, row.credit_note,
            row.outstanding
        ])