forked from routablehq/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpurchase.py
More file actions
76 lines (64 loc) · 2.6 KB
/
purchase.py
File metadata and controls
76 lines (64 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from six import python_2_unicode_compatible
from quickbooks.objects.detailline import DetailLine, AccountBasedExpenseLine, ItemBasedExpenseLine, \
TDSLine
from .base import Ref, QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin, \
LinkedTxn, Address
from .tax import TxnTaxDetail
from ..mixins import DeleteMixin
@python_2_unicode_compatible
class Purchase(DeleteMixin, QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin):
"""
QBO definition: This entity represents expenses, such as a purchase made from a vendor.
There are three types of Purchases: Cash, Check, and Credit Card.
- Cash Purchase contains information regarding a payment made in cash.
- Check Purchase contains information regarding a payment made by check.
- Credit Card Purchase contains information regarding a payment made by credit card or refunded/credited back
to a credit card.
For example, to create a transaction that sends a check to a vendor, create a Purchase object with PaymentType
set to Check. To query Purchase transactions of a certain type, for example Check, submit the following to the
query endpoint: SELECT * from Purchase where PaymentType='Check' You must specify an AccountRef for all purchases.
The TotalAmtattribute must add up to sum of Line.Amount attributes.
"""
class_dict = {
"AccountRef": Ref,
"EntityRef": Ref,
"DepartmentRef": Ref,
"CurrencyRef": Ref,
"PaymentMethodRef": Ref,
"RemitToAddr": Address,
"TxnTaxDetail": TxnTaxDetail
}
list_dict = {
"Line": DetailLine,
"LinkedTxn": LinkedTxn,
}
detail_dict = {
"AccountBasedExpenseLineDetail": AccountBasedExpenseLine,
"ItemBasedExpenseLineDetail": ItemBasedExpenseLine,
"TDSLineDetail": TDSLine,
}
qbo_object_name = "Purchase"
def __init__(self):
super(Purchase, self).__init__()
self.DocNumber = ""
self.TxnDate = ""
self.ExchangeRate = 1
self.PrivateNote = ""
self.PaymentType = ""
self.Credit = False
self.TotalAmt = 0
self.PrintStatus = "NeedToPrint"
self.PurchaseEx = None
self.TxnSource = None
self.GlobalTaxCalculation = "TaxExcluded"
self.TxnTaxDetail = None
self.DepartmentRef = None
self.AccountRef = None
self.EntityRef = None
self.CurrencyRef = None
self.PaymentMethodRef = None
self.RemitToAddr = None
self.Line = []
self.LinkedTxn = []
def __str__(self):
return str(self.TotalAmt)