def currency_formatter(input, organization): if organization != None: for payment_info in organization.organizationpaymentinfo_set.all(): return payment_info.currency.convert_display(input) else: currency_obj = Currency(order=1, name="USD") return currency_obj.convert_display(input)
def currency_formatter(self, input, organization): from atrinsic.base.models import Currency, Organization if organization != None and isinstance(organization, Organization): currency_obj = Currency(order=1, name=self.currency) if (self.currency == None) | (self.exchange_rate == None): self.currency = organization.organizationpaymentinfo_set.all( )[0].currency.name self.currency_obj = Currency(order=1, name=self.currency) self.exchange_rate = self.currency_obj.get_exchange_rate( self.currency) return currency_obj.convert_display_v2(input, float(self.exchange_rate), self.currency) else: currency_obj = Currency(order=1, name="USD") if self.currency == None: self.currency = 'USD' if self.exchange_rate == None: self.exchange_rate = currency_obj.get_exchange_rate( self.currency) return currency_obj.convert_display_v2(input, float(self.exchange_rate), self.currency)