fix add expenses dialog

This commit is contained in:
Wilson Gomez 2023-01-06 19:18:13 -05:00
parent 7d4a95fa0c
commit add964c64b
2 changed files with 6 additions and 3 deletions

View File

@ -23,7 +23,10 @@ class TableEdit(QAbstractTableModel):
if self._fields[col]['type'] == 'integer':
return int(val)
elif self._fields[col]['type'] == 'float':
return "{:,.2f}".format(val)
if isinstance(val, (int, float)):
return "{:,.2f}".format(float(val))
else:
return "{:,.2f}".format(float(val.replace(',', '')))
return val
elif role == Qt.TextAlignmentRole:
col = index.column()
@ -89,7 +92,7 @@ class TableEdit(QAbstractTableModel):
return rec
def get_sum(self, col):
return sum(int(d[col]) for d in self._data)
return sum(float(d[col].replace(',', '') if isinstance(d[col], str) else d[col]) for d in self._data)
class TableModel(QAbstractTableModel):

View File

@ -1059,7 +1059,7 @@ class DialogExpenses(QuickDialog):
'invoice_number': d[1],
'description': d[2],
'reference': d[3],
'amount': d[4],
'amount': d[4].replace(',', '') if isinstance(d[4], str) else d[4],
}
obj_id = d[0]
if d[0] > 0: