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
145 lines (116 loc) · 4.1 KB
/
Copy pathpurchase.py
File metadata and controls
145 lines (116 loc) · 4.1 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from six import python_2_unicode_compatible
from .base import QuickbooksBaseObject, Ref, QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin, \
LinkedTxn, Address, CustomField, MarkupInfo
from .tax import TxnTaxDetail
@python_2_unicode_compatible
class AccountBasedExpenseLineDetail(QuickbooksBaseObject):
class_dict = {
"ClassRef": Ref,
"AccountRef": Ref,
"TaxCodeRef": Ref
}
list_dict = {}
def __init__(self):
super(AccountBasedExpenseLineDetail, self).__init__()
self.BillableStatus = ""
self.ClassRef = None
self.AccountRef = None
self.TaxCodeRef = None
def __str__(self):
return self.BillableStatus
class ItemBasedExpenseLineDetail(QuickbooksBaseObject):
class_dict = {
"ItemRef": Ref,
"ClassRef": Ref,
"PriceLevelRef": Ref,
"TaxCodeRef": Ref,
"CustomerRef": Ref,
"MarkupInfo": MarkupInfo
}
def __init__(self):
self.UnitPrice = 0
self.Qty = 0
self.BillableStatus = ""
self.TaxInclusiveAmt = 0
self.ItemRef = None
self.ClassRef = None
self.PriceLevelRef = None
self.TaxCodeRef = None
self.CustomerRef = None
self.MarkupInfo = None
@python_2_unicode_compatible
class PurchaseLine(QuickbooksBaseObject):
class_dict = {
"AccountBasedExpenseLineDetail": Ref,
"ItemBasedExpenseLineDetail": ItemBasedExpenseLineDetail,
}
list_dict = {
"LinkedTxn": LinkedTxn,
"CustomField": CustomField,
}
def __init__(self):
super(PurchaseLine, self).__init__()
self.Id = 0
self.LineNum = 0
self.Description = ""
self.Amount = 0
self.DetailType = "ItemBasedExpenseLineDetail"
self.TaxCodeRef = None
self.AccountRef = None
self.ItemBasedExpenseLineDetail = None
self.LinkedTxn = []
self.AccountBasedExpenseLineDetail = []
def __str__(self):
return str(self.Amount)
@python_2_unicode_compatible
class Purchase(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": PurchaseLine,
"LinkedTxn": LinkedTxn,
}
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 = ""
self.TxnSource = ""
self.GlobalTaxCalculation = "TaxExcluded"
self.TxnTaxDetail = None
self.DepartmentRef = None
self.AccountRef = None
self.EnitityRef = None
self.CurrencyRef = None
self.PaymentMethodRef = None
self.RemitToAddr = None
self.Line = []
self.LinkedTxn = []
def __str__(self):
return str(self.TotalAmt)