31
31
class Mixin :
32
32
"""Mixin containing methods attached to TransactionBuilder Class."""
33
33
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
-
43
34
def with_commit (self ):
44
35
"""
45
36
Set the commit flag of the transaction.
@@ -136,14 +127,7 @@ def with_latlong(self, address_type, lat, long_):
136
127
'longitude' : float (long_ )}
137
128
return self
138
129
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 ):
147
131
r"""
148
132
Add a line to the transaction.
149
133
@@ -152,45 +136,42 @@ def with_line(
152
136
:param string item_code: Code of the item.
153
137
:param string tax_code: Tax Code of the item. If left blank, \
154
138
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.
156
140
:return: TransactionBuilder
157
141
"""
158
-
142
+ if line_number is not None :
143
+ self .line_num = line_number ;
144
+
159
145
temp = {
160
- 'number' : self ._get_line_number ( line_number ),
146
+ 'number' : str ( self .line_num ),
161
147
'amount' : amount ,
162
148
'quantity' : quantity ,
163
149
'itemCode' : str (item_code ),
164
150
'taxCode' : str (tax_code )
165
151
}
166
152
self .create_model ['lines' ].append (temp )
153
+ self .line_num += 1
167
154
return self
168
155
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 ):
176
157
"""
177
158
Add a line with an exemption to this transaction.
178
159
179
160
:param float amount: The amount of this line item
180
161
:param string item_code: The code for the item
181
162
:param string exemption_code: The exemption code for this line item
182
- :param str line_number: Value of the line number.
183
163
:return: TransactionBuilder
184
164
"""
185
165
186
166
temp = {
187
- 'number' : self ._get_line_number ( line_number ),
167
+ 'number' : str ( self .line_num ),
188
168
'quantity' : 1 ,
189
169
'amount' : amount ,
190
170
'exemptionCode' : str (exemption_code ),
191
171
'itemCode' : str (item_code )
192
172
}
193
173
self .create_model ['lines' ].append (temp )
174
+ self .line_num += 1
194
175
return self
195
176
196
177
def with_diagnostics (self ):
@@ -316,13 +297,7 @@ def with_tax_override(self, type_, reason, tax_amount, tax_date):
316
297
}
317
298
return self
318
299
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 ):
326
301
r"""
327
302
Add a line to this transaction.
328
303
@@ -340,11 +315,10 @@ def with_separate_address_line(
340
315
region State or Region of the location.
341
316
postal_code Postal/zip code of the location.
342
317
country The two-letter country code of the location.
343
- :param str line_number: Value of the line number.
344
318
:return: TransactionBuilder
345
319
"""
346
320
temp = {
347
- 'number' : self ._get_line_number ( line_number ) ,
321
+ 'number' : self .line_num ,
348
322
'quantity' : 1 ,
349
323
'amount' : amount ,
350
324
'addresses' : {
@@ -353,6 +327,7 @@ def with_separate_address_line(
353
327
}
354
328
355
329
self .create_model ['lines' ].append (temp )
330
+ self .line_num += 1
356
331
return self
357
332
358
333
def create_adjustment_request (self , desc , reason ):
0 commit comments