Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff3e741

Browse files
committed
Updates.
1 parent 9a6ca5b commit ff3e741

34 files changed

+448
-598
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Changelog
22
========
33

4-
* 0.5.0 (July 22, 2016)
5-
* Fixed bug on PurchaseLine.
4+
* 0.5.0 (July 25, 2016)
65
* Added ability to query current user.
76
* Added support to reconnect an account.
87
* Added to_ref method to Bill object.
@@ -17,6 +16,12 @@ Changelog
1716
* Fixed issues that prevented save from working on TaxService.
1817
* Removed unsupported save method from TaxRate.
1918
* Removed unsupported save method from TaxCode.
19+
* Added to_ref method to TaxCode.
20+
* Fixed issues with default values on Estimate.
21+
* Fixed issues loading detail lines on the following objects: JournalEntry, CreditMemo, Bill, Purchase and PurchaseOrder.
22+
* Corrected spelling of object SaleItemLine to SalesItemLine.
23+
* Removed the following objects: CreditMemoLine, BillLine, JournalEntryLine, PurchaseLine, and PurchaseOrderLine.
24+
2025

2126
* 0.4.0 (June 15, 2016)
2227
* Added a way of disconnecting a Quickbooks Account to client.

quickbooks/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class QuickBooks(object):
5555
"Department", "Deposit", "Employee", "Estimate", "Invoice",
5656
"Item", "JournalEntry", "Payment", "PaymentMethod",
5757
"Purchase", "PurchaseOrder", "RefundReceipt",
58-
"SalesReceipt", "Taxcode", "TaxService/Taxcode", "TaxRate", "Term",
58+
"SalesReceipt", "TaxCode", "TaxService/Taxcode", "TaxRate", "Term",
5959
"TimeActivity", "Transfer", "Vendor", "VendorCredit"
6060
]
6161

quickbooks/mixins.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ def from_json(cls, json_data):
2828
sub_obj = obj.class_dict[key]()
2929
sub_obj = sub_obj.from_json(json_data[key])
3030
setattr(obj, key, sub_obj)
31+
3132
elif key in obj.list_dict:
3233
sub_list = []
3334

3435
for data in json_data[key]:
35-
sub_obj = obj.list_dict[key]()
36+
37+
if 'DetailType' in data and data['DetailType'] in obj.detail_dict:
38+
sub_obj = obj.detail_dict[data['DetailType']]()
39+
else:
40+
sub_obj = obj.list_dict[key]()
41+
3642
sub_obj = sub_obj.from_json(data)
3743
sub_list.append(sub_obj)
3844

quickbooks/objects/base.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
class QuickbooksBaseObject(ToJsonMixin, FromJsonMixin):
66
class_dict = {}
77
list_dict = {}
8+
detail_dict = {}
89

910

1011
class QuickbooksTransactionEntity(QuickbooksBaseObject):
11-
class_dict = {}
12-
list_dict = {}
13-
1412
def __init__(self):
1513
self.Id = None
1614
self.SyncToken = 0
@@ -47,7 +45,7 @@ def to_linked_txn(self):
4745

4846

4947
@python_2_unicode_compatible
50-
class Address(ToJsonMixin, FromJsonMixin):
48+
class Address(QuickbooksBaseObject):
5149
def __init__(self):
5250
self.Id = None
5351
self.Line1 = ""
@@ -77,7 +75,7 @@ def __str__(self):
7775

7876

7977
@python_2_unicode_compatible
80-
class EmailAddress(ToJsonMixin, FromJsonMixin):
78+
class EmailAddress(QuickbooksBaseObject):
8179
def __init__(self):
8280
self.Address = ""
8381

@@ -86,7 +84,7 @@ def __str__(self):
8684

8785

8886
@python_2_unicode_compatible
89-
class WebAddress(ToJsonMixin, FromJsonMixin):
87+
class WebAddress(QuickbooksBaseObject):
9088
def __init__(self):
9189
self.URI = ""
9290

@@ -95,10 +93,7 @@ def __str__(self):
9593

9694

9795
@python_2_unicode_compatible
98-
class Ref(ToJsonMixin, FromJsonMixin):
99-
class_dict = {}
100-
list_dict = {}
101-
96+
class Ref(QuickbooksBaseObject):
10297
def __init__(self):
10398
self.value = ""
10499
self.name = ""
@@ -109,7 +104,7 @@ def __str__(self):
109104

110105

111106
@python_2_unicode_compatible
112-
class CustomField(ToJsonMixin, FromJsonMixin):
107+
class CustomField(QuickbooksBaseObject):
113108
def __init__(self):
114109
self.Type = ""
115110
self.Name = ""

quickbooks/objects/bill.py

Lines changed: 10 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,9 @@
11
from six import python_2_unicode_compatible
2-
from .base import QuickbooksBaseObject, Ref, LinkedTxn, QuickbooksManagedObject, QuickbooksTransactionEntity, \
3-
LinkedTxnMixin, MarkupInfo
4-
from .tax import TxnTaxDetail
5-
6-
7-
@python_2_unicode_compatible
8-
class AccountBasedExpenseLineDetail(QuickbooksBaseObject):
9-
class_dict = {
10-
"CustomerRef": Ref,
11-
"AccountRef": Ref,
12-
"TaxCodeRef": Ref,
13-
"ClassRef": Ref,
14-
"MarkupInfo": MarkupInfo,
15-
}
16-
17-
def __init__(self):
18-
super(AccountBasedExpenseLineDetail, self).__init__()
19-
self.BillableStatus = None
20-
self.TaxAmount = 0
21-
self.TaxInclusiveAmt = 0
22-
23-
self.CustomerRef = None
24-
self.AccountRef = None
25-
self.TaxCodeRef = None
26-
27-
def __str__(self):
28-
return self.BillableStatus
29-
30-
31-
class ItemBasedExpenseLineDetail(QuickbooksBaseObject):
32-
class_dict = {
33-
"ItemRef": Ref,
34-
"ClassRef": Ref,
35-
"PriceLevelRef": Ref,
36-
"TaxCodeRef": Ref,
37-
"CustomerRef": Ref,
38-
"MarkupInfo": MarkupInfo
39-
}
40-
41-
def __init__(self):
42-
super(ItemBasedExpenseLineDetail, self).__init__()
43-
self.BillableStatus = ""
44-
self.UnitPrice = 0
45-
self.TaxInclusiveAmt = 0
46-
self.Qty = 0
47-
self.ItemRef = None
48-
self.ClassRef = None
49-
self.PriceLevelRef = None
50-
self.TaxCodeRef = None
51-
self.MarkupInfo = None
52-
self.CustomerRef = None
532

54-
55-
@python_2_unicode_compatible
56-
class BillLine(QuickbooksBaseObject):
57-
class_dict = {
58-
"AccountBasedExpenseLineDetail": AccountBasedExpenseLineDetail,
59-
"ItemBasedExpenseLineDetail": ItemBasedExpenseLineDetail,
60-
}
61-
62-
list_dict = {
63-
"LinkedTxn": LinkedTxn
64-
}
65-
66-
def __init__(self):
67-
super(BillLine, self).__init__()
68-
69-
self.Id = None
70-
self.LineNum = 0
71-
self.Description = ""
72-
self.Amount = 0
73-
self.DetailType = "AccountBasedExpenseLineDetail"
74-
75-
self.AccountBasedExpenseLineDetail = None
76-
self.ItemBasedExpenseLineDetail = None
77-
78-
def __str__(self):
79-
return str(self.Amount)
3+
from quickbooks.objects.detailline import DetailLine, ItemBasedExpenseLine, AccountBasedExpenseLine
4+
from .base import Ref, LinkedTxn, QuickbooksManagedObject, QuickbooksTransactionEntity, \
5+
LinkedTxnMixin
6+
from .tax import TxnTaxDetail
807

818

829
@python_2_unicode_compatible
@@ -97,7 +24,12 @@ class Bill(QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMixin)
9724
}
9825

9926
list_dict = {
100-
"Line": BillLine,
27+
"Line": DetailLine,
28+
}
29+
30+
detail_dict = {
31+
"ItemBasedExpenseLineDetail": ItemBasedExpenseLine,
32+
"AccountBasedExpenseLineDetail": AccountBasedExpenseLine,
10133
}
10234

10335
qbo_object_name = "Bill"

quickbooks/objects/creditmemo.py

Lines changed: 12 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,9 @@
11
from six import python_2_unicode_compatible
2-
from .base import QuickbooksBaseObject, Address, EmailAddress, Ref, CustomField, CustomerMemo, QuickbooksManagedObject, \
3-
LinkedTxnMixin, LinkedTxn, MarkupInfo, QuickbooksTransactionEntity
4-
from .tax import TxnTaxDetail
5-
6-
7-
@python_2_unicode_compatible
8-
class SalesItemLineDetail(QuickbooksBaseObject):
9-
class_dict = {
10-
"ItemRef": Ref,
11-
"TaxCodeRef": Ref,
12-
"ClassRef": Ref,
13-
"PriceLevelRef": Ref,
14-
"MarkupInfo": MarkupInfo
15-
}
16-
17-
def __init__(self):
18-
super(SalesItemLineDetail, self).__init__()
19-
self.Qty = 0
20-
self.UnitPrice = 0
21-
self.ServiceDate = ""
22-
self.TaxInclusiveAmt = 0
23-
24-
self.MarkupInfo = None
25-
self.ItemRef = None
26-
self.TaxCodeRef = None
27-
self.ClassRef = None
28-
self.PriceLevelRef = None
29-
30-
def __str__(self):
31-
return str(self.UnitPrice)
32-
33-
34-
class SubtotalLineDetail(QuickbooksBaseObject):
35-
class_dict = {
36-
"ItemRef": Ref
37-
}
38-
39-
def __init__(self):
40-
super(SubtotalLineDetail, self).__init__()
41-
self.ItemRef = None
42-
43-
44-
class DiscountOverride(QuickbooksBaseObject):
45-
class_dict = {
46-
"DiscountRef": Ref,
47-
"DiscountAccountRef": Ref
48-
}
49-
50-
def __init__(self):
51-
super(DiscountOverride, self).__init__()
52-
self.PercentBased = False
53-
self.DiscountPercent = 0
54-
self.DiscountAccountRef = None
55-
self.DiscountRef = None
56-
57-
58-
class DiscountLineDetail(QuickbooksBaseObject):
59-
class_dict = {
60-
"ClassRef": Ref,
61-
"TaxCodeRef": Ref,
62-
"Discount": DiscountOverride
63-
}
64-
65-
def __init__(self):
66-
super(DiscountLineDetail, self).__init__()
67-
self.ClassRef = None
68-
self.TaxCodeRef = None
69-
self.Discount = None
70-
71-
72-
class DescriptionLineDetail(QuickbooksBaseObject):
73-
class_dict = {
74-
"TaxCodeRef": Ref
75-
}
76-
77-
def __init__(self):
78-
super(DescriptionLineDetail, self).__init__()
79-
self.ServiceDate = ""
80-
self.TaxCodeRef = None
81-
82-
83-
@python_2_unicode_compatible
84-
class CreditMemoLine(QuickbooksBaseObject):
85-
class_dict = {
86-
"SalesItemLineDetail": SalesItemLineDetail,
87-
"SubtotalLineDetail": SubtotalLineDetail,
88-
"DiscountLineDetail": DiscountLineDetail,
89-
"DescriptionLineDetail": DescriptionLineDetail
90-
}
91-
92-
list_dict = {
93-
"LinkedTxn": LinkedTxn,
94-
"CustomField": CustomField
95-
}
96-
97-
def __init__(self):
98-
super(CreditMemoLine, self).__init__()
99-
self.Id = None
100-
self.LineNum = ""
101-
self.Description = ""
102-
self.Amount = ""
103-
self.DetailType = ""
1042

105-
self.SubtotalLineDetail = None
106-
self.SalesItemLineDetail = None
107-
self.DiscountLineDetail = None
108-
self.DescriptionLineDetail = None
109-
110-
self.LinkedTxn = []
111-
self.CustomField = []
112-
113-
def __str__(self):
114-
return "[{0}] {1} {2}".format(self.LineNum, self.Description, self.Amount)
3+
from quickbooks.objects.detailline import SalesItemLine, SubtotalLine, DiscountLine, DescriptionLine, DetailLine
4+
from .base import Address, EmailAddress, Ref, CustomField, CustomerMemo, QuickbooksManagedObject, \
5+
LinkedTxnMixin, QuickbooksTransactionEntity
6+
from .tax import TxnTaxDetail
1157

1168

1179
@python_2_unicode_compatible
@@ -138,7 +30,14 @@ class CreditMemo(QuickbooksTransactionEntity, QuickbooksManagedObject, LinkedTxn
13830

13931
list_dict = {
14032
"CustomField": CustomField,
141-
"Line": CreditMemoLine
33+
"Line": DetailLine
34+
}
35+
36+
detail_dict = {
37+
"SalesItemLineDetail": SalesItemLine,
38+
"SubTotalLineDetail": SubtotalLine,
39+
"DiscountLineDetail": DiscountLine,
40+
"DescriptionLineDetail": DescriptionLine
14241
}
14342

14443
qbo_object_name = "CreditMemo"

quickbooks/objects/deposit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class Deposit(QuickbooksManagedObject, QuickbooksTransactionEntity, LinkedTxnMix
106106
"Line": DepositLine
107107
}
108108

109+
detail_dict = {
110+
"DepositLineDetail": DepositLine
111+
}
112+
109113
qbo_object_name = "Deposit"
110114

111115
def __init__(self):

0 commit comments

Comments
 (0)