forked from routablehq/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaxservice.py
More file actions
66 lines (49 loc) · 2.04 KB
/
taxservice.py
File metadata and controls
66 lines (49 loc) · 2.04 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
from six import python_2_unicode_compatible
from .base import QuickbooksBaseObject
from ..mixins import UpdateMixin
from ..client import QuickBooks
@python_2_unicode_compatible
class TaxRateDetails(QuickbooksBaseObject):
qbo_object_name = "TaxRateDetails"
def __init__(self):
super(TaxRateDetails, self).__init__()
self.TaxRateName = None
self.TaxRateId = None
self.RateValue = None
self.TaxAgencyId = None
self.TaxApplicableOn = "Sales"
def __str__(self):
return self.TaxRateName
@python_2_unicode_compatible
class TaxService(QuickbooksBaseObject, UpdateMixin):
"""
QBO definition: The TaxService endpoint allows you to perform the following actions:
- Create a new tax code and specify a list of existing tax rates to be associated to that tax code. To retrieve a
list of existing tax codes, query the TaxCode endpoint.
- Create a new tax rate dynamically. To retrieve a list of existing tax rates, query the TaxRate endpoint.
Tax agency entities on tax rates created via the TaxService endpoint are referenced by id only. That is, you
cannot create new tax agencies via the TaxService endpoint.
"""
list_dict = {
"TaxRateDetails": TaxRateDetails
}
qbo_object_name = "TaxService/Taxcode"
def __init__(self):
super(TaxService, self).__init__()
self.TaxCode = None # Required
self.TaxCodeId = None # Readonly - this is the unique database Id (called Id on every other model...)
self.Id = 0
self.TaxRateDetails = []
def __str__(self):
return self.TaxCode
def save(self, qb=None):
if not qb:
qb = QuickBooks()
if self.TaxCodeId and self.TaxCodeId > 0:
json_data = qb.update_object(self.qbo_object_name, self.to_json())
else:
json_data = qb.create_object(self.qbo_object_name, self.to_json())
obj = type(self).from_json(json_data)
self.TaxCodeId = obj.Id
self.Id = self.TaxCodeId
return obj