Skip to content

Commit 63f7736

Browse files
authored
Merge pull request #76 from avadev/revert-73-refactor-line-number-internals
Revert "Base the line number off of the lines list length"
2 parents 2a58016 + a4a5d1c commit 63f7736

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

src/avalara/transaction_builder_methods.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131
class Mixin:
3232
"""Mixin containing methods attached to TransactionBuilder Class."""
3333

34-
@property
35-
def line_num(self):
36-
return len(self.create_model.get('lines', []))
37-
38-
def _get_line_number(self, line_number=None):
39-
if line_number is None:
40-
line_number = self.line_num
41-
return str(line_number)
42-
4334
def with_commit(self):
4435
"""
4536
Set the commit flag of the transaction.
@@ -136,14 +127,7 @@ def with_latlong(self, address_type, lat, long_):
136127
'longitude': float(long_)}
137128
return self
138129

139-
def with_line(
140-
self,
141-
amount,
142-
quantity,
143-
item_code,
144-
tax_code,
145-
line_number=None,
146-
):
130+
def with_line(self, amount, quantity, item_code, tax_code, line_number=None):
147131
r"""
148132
Add a line to the transaction.
149133
@@ -152,45 +136,42 @@ def with_line(
152136
:param string item_code: Code of the item.
153137
:param string tax_code: Tax Code of the item. If left blank, \
154138
the default item (P0000000) is assumed.
155-
:param str line_number: Value of the line number.
139+
:param [int] line_number: Value of the line number.
156140
:return: TransactionBuilder
157141
"""
158-
142+
if line_number is not None:
143+
self.line_num = line_number;
144+
159145
temp = {
160-
'number': self._get_line_number(line_number),
146+
'number': str(self.line_num),
161147
'amount': amount,
162148
'quantity': quantity,
163149
'itemCode': str(item_code),
164150
'taxCode': str(tax_code)
165151
}
166152
self.create_model['lines'].append(temp)
153+
self.line_num += 1
167154
return self
168155

169-
def with_exempt_line(
170-
self,
171-
amount,
172-
item_code,
173-
exemption_code,
174-
line_number=None,
175-
):
156+
def with_exempt_line(self, amount, item_code, exemption_code):
176157
"""
177158
Add a line with an exemption to this transaction.
178159
179160
:param float amount: The amount of this line item
180161
:param string item_code: The code for the item
181162
:param string exemption_code: The exemption code for this line item
182-
:param str line_number: Value of the line number.
183163
:return: TransactionBuilder
184164
"""
185165

186166
temp = {
187-
'number': self._get_line_number(line_number),
167+
'number': str(self.line_num),
188168
'quantity': 1,
189169
'amount': amount,
190170
'exemptionCode': str(exemption_code),
191171
'itemCode': str(item_code)
192172
}
193173
self.create_model['lines'].append(temp)
174+
self.line_num += 1
194175
return self
195176

196177
def with_diagnostics(self):
@@ -316,13 +297,7 @@ def with_tax_override(self, type_, reason, tax_amount, tax_date):
316297
}
317298
return self
318299

319-
def with_separate_address_line(
320-
self,
321-
amount,
322-
type_,
323-
address,
324-
line_number=None,
325-
):
300+
def with_separate_address_line(self, amount, type_, address):
326301
r"""
327302
Add a line to this transaction.
328303
@@ -340,11 +315,10 @@ def with_separate_address_line(
340315
region State or Region of the location.
341316
postal_code Postal/zip code of the location.
342317
country The two-letter country code of the location.
343-
:param str line_number: Value of the line number.
344318
:return: TransactionBuilder
345319
"""
346320
temp = {
347-
'number': self._get_line_number(line_number),
321+
'number': self.line_num,
348322
'quantity': 1,
349323
'amount': amount,
350324
'addresses': {
@@ -353,6 +327,7 @@ def with_separate_address_line(
353327
}
354328

355329
self.create_model['lines'].append(temp)
330+
self.line_num += 1
356331
return self
357332

358333
def create_adjustment_request(self, desc, reason):

0 commit comments

Comments
 (0)