コード例 #1
0
    def test_payment_against_negative_sales_invoice(self):
        pe1 = frappe.new_doc("Payment Entry")
        pe1.payment_type = "Pay"
        pe1.company = "_Test Company"
        pe1.party_type = "Customer"
        pe1.party = "_Test Customer"
        pe1.paid_from = "_Test Cash - _TC"
        pe1.paid_amount = 100
        pe1.received_amount = 100

        self.assertRaises(InvalidPaymentEntry, pe1.validate)

        si1 = create_sales_invoice()

        # create full payment entry against si1
        pe2 = get_payment_entry("Sales Invoice",
                                si1.name,
                                bank_account="_Test Cash - _TC")
        pe2.insert()
        pe2.submit()

        # create return entry against si1
        create_sales_invoice(is_return=1, return_against=si1.name, qty=-1)
        si1_outstanding = frappe.db.get_value("Sales Invoice", si1.name,
                                              "outstanding_amount")
        self.assertEqual(si1_outstanding, -100)

        # pay more than outstanding against si1
        pe3 = get_payment_entry("Sales Invoice",
                                si1.name,
                                bank_account="_Test Cash - _TC")
        pe3.paid_amount = pe3.received_amount = 300
        self.assertRaises(InvalidPaymentEntry, pe3.validate)

        # pay negative outstanding against si1
        pe3.paid_to = "Debtors - _TC"
        pe3.paid_amount = pe3.received_amount = 100

        pe3.insert()
        pe3.submit()

        expected_gle = dict((d[0], d)
                            for d in [["Debtors - _TC", 100, 0, si1.name],
                                      ["_Test Cash - _TC", 0, 100, None]])

        self.validate_gl_entries(pe3.name, expected_gle)

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si1.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 0)

        pe3.cancel()

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si1.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, -100)
コード例 #2
0
    def test_payment_entry_against_si_usd_to_usd(self):
        si = create_sales_invoice(customer="_Test Customer USD",
                                  debit_to="_Test Receivable USD - _TC",
                                  currency="USD",
                                  conversion_rate=50)
        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Bank USD - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.target_exchange_rate = 50
        pe.insert()
        pe.submit()

        expected_gle = dict(
            (d[0], d)
            for d in [["_Test Receivable USD - _TC", 0, 5000, si.name],
                      ["_Test Bank USD - _TC", 5000.0, 0, None]])

        self.validate_gl_entries(pe.name, expected_gle)

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 0)

        pe.cancel()

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 100)
コード例 #3
0
    def test_payment_entry_write_off_difference(self):
        si = create_sales_invoice()
        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Cash - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.received_amount = pe.paid_amount = 110
        pe.insert()

        self.assertEqual(pe.unallocated_amount, 10)

        pe.received_amount = pe.paid_amount = 95
        pe.append(
            "deductions", {
                "account": "_Test Write Off - _TC",
                "cost_center": "_Test Cost Center - _TC",
                "amount": 5
            })
        pe.save()

        self.assertEqual(pe.unallocated_amount, 0)
        self.assertEqual(pe.difference_amount, 0)

        pe.submit()

        expected_gle = dict((d[0], d)
                            for d in [["Debtors - _TC", 0, 100, si.name],
                                      ["_Test Cash - _TC", 95, 0, None],
                                      ["_Test Write Off - _TC", 5, 0, None]])

        self.validate_gl_entries(pe.name, expected_gle)
コード例 #4
0
ファイル: accounts.py プロジェクト: mohrezbak/erpbee
def make_payment_entries(ref_doctype, report):

    outstanding_invoices = frappe.get_all(ref_doctype,
                                          fields=["name"],
                                          filters={
                                              "company":
                                              erpbee.get_default_company(),
                                              "outstanding_amount": (">", 0.0)
                                          })

    # make Payment Entry
    for inv in outstanding_invoices[:random.randint(1, 2)]:
        pe = get_payment_entry(ref_doctype, inv.name)
        pe.posting_date = frappe.flags.current_date
        pe.reference_no = random_string(6)
        pe.reference_date = frappe.flags.current_date
        pe.insert()
        pe.submit()
        frappe.db.commit()
        outstanding_invoices.remove(inv)

    # make payment via JV
    for inv in outstanding_invoices[:1]:
        jv = frappe.get_doc(
            get_payment_entry_against_invoice(ref_doctype, inv.name))
        jv.posting_date = frappe.flags.current_date
        jv.cheque_no = random_string(6)
        jv.cheque_date = frappe.flags.current_date
        jv.insert()
        jv.submit()
        frappe.db.commit()
コード例 #5
0
    def test_payment_entry_unlink_against_purchase_invoice(self):
        from erpbee.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
        unlink_payment_on_cancel_of_invoice(0)

        pi_doc = make_purchase_invoice()

        pe = get_payment_entry("Purchase Invoice",
                               pi_doc.name,
                               bank_account="_Test Bank - _TC")
        pe.reference_no = "1"
        pe.reference_date = nowdate()
        pe.paid_from_account_currency = pi_doc.currency
        pe.paid_to_account_currency = pi_doc.currency
        pe.source_exchange_rate = 1
        pe.target_exchange_rate = 1
        pe.paid_amount = pi_doc.grand_total
        pe.save(ignore_permissions=True)
        pe.submit()

        pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
        pi_doc.load_from_db()
        self.assertTrue(pi_doc.status, "Paid")

        self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
        unlink_payment_on_cancel_of_invoice()
コード例 #6
0
    def test_payment_against_sales_invoice_to_check_status(self):
        si = create_sales_invoice(customer="_Test Customer USD",
                                  debit_to="_Test Receivable USD - _TC",
                                  currency="USD",
                                  conversion_rate=50)

        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Bank USD - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.target_exchange_rate = 50
        pe.insert()
        pe.submit()

        outstanding_amount, status = frappe.db.get_value(
            "Sales Invoice", si.name, ["outstanding_amount", "status"])
        self.assertEqual(flt(outstanding_amount), 0)
        self.assertEqual(status, 'Paid')

        pe.cancel()

        outstanding_amount, status = frappe.db.get_value(
            "Sales Invoice", si.name, ["outstanding_amount", "status"])
        self.assertEqual(flt(outstanding_amount), 100)
        self.assertEqual(status, 'Unpaid')
コード例 #7
0
    def test_payment_entry_against_ec(self):

        payable = frappe.get_cached_value('Company', "_Test Company",
                                          'default_payable_account')
        ec = make_expense_claim(payable, 300, 300, "_Test Company",
                                "Travel Expenses - _TC")
        pe = get_payment_entry("Expense Claim",
                               ec.name,
                               bank_account="_Test Bank USD - _TC",
                               bank_amount=300)
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.source_exchange_rate = 1
        pe.paid_to = payable
        pe.insert()
        pe.submit()

        expected_gle = dict((d[0], d)
                            for d in [[payable, 300, 0, ec.name],
                                      ["_Test Bank USD - _TC", 0, 300, None]])

        self.validate_gl_entries(pe.name, expected_gle)

        outstanding_amount = flt(frappe.db.get_value("Expense Claim", ec.name, "total_sanctioned_amount")) - \
         flt(frappe.db.get_value("Expense Claim", ec.name, "total_amount_reimbursed"))
        self.assertEqual(outstanding_amount, 0)
コード例 #8
0
    def test_advance_payment_entry_unlink_against_purchase_order(self):
        from erpbee.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
        frappe.db.set_value("Accounts Settings", "Accounts Settings",
                            "unlink_advance_payment_on_cancelation_of_order",
                            1)

        po_doc = create_purchase_order()

        pe = get_payment_entry("Purchase Order",
                               po_doc.name,
                               bank_account="_Test Bank - _TC")
        pe.reference_no = "1"
        pe.reference_date = nowdate()
        pe.paid_from_account_currency = po_doc.currency
        pe.paid_to_account_currency = po_doc.currency
        pe.source_exchange_rate = 1
        pe.target_exchange_rate = 1
        pe.paid_amount = po_doc.grand_total
        pe.save(ignore_permissions=True)
        pe.submit()

        po_doc = frappe.get_doc('Purchase Order', po_doc.name)
        po_doc.cancel()

        pe_doc = frappe.get_doc('Payment Entry', pe.name)
        pe_doc.cancel()

        frappe.db.set_value("Accounts Settings", "Accounts Settings",
                            "unlink_advance_payment_on_cancelation_of_order",
                            0)
コード例 #9
0
    def test_debit_note(self):
        from erpbee.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
        from erpbee.accounts.doctype.sales_invoice.test_sales_invoice import get_outstanding_amount

        pi = make_purchase_invoice(item_code="_Test Item",
                                   qty=(5 * -1),
                                   rate=500,
                                   is_return=1)
        pi.load_from_db()
        self.assertTrue(pi.status, "Return")

        outstanding_amount = get_outstanding_amount(pi.doctype, pi.name,
                                                    "Creditors - _TC",
                                                    pi.supplier, "Supplier")

        self.assertEqual(pi.outstanding_amount, outstanding_amount)

        pe = get_payment_entry("Purchase Invoice",
                               pi.name,
                               bank_account="_Test Bank - _TC")
        pe.reference_no = "1"
        pe.reference_date = nowdate()
        pe.paid_from_account_currency = pi.currency
        pe.paid_to_account_currency = pi.currency
        pe.source_exchange_rate = 1
        pe.target_exchange_rate = 1
        pe.paid_amount = pi.grand_total * -1
        pe.insert()
        pe.submit()

        pi_doc = frappe.get_doc('Purchase Invoice', pi.name)
        self.assertEqual(pi_doc.outstanding_amount, 0)
コード例 #10
0
    def test_payment_against_purchase_invoice_to_check_status(self):
        pi = make_purchase_invoice(supplier="_Test Supplier USD",
                                   debit_to="_Test Payable USD - _TC",
                                   currency="USD",
                                   conversion_rate=50)

        pe = get_payment_entry("Purchase Invoice",
                               pi.name,
                               bank_account="_Test Bank USD - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.source_exchange_rate = 50
        pe.insert()
        pe.submit()

        outstanding_amount, status = frappe.db.get_value(
            "Purchase Invoice", pi.name, ["outstanding_amount", "status"])
        self.assertEqual(flt(outstanding_amount), 0)
        self.assertEqual(status, 'Paid')

        pe.cancel()

        outstanding_amount, status = frappe.db.get_value(
            "Purchase Invoice", pi.name, ["outstanding_amount", "status"])
        self.assertEqual(flt(outstanding_amount), 250)
        self.assertEqual(status, 'Unpaid')
コード例 #11
0
    def test_payment_entry_against_payment_terms(self):
        si = create_sales_invoice(do_not_save=1, qty=1, rate=200)
        create_payment_terms_template()
        si.payment_terms_template = 'Test Receivable Template'

        si.append(
            'taxes', {
                "charge_type": "On Net Total",
                "account_head": "_Test Account Service Tax - _TC",
                "cost_center": "_Test Cost Center - _TC",
                "description": "Service Tax",
                "rate": 18
            })
        si.save()

        si.submit()

        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Cash - _TC")
        pe.submit()
        si.load_from_db()

        self.assertEqual(pe.references[0].payment_term,
                         'Basic Amount Receivable')
        self.assertEqual(pe.references[1].payment_term, 'Tax Receivable')
        self.assertEqual(si.payment_schedule[0].paid_amount, 200.0)
        self.assertEqual(si.payment_schedule[1].paid_amount, 36.0)
コード例 #12
0
ファイル: payment_request.py プロジェクト: mohrezbak/erpbee
    def create_payment_entry(self, submit=True):
        """create entry"""
        frappe.flags.ignore_account_permission = True

        ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)

        if self.reference_doctype in ["Sales Invoice", "POS Invoice"]:
            party_account = ref_doc.debit_to
        elif self.reference_doctype == "Purchase Invoice":
            party_account = ref_doc.credit_to
        else:
            party_account = get_party_account("Customer",
                                              ref_doc.get("customer"),
                                              ref_doc.company)

        party_account_currency = ref_doc.get(
            "party_account_currency") or get_account_currency(party_account)

        bank_amount = self.grand_total
        if party_account_currency == ref_doc.company_currency and party_account_currency != self.currency:
            party_amount = ref_doc.base_grand_total
        else:
            party_amount = self.grand_total

        payment_entry = get_payment_entry(self.reference_doctype,
                                          self.reference_name,
                                          party_amount=party_amount,
                                          bank_account=self.payment_account,
                                          bank_amount=bank_amount)

        payment_entry.update({
            "reference_no":
            self.name,
            "reference_date":
            nowdate(),
            "remarks":
            "Payment Entry against {0} {1} via Payment Request {2}".format(
                self.reference_doctype, self.reference_name, self.name)
        })

        if payment_entry.difference_amount:
            company_details = get_company_defaults(ref_doc.company)

            payment_entry.append(
                "deductions", {
                    "account": company_details.exchange_gain_loss_account,
                    "cost_center": company_details.cost_center,
                    "amount": payment_entry.difference_amount
                })

        if submit:
            payment_entry.insert(ignore_permissions=True)
            payment_entry.submit()

        return payment_entry
コード例 #13
0
    def test_purchase_invoice_temporary_blocked(self):
        pi = make_purchase_invoice(do_not_save=True)
        pi.release_date = add_days(nowdate(), 10)
        pi.save()
        pi.submit()

        pe = get_payment_entry('Purchase Invoice',
                               dn=pi.name,
                               bank_account="_Test Bank - _TC")

        self.assertRaises(frappe.ValidationError, pe.save)
コード例 #14
0
    def test_po_for_blocked_supplier_payments_past_date(self):
        # this test is meant to fail only if something fails in the try block
        with self.assertRaises(Exception):
            try:
                supplier = frappe.get_doc('Supplier', '_Test Supplier')
                supplier.on_hold = 1
                supplier.hold_type = 'Payments'
                supplier.release_date = '2018-03-01'
                supplier.save()

                po = create_purchase_order()
                get_payment_entry('Purchase Order',
                                  po.name,
                                  bank_account='_Test Bank - _TC')

                supplier.on_hold = 0
                supplier.save()
            except:
                pass
            else:
                raise Exception
コード例 #15
0
def make_payament_entry_against_sales_invoice(doc,
                                              shopify_settings,
                                              posting_date=None):
    from erpbee.accounts.doctype.payment_entry.payment_entry import get_payment_entry
    payment_entry = get_payment_entry(
        doc.doctype, doc.name, bank_account=shopify_settings.cash_bank_account)
    payment_entry.flags.ignore_mandatory = True
    payment_entry.reference_no = doc.name
    payment_entry.posting_date = posting_date or nowdate()
    payment_entry.reference_date = posting_date or nowdate()
    payment_entry.insert(ignore_permissions=True)
    payment_entry.submit()
コード例 #16
0
    def test_get_mode_of_payments_details(self):
        filters = get_filters()

        for dummy in range(2):
            si = create_sales_invoice_record()
            si.insert()
            si.submit()

            if int(si.name[-3:]) % 2 == 0:
                bank_account = "_Test Cash - _TC"
                mode_of_payment = "Cash"
            else:
                bank_account = "_Test Bank - _TC"
                mode_of_payment = "Credit Card"

            pe = get_payment_entry("Sales Invoice",
                                   si.name,
                                   bank_account=bank_account)
            pe.reference_no = "_Test"
            pe.reference_date = today()
            pe.mode_of_payment = mode_of_payment
            pe.insert()
            pe.submit()

        mopd = get_mode_of_payment_details(filters)

        mopd_values = list(mopd.values())[0]
        for mopd_value in mopd_values:
            if mopd_value[0] == "Credit Card":
                cc_init_amount = mopd_value[1]

        # Cancel one Credit Card Payment Entry and check that it is not fetched in mode of payment details.
        payment_entries = frappe.get_all("Payment Entry",
                                         filters={
                                             "mode_of_payment": "Credit Card",
                                             "docstatus": 1
                                         },
                                         fields=["name", "docstatus"])
        for payment_entry in payment_entries[:1]:
            pe = frappe.get_doc("Payment Entry", payment_entry.name)
            pe.cancel()

        mopd = get_mode_of_payment_details(filters)
        mopd_values = list(mopd.values())[0]
        for mopd_value in mopd_values:
            if mopd_value[0] == "Credit Card":
                cc_final_amount = mopd_value[1]

        self.assertTrue(cc_init_amount > cc_final_amount)
コード例 #17
0
	def test_payment_order_creation_against_payment_entry(self):
		purchase_invoice = make_purchase_invoice()
		payment_entry = get_payment_entry("Purchase Invoice", purchase_invoice.name, bank_account="_Test Bank - _TC")
		payment_entry.reference_no = "_Test_Payment_Order"
		payment_entry.reference_date = getdate()
		payment_entry.party_bank_account = "Checking Account - Citi Bank"
		payment_entry.insert()
		payment_entry.submit()

		doc = create_payment_order_against_payment_entry(payment_entry, "Payment Entry")
		reference_doc = doc.get("references")[0]
		self.assertEquals(reference_doc.reference_name, payment_entry.name)
		self.assertEquals(reference_doc.reference_doctype, "Payment Entry")
		self.assertEquals(reference_doc.supplier, "_Test Supplier")
		self.assertEquals(reference_doc.amount, 250)
コード例 #18
0
    def test_payment_entry_account_and_party_balance_with_cost_center(self):
        from erpbee.accounts.doctype.cost_center.test_cost_center import create_cost_center
        from erpbee.accounts.utils import get_balance_on
        cost_center = "_Test Cost Center for BS Account - _TC"
        create_cost_center(cost_center_name="_Test Cost Center for BS Account",
                           company="_Test Company")

        si = create_sales_invoice_against_cost_center(cost_center=cost_center,
                                                      debit_to="Debtors - _TC")

        account_balance = get_balance_on(account="_Test Bank - _TC",
                                         cost_center=si.cost_center)
        party_balance = get_balance_on(party_type="Customer",
                                       party=si.customer,
                                       cost_center=si.cost_center)
        party_account_balance = get_balance_on(si.debit_to,
                                               cost_center=si.cost_center)

        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Bank - _TC")
        pe.reference_no = "112211-1"
        pe.reference_date = nowdate()
        pe.paid_to = "_Test Bank - _TC"
        pe.paid_amount = si.grand_total
        pe.insert()
        pe.submit()

        expected_account_balance = account_balance + si.grand_total
        expected_party_balance = party_balance - si.grand_total
        expected_party_account_balance = party_account_balance - si.grand_total

        account_balance = get_balance_on(account=pe.paid_to,
                                         cost_center=pe.cost_center)
        party_balance = get_balance_on(party_type="Customer",
                                       party=pe.party,
                                       cost_center=pe.cost_center)
        party_account_balance = get_balance_on(account=pe.paid_from,
                                               cost_center=pe.cost_center)

        self.assertEqual(pe.cost_center, si.cost_center)
        self.assertEqual(expected_account_balance, account_balance)
        self.assertEqual(expected_party_balance, party_balance)
        self.assertEqual(expected_party_account_balance, party_account_balance)
コード例 #19
0
    def test_payment_entry_against_purchase_invoice_with_cost_center(self):
        from erpbee.accounts.doctype.cost_center.test_cost_center import create_cost_center
        cost_center = "_Test Cost Center for BS Account - _TC"
        create_cost_center(cost_center_name="_Test Cost Center for BS Account",
                           company="_Test Company")

        pi = make_purchase_invoice_against_cost_center(
            cost_center=cost_center, credit_to="Creditors - _TC")

        pe = get_payment_entry("Purchase Invoice",
                               pi.name,
                               bank_account="_Test Bank - _TC")
        self.assertEqual(pe.cost_center, pi.cost_center)

        pe.reference_no = "112222-1"
        pe.reference_date = nowdate()
        pe.paid_from = "_Test Bank - _TC"
        pe.paid_amount = pi.grand_total
        pe.insert()
        pe.submit()

        expected_values = {
            "_Test Bank - _TC": {
                "cost_center": cost_center
            },
            "Creditors - _TC": {
                "cost_center": cost_center
            }
        }

        gl_entries = frappe.db.sql(
            """select account, cost_center, account_currency, debit, credit,
			debit_in_account_currency, credit_in_account_currency
			from `tabGL Entry` where voucher_type='Payment Entry' and voucher_no=%s
			order by account asc""",
            pe.name,
            as_dict=1)

        self.assertTrue(gl_entries)

        for gle in gl_entries:
            self.assertEqual(expected_values[gle.account]["cost_center"],
                             gle.cost_center)
コード例 #20
0
    def test_get_mode_of_payments(self):
        filters = get_filters()

        for dummy in range(2):
            si = create_sales_invoice_record()
            si.insert()
            si.submit()

            if int(si.name[-3:]) % 2 == 0:
                bank_account = "_Test Cash - _TC"
                mode_of_payment = "Cash"
            else:
                bank_account = "_Test Bank - _TC"
                mode_of_payment = "Credit Card"

            pe = get_payment_entry("Sales Invoice",
                                   si.name,
                                   bank_account=bank_account)
            pe.reference_no = "_Test"
            pe.reference_date = today()
            pe.mode_of_payment = mode_of_payment
            pe.insert()
            pe.submit()

        mop = get_mode_of_payments(filters)
        self.assertTrue('Credit Card' in list(mop.values())[0])
        self.assertTrue('Cash' in list(mop.values())[0])

        # Cancel all Cash payment entry and check if this mode of payment is still fetched.
        payment_entries = frappe.get_all("Payment Entry",
                                         filters={
                                             "mode_of_payment": "Cash",
                                             "docstatus": 1
                                         },
                                         fields=["name", "docstatus"])
        for payment_entry in payment_entries:
            pe = frappe.get_doc("Payment Entry", payment_entry.name)
            pe.cancel()

        mop = get_mode_of_payments(filters)
        self.assertTrue('Credit Card' in list(mop.values())[0])
        self.assertTrue('Cash' not in list(mop.values())[0])
コード例 #21
0
    def test_payment_entry_exchange_gain_loss(self):
        si = create_sales_invoice(customer="_Test Customer USD",
                                  debit_to="_Test Receivable USD - _TC",
                                  currency="USD",
                                  conversion_rate=50)
        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               bank_account="_Test Bank USD - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.target_exchange_rate = 55

        pe.append(
            "deductions", {
                "account": "_Test Exchange Gain/Loss - _TC",
                "cost_center": "_Test Cost Center - _TC",
                "amount": -500
            })
        pe.save()

        self.assertEqual(pe.unallocated_amount, 0)
        self.assertEqual(pe.difference_amount, 0)

        pe.submit()

        expected_gle = dict((d[0], d) for d in [
            ["_Test Receivable USD - _TC", 0, 5000, si.name],
            ["_Test Bank USD - _TC", 5500, 0, None],
            ["_Test Exchange Gain/Loss - _TC", 0, 500, None],
        ])

        self.validate_gl_entries(pe.name, expected_gle)

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 0)
コード例 #22
0
    def test_payment_entry_against_pi(self):
        pi = make_purchase_invoice(supplier="_Test Supplier USD",
                                   debit_to="_Test Payable USD - _TC",
                                   currency="USD",
                                   conversion_rate=50)
        pe = get_payment_entry("Purchase Invoice",
                               pi.name,
                               bank_account="_Test Bank USD - _TC")
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"
        pe.source_exchange_rate = 50
        pe.insert()
        pe.submit()

        expected_gle = dict(
            (d[0], d) for d in [["_Test Payable USD - _TC", 12500, 0, pi.name],
                                ["_Test Bank USD - _TC", 0, 12500, None]])

        self.validate_gl_entries(pe.name, expected_gle)

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", pi.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 0)
コード例 #23
0
    def test_payment_entry_against_order(self):
        so = make_sales_order()
        pe = get_payment_entry("Sales Order",
                               so.name,
                               bank_account="_Test Cash - _TC")
        pe.paid_from = "Debtors - _TC"
        pe.insert()
        pe.submit()

        expected_gle = dict((d[0], d)
                            for d in [["Debtors - _TC", 0, 1000, so.name],
                                      ["_Test Cash - _TC", 1000.0, 0, None]])

        self.validate_gl_entries(pe.name, expected_gle)

        so_advance_paid = frappe.db.get_value("Sales Order", so.name,
                                              "advance_paid")
        self.assertEqual(so_advance_paid, 1000)

        pe.cancel()

        so_advance_paid = frappe.db.get_value("Sales Order", so.name,
                                              "advance_paid")
        self.assertEqual(so_advance_paid, 0)
コード例 #24
0
    def test_payment_entry_against_si_usd_to_inr(self):
        si = create_sales_invoice(customer="_Test Customer USD",
                                  debit_to="_Test Receivable USD - _TC",
                                  currency="USD",
                                  conversion_rate=50)
        pe = get_payment_entry("Sales Invoice",
                               si.name,
                               party_amount=20,
                               bank_account="_Test Bank - _TC",
                               bank_amount=900)
        pe.reference_no = "1"
        pe.reference_date = "2016-01-01"

        self.assertEqual(pe.difference_amount, 100)

        pe.append(
            "deductions", {
                "account": "_Test Exchange Gain/Loss - _TC",
                "cost_center": "_Test Cost Center - _TC",
                "amount": 100
            })
        pe.insert()
        pe.submit()

        expected_gle = dict((d[0], d) for d in [
            ["_Test Receivable USD - _TC", 0, 1000, si.name],
            ["_Test Bank - _TC", 900, 0, None],
            ["_Test Exchange Gain/Loss - _TC", 100.0, 0, None],
        ])

        self.validate_gl_entries(pe.name, expected_gle)

        outstanding_amount = flt(
            frappe.db.get_value("Sales Invoice", si.name,
                                "outstanding_amount"))
        self.assertEqual(outstanding_amount, 80)
コード例 #25
0
def make_payment(docname):
	pe = get_payment_entry("Sales Invoice", docname, bank_account="Cash - _TC2", party_amount=40)
	pe.paid_from = "Debtors - _TC2"
	pe.insert()
	pe.submit()