Skip to content

Commit d3ace7f

Browse files
committed
Show currency field
1 parent cdc78c7 commit d3ace7f

7 files changed

Lines changed: 71 additions & 5 deletions

File tree

OpenNumismat/Collection/Collection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,8 @@ def selectStatement(self):
10501050
"width", "height", "technique", "modification", "axis", "real_weight", "real_diameter", "rating",
10511051
10521052
buy_prices.url AS buying_invoice, sell_prices.url AS sale_invoice,
1053-
catalogs.price5 AS price5, catalogs.price6 AS price6
1053+
catalogs.price5 AS price5, catalogs.price6 AS price6,
1054+
buy_prices.currency AS buying_currency, sell_prices.currency AS sale_currency
10541055
10551056
FROM "coins"
10561057
'''

OpenNumismat/Collection/CollectionFields.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ def compare(self, left, right):
200200
'paydate': 'date', 'payprice': 'price',
201201
'totalpayprice': 'total_price', 'saller': 'counterparty',
202202
'payplace': 'place', 'payinfo': 'info', 'buying_invoice': 'url',
203+
'buying_currency': 'currency',
203204
}
204205
SellPriceFields = {
205206
'saledate': 'date', 'saleprice': 'price',
206207
'totalsaleprice': 'total_price', 'buyer': 'counterparty',
207208
'saleplace': 'place', 'saleinfo': 'info', 'sale_invoice': 'url',
209+
'sale_currency': 'currency',
208210
}
209211
CatalogFields = {
210212
'price1': 'price1', 'price2': 'price2', 'price3': 'price3',
@@ -340,6 +342,8 @@ def __init__(self, parent=None):
340342
('sale_invoice', QApplication.translate('CollectionFieldsBase', "Invoice"), Type.String),
341343
('price4', QApplication.translate('CollectionFieldsBase', "AU"), Type.Money),
342344
('price6', QApplication.translate('CollectionFieldsBase', "BU"), Type.Money),
345+
('buying_currency', QApplication.translate('CollectionFieldsBase', "Currency"), Type.String),
346+
('sale_currency', QApplication.translate('CollectionFieldsBase', "Currency"), Type.String),
343347
]
344348

345349
self.fields = []
@@ -364,6 +368,7 @@ def __init__(self, parent=None):
364368
self.saledate, self.saleprice, self.totalsaleprice,
365369
self.buyer, self.saleplace, self.saleinfo,
366370
self.buying_invoice, self.sale_invoice,
371+
self.buying_currency, self.sale_currency,
367372
)
368373
self.externalFields = self.catalogFields + self.priceFields
369374

OpenNumismat/Collection/VersionUpdater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def update(self):
699699
self.db.transaction()
700700

701701
query = QSqlQuery(self.db)
702-
for field in ('price4', 'price6'):
702+
for field in ('price4', 'price6', 'buying_currency', 'sale_currency'):
703703
fieldDesc = getattr(self.collection.fields, field)
704704
query.prepare("INSERT INTO fields (id, title, enabled)"
705705
" VALUES (?, ?, ?)")

OpenNumismat/EditCoinDialog/BaseFormLayout.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def __init__(self, settings, field, title, itemType,
5858
self._widget = NativeYearEdit(parent)
5959
elif self._field == 'rating':
6060
self._widget = RatingEdit(settings['stars_count'], parent)
61+
elif self._field in ('buying_currency', 'sale_currency'):
62+
self._widget = CurrencyEdit(parent)
6163
else:
6264
self._widget = LineEdit(parent)
6365
elif self._type == Type.ShortString:

OpenNumismat/EditCoinDialog/DetailsTabWidget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def payLayout(self):
300300
item = self.addPayCommission()
301301

302302
layout.addRow(self.items['totalpayprice'], item)
303+
layout.addRow(self.items['buying_currency'])
303304
layout.addRow(self.items['saller'])
304305
layout.addRow(self.items['payplace'])
305306
layout.addRow(self.items['buying_invoice'])
@@ -320,6 +321,7 @@ def saleLayout(self):
320321
item = self.addSaleCommission()
321322

322323
layout.addRow(self.items['totalsaleprice'], item)
324+
layout.addRow(self.items['sale_currency'])
323325
layout.addRow(self.items['buyer'])
324326
layout.addRow(self.items['saleplace'])
325327
layout.addRow(self.items['sale_invoice'])
@@ -348,6 +350,7 @@ def passLayout(self):
348350
item = self.addSaleCommission()
349351
layout.addRow(self.items['totalsaleprice'], item)
350352

353+
layout.addRow(self.items['sale_currency'])
351354
layout.addRow(self.items['saller'])
352355
layout.addRow(self.items['buyer'])
353356
layout.addRow(self.items['saleplace'])

OpenNumismat/EditCoinDialog/FormItems.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import re
66

7-
from PySide6.QtCore import QMargins, QDate, QLocale, QPointF, QSize, QUrl
7+
from PySide6.QtCore import QMargins, QDate, QLocale, QPointF, QSize, QUrl, QT_TRANSLATE_NOOP
88
from PySide6.QtCore import Signal as pyqtSignal
99
from PySide6.QtGui import (
1010
Qt,
@@ -1336,3 +1336,56 @@ def paintEvent(self, event):
13361336

13371337
def sizeHint(self):
13381338
return self.PaintingScaleFactor * QSize(self.maxStarCount, 1)
1339+
1340+
1341+
class CurrencyEdit(QComboBox):
1342+
Currencies = (
1343+
('ARS', QT_TRANSLATE_NOOP("Currency", "ARS - Argentine peso")),
1344+
('AUD', QT_TRANSLATE_NOOP("Currency", "AUD - Australian dollar")),
1345+
('BGN', QT_TRANSLATE_NOOP("Currency", "BGN - Bulgarian lev")),
1346+
('BRL', QT_TRANSLATE_NOOP("Currency", "BRL - Brazilian real")),
1347+
('BYN', QT_TRANSLATE_NOOP("Currency", "BYN - Belarusian ruble")),
1348+
('CAD', QT_TRANSLATE_NOOP("Currency", "CAD - Canadian dollar")),
1349+
('CHF', QT_TRANSLATE_NOOP("Currency", "CHF - Swiss franc")),
1350+
('CZK', QT_TRANSLATE_NOOP("Currency", "CZK - Czech koruna")),
1351+
('EUR', QT_TRANSLATE_NOOP("Currency", "EUR - Euro")),
1352+
('GBP', QT_TRANSLATE_NOOP("Currency", "GBP - Pound sterling")),
1353+
('HUF', QT_TRANSLATE_NOOP("Currency", "HUF - Hungarian forint")),
1354+
('INR', QT_TRANSLATE_NOOP("Currency", "INR - Indian rupee")),
1355+
('NOK', QT_TRANSLATE_NOOP("Currency", "NOK - Norwegian krone")),
1356+
('PLN', QT_TRANSLATE_NOOP("Currency", "PLN - Polish złoty")),
1357+
('RUB', QT_TRANSLATE_NOOP("Currency", "RUB - Russian ruble")),
1358+
('SEK', QT_TRANSLATE_NOOP("Currency", "SEK - Swedish krona")),
1359+
('TRY', QT_TRANSLATE_NOOP("Currency", "TRY - Turkish lira")),
1360+
('UAH', QT_TRANSLATE_NOOP("Currency", "UAH - Ukrainian hryvnia")),
1361+
('USD', QT_TRANSLATE_NOOP("Currency", "USD - United States dollar")),
1362+
)
1363+
1364+
def __init__(self, parent=None):
1365+
super().__init__(parent)
1366+
self.setMinimumWidth(120)
1367+
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
1368+
1369+
self.addItem("")
1370+
for code, title in self.Currencies:
1371+
self.addItem(title, code)
1372+
1373+
def clear(self):
1374+
self.setCurrentIndex(0)
1375+
1376+
def setReadOnly(self, b):
1377+
self.setEnabled(not b)
1378+
1379+
def text(self):
1380+
return self.currentData()
1381+
1382+
def setText(self, text):
1383+
index = self.findData(text)
1384+
if index >= 0:
1385+
old_index = self.currentIndex()
1386+
self.setCurrentIndex(index)
1387+
if old_index == index:
1388+
self.currentIndexChanged.emit(index)
1389+
1390+
def home(self, _mark):
1391+
return

OpenNumismat/SettingsDialog.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,12 @@ def __init__(self, collection, parent=None):
605605
'features', 'grader', 'seat', 'rating',):
606606
coin_state_item.addChild(item)
607607
elif field.name in ('paydate', 'payprice', 'totalpayprice',
608-
'saller', 'payplace', 'payinfo', 'buying_invoice'):
608+
'saller', 'payplace', 'payinfo', 'buying_invoice',
609+
'buying_currency'):
609610
market_buy_item.addChild(item)
610611
elif field.name in ('saledate', 'saleprice', 'totalsaleprice',
611-
'buyer', 'saleplace', 'saleinfo', 'sale_invoice'):
612+
'buyer', 'saleplace', 'saleinfo', 'sale_invoice',
613+
'sale_currency'):
612614
market_sale_item.addChild(item)
613615
elif field.name in ('address', 'latitude', 'longitude'):
614616
map_item.addChild(item)

0 commit comments

Comments
 (0)