有没有更好的方法来进行以下计算sales - returns = total
?
exchange_rates = self.rates_dict
self.DBConnection.cursor.execute("SELECT royalty_price, royalty_currency FROM sales_raw WHERE provider='%s' AND sales_or_return = 'S' AND date='%s'"%(provider, self.date))
data = list(self.DBConnection.cursor.fetchall())
sales_in_usd = sum(float(price) * exchange_rates[currency] for price, currency in data)
self.DBConnection.cursor.execute("SELECT royalty_price, royalty_currency FROM sales_raw WHERE provider='%s' AND sales_or_return = 'R' AND date='%s'"%(provider, self.date))
data = list(self.DBConnection.cursor.fetchall())
returns_in_usd = sum(float(price) * exchange_rates[currency] for price, currency in data)
total_in_usd = sales_in_usd - returns_in_usd