Skip to content

Commit 885fcfa

Browse files
authored
Merge pull request ej2#202 from jakubczaplicki/credit_card_payment
Add support for CreditCardPayment entity
2 parents acfe638 + d162a3c commit 885fcfa

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed

quickbooks/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class QuickBooks(object):
4949
"Item", "JournalEntry", "Payment", "PaymentMethod",
5050
"Purchase", "PurchaseOrder", "RefundReceipt",
5151
"SalesReceipt", "TaxAgency", "TaxCode", "TaxService/Taxcode", "TaxRate", "Term",
52-
"TimeActivity", "Transfer", "Vendor", "VendorCredit"
52+
"TimeActivity", "Transfer", "Vendor", "VendorCredit", "CreditCardPayment",
5353
]
5454

5555
__instance = None
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from six import python_2_unicode_compatible
2+
from .base import Ref, QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin
3+
from ..mixins import DeleteMixin
4+
5+
6+
@python_2_unicode_compatible
7+
class CreditCardPayment(DeleteMixin, QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin):
8+
"""
9+
QBO definition: A Represents a financial transaction to record a Credit Card balance payment
10+
in QuickBooks Online. It provides an easy way for users to move money from a Bank account to
11+
a Credit Card account. It is essentially a more limited Transfer form.
12+
13+
Added in QuickBooks Online v1928, Date: February 13, 2020
14+
15+
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/creditcardpayment
16+
"""
17+
class_dict = {
18+
"BankAccountRef": Ref,
19+
"CreditCardAccountRef": Ref,
20+
}
21+
22+
qbo_object_name = "CreditCardPayment"
23+
24+
def __init__(self):
25+
super(CreditCardPayment, self).__init__()
26+
self.TxnDate = None
27+
self.Amount = 0
28+
self.PrivateNote = None
29+
30+
self.BankAccountRef = None
31+
self.CreditCardAccountRef = None
32+
33+
def __str__(self):
34+
return str(self.Amount)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import time
2+
from datetime import datetime
3+
4+
from quickbooks.objects import Transfer
5+
from quickbooks.objects.account import Account
6+
from quickbooks.objects.creditcardpayment_entity import CreditCardPayment
7+
from tests.integration.test_base import QuickbooksTestCase
8+
9+
10+
class CreditCardPaymentEntityTest(QuickbooksTestCase):
11+
def setUp(self):
12+
time.sleep(3) # Used to prevent error code 3001 - The request limit was reached.
13+
super(CreditCardPaymentEntityTest, self).setUp()
14+
15+
self.account_number = datetime.now().strftime('%d%H%M')
16+
self.name = "Test CreditCardPaymentEntityTest {0}".format(self.account_number)
17+
18+
def test_create(self):
19+
credit_card_account = Account()
20+
credit_card_account.Name = "Credit Card Account {0}".format(self.account_number)
21+
credit_card_account.AccountType = "Credit Card"
22+
credit_card_account.AccountSubType = "CreditCard"
23+
credit_card_account.save(qb=self.qb_client)
24+
25+
accounts = Account.where(
26+
"Classification = 'Asset' AND FullyQualifiedName != 'Accounts Receivable (A/R)'",
27+
max_results=1, qb=self.qb_client)
28+
29+
from_account = accounts[0]
30+
to_account = credit_card_account
31+
32+
credit_card_payment = CreditCardPayment()
33+
credit_card_payment.Amount = 100
34+
credit_card_payment.BankAccountRef = from_account.to_ref()
35+
credit_card_payment.CreditCardAccountRef = to_account.to_ref()
36+
37+
credit_card_payment.save(qb=self.qb_client)
38+
39+
query_credit_card_payment = CreditCardPayment.get(credit_card_payment.Id, qb=self.qb_client)
40+
41+
self.assertEquals(query_credit_card_payment.Id, credit_card_payment.Id)
42+
self.assertEquals(query_credit_card_payment.Amount, 100)
43+
self.assertEquals(query_credit_card_payment.BankAccountRef.value, from_account.Id)
44+
self.assertEquals(query_credit_card_payment.CreditCardAccountRef.value, to_account.Id)
45+
46+
# reset transfer (so the from_account doesn't run out of cash)
47+
# I wonder if we can do a transfer from credit_card_account to a bank_account
48+
transfer = Transfer()
49+
transfer.Amount = 100
50+
transfer.FromAccountRef = to_account.to_ref()
51+
transfer.ToAccountRef = from_account.to_ref()
52+
53+
transfer.save(qb=self.qb_client)
54+
55+
def test_update(self):
56+
credit_card_payment = CreditCardPayment.all(max_results=1, qb=self.qb_client)[0]
57+
credit_card_payment.Amount += 1
58+
credit_card_payment.save(qb=self.qb_client)
59+
60+
query_credit_card_payment = CreditCardPayment.get(credit_card_payment.Id, qb=self.qb_client)
61+
62+
self.assertEquals(query_credit_card_payment.Amount, credit_card_payment.Amount)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import unittest
2+
3+
from quickbooks import QuickBooks
4+
from quickbooks.objects.creditcardpayment_entity import CreditCardPayment
5+
6+
7+
class TaxAgencyTests(unittest.TestCase):
8+
def test_unicode(self):
9+
credit_card_payment = CreditCardPayment()
10+
credit_card_payment.Amount = 100
11+
12+
self.assertEquals(str(credit_card_payment), "100")
13+
14+
def test_valid_object_name(self):
15+
obj = CreditCardPayment()
16+
client = QuickBooks()
17+
result = client.isvalid_object_name(obj.qbo_object_name)
18+
19+
self.assertTrue(result)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy