minor fix discount
This commit is contained in:
parent
35d33d87f2
commit
098e48e1fd
|
@ -807,7 +807,6 @@ class MainWindow(FrontWindow):
|
|||
def _process_price(self, text):
|
||||
discount_valid = True
|
||||
eval_value = text.replace(',', '')
|
||||
|
||||
value = float(eval_value)
|
||||
if self._sign == '-':
|
||||
if self.discount_method == 'percentage' and value > 90:
|
||||
|
@ -821,10 +820,11 @@ class MainWindow(FrontWindow):
|
|||
sale_line, = self.ModSaleLine.find([
|
||||
('id', '=', self._current_line_id)
|
||||
])
|
||||
price_w_tax = sale_line['unit_price_w_tax']
|
||||
price_w_tax = sale_line['product']['sale_price_w_tax']
|
||||
if price_w_tax <= Decimal(value):
|
||||
# Change unit price
|
||||
discount_valid = self.set_unit_price(value)
|
||||
self.set_discount(0)
|
||||
else:
|
||||
eval_value = (1 - (value / price_w_tax)) * 100
|
||||
if self.discount_method == 'fixed':
|
||||
|
@ -1277,7 +1277,10 @@ class MainWindow(FrontWindow):
|
|||
if discount and discount.isdigit():
|
||||
if self.model_sale_lines.rowCount() > 0:
|
||||
lines = [line['id'] for line in self.model_sale_lines._data]
|
||||
self.set_discount(int(discount), lines)
|
||||
res = self.set_discount(int(discount), lines)
|
||||
if not res:
|
||||
self.message_bar.set('discount_not_valid')
|
||||
return False
|
||||
|
||||
def _print_order(self, sale_id, kind, reversion=False):
|
||||
result = False
|
||||
|
@ -2429,9 +2432,8 @@ class MainWindow(FrontWindow):
|
|||
except ValueError:
|
||||
logging.warning('ValueError > ', ValueError)
|
||||
return
|
||||
|
||||
if float(value) <= 0:
|
||||
return
|
||||
if float(value) < 0:
|
||||
return False
|
||||
|
||||
if not lines_ids:
|
||||
target_lines = [self._current_line_id]
|
||||
|
@ -2442,7 +2444,6 @@ class MainWindow(FrontWindow):
|
|||
'line_ids': target_lines,
|
||||
'value': value
|
||||
})
|
||||
|
||||
for rec in records:
|
||||
self.model_sale_lines.update_record(rec)
|
||||
|
||||
|
|
Loading…
Reference in New Issue