|
| 1 | +import unittest |
| 2 | +from datetime import datetime |
| 3 | + |
| 4 | +from quickbooks.objects.creditcardpayment import CreditCardPayment |
| 5 | +from quickbooks.objects.account import Account |
| 6 | +from quickbooks.objects.bill import Bill |
| 7 | +from quickbooks.objects.billpayment import BillPayment, BillPaymentLine |
| 8 | +from quickbooks.objects.base import Ref |
| 9 | +from quickbooks.objects.vendor import Vendor |
| 10 | + |
| 11 | + |
| 12 | +class BillPaymentTest(unittest.TestCase): |
| 13 | + def setUp(self): |
| 14 | + |
| 15 | + self.account_number = datetime.now().strftime('%d%H%M') |
| 16 | + self.name = "Test Account {0}".format(self.account_number) |
| 17 | + |
| 18 | + def test_create(self): |
| 19 | + bill_payment = BillPayment() |
| 20 | + |
| 21 | + bill_payment.PayType = "CreditCard" |
| 22 | + bill_payment.TotalAmt = 200 |
| 23 | + bill_payment.PrivateNote = "Private Note" |
| 24 | + |
| 25 | + vendor = Vendor.all(max_results=1)[0] |
| 26 | + bill_payment.VendorRef = vendor.to_ref() |
| 27 | + |
| 28 | + bill_payment.CreditCardPayment = CreditCardPayment() |
| 29 | + |
| 30 | + #account = Account.all(max_results=1)[0] |
| 31 | + #bill_payment.CreditCardPayment.CCAccountRef = account.to_ref() |
| 32 | + |
| 33 | + ap_account = Account.where("AccountSubType = 'AccountsPayable'")[0] |
| 34 | + bill_payment.APAccountRef = ap_account.to_ref() |
| 35 | + |
| 36 | + bill = Bill.all(max_results=1)[0] |
| 37 | + |
| 38 | + line = BillPaymentLine() |
| 39 | + line.LinkedTxn.append(bill.to_linked_txn()) |
| 40 | + line.Amount = 200 |
| 41 | + |
| 42 | + bill_payment.Line.append(line) |
| 43 | + bill_payment.save() |
| 44 | + |
| 45 | + query_bill_payment = BillPayment.get(bill_payment.Id) |
| 46 | + |
| 47 | + self.assertEquals(query_bill_payment.PayType, "Check") |
| 48 | + self.assertEquals(query_bill_payment.TotalAmt, 200.0) |
| 49 | + self.assertEquals(query_bill_payment.PrivateNote,"Private Note") |
| 50 | + |
| 51 | + self.assertEquals(len(query_bill_payment.Line), 1) |
| 52 | + self.assertEquals(query_bill_payment.Line[0].Amount, 200.0) |
0 commit comments