Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit885fcfa

Browse files
authored
Merge pull requestej2#202 from jakubczaplicki/credit_card_payment
Add support for CreditCardPayment entity
2 parentsacfe638 +d162a3c commit885fcfa

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+
fromsiximportpython_2_unicode_compatible
2+
from .baseimportRef,QuickbooksManagedObject,QuickbooksTransactionEntity,LinkedTxnMixin
3+
from ..mixinsimportDeleteMixin
4+
5+
6+
@python_2_unicode_compatible
7+
classCreditCardPayment(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+
returnstr(self.Amount)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
importtime
2+
fromdatetimeimportdatetime
3+
4+
fromquickbooks.objectsimportTransfer
5+
fromquickbooks.objects.accountimportAccount
6+
fromquickbooks.objects.creditcardpayment_entityimportCreditCardPayment
7+
fromtests.integration.test_baseimportQuickbooksTestCase
8+
9+
10+
classCreditCardPaymentEntityTest(QuickbooksTestCase):
11+
defsetUp(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+
deftest_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+
deftest_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+
importunittest
2+
3+
fromquickbooksimportQuickBooks
4+
fromquickbooks.objects.creditcardpayment_entityimportCreditCardPayment
5+
6+
7+
classTaxAgencyTests(unittest.TestCase):
8+
deftest_unicode(self):
9+
credit_card_payment=CreditCardPayment()
10+
credit_card_payment.Amount=100
11+
12+
self.assertEquals(str(credit_card_payment),"100")
13+
14+
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp