Ejemplo n.º 1
0
	def set_price_list_currency(self, buying_or_selling):
		company_currency = get_company_currency(self.doc.company)
		fieldname = buying_or_selling.lower() + "_price_list"
		
		# TODO - change this, since price list now has only one currency allowed
		if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
			self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname)))
				
			if self.doc.price_list_currency:
				if self.doc.price_list_currency == company_currency:
					self.doc.plc_conversion_rate = 1.0
				elif not self.doc.plc_conversion_rate or \
						(flt(self.doc.plc_conversion_rate)==1 and company_currency!= self.doc.price_list_currency):
					exchange = self.doc.price_list_currency + "-" + company_currency
					self.doc.plc_conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
						exchange, "exchange_rate"))
					
				if not self.doc.currency:
					self.doc.currency = self.doc.price_list_currency
					self.doc.conversion_rate = self.doc.plc_conversion_rate
						
		if self.meta.get_field("currency"):
			if self.doc.currency and self.doc.currency != company_currency:
				if not self.doc.conversion_rate:
					exchange = self.doc.currency + "-" + company_currency
					self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
						exchange, "exchange_rate"))
			else:
				self.doc.conversion_rate = 1
Ejemplo n.º 2
0
    def set_price_list_currency(self, buying_or_selling):
        company_currency = get_company_currency(self.doc.company)
        fieldname = buying_or_selling.lower() + "_price_list"

        # TODO - change this, since price list now has only one currency allowed
        if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
            if not self.doc.price_list_currency:
                self.doc.fields.update(
                    get_price_list_currency(self.doc.fields.get(fieldname)))

            if self.doc.price_list_currency:
                if self.doc.price_list_currency == company_currency:
                    self.doc.plc_conversion_rate = 1.0
                elif not self.doc.plc_conversion_rate:
                    exchange = self.doc.price_list_currency + "-" + company_currency
                    self.doc.plc_conversion_rate = flt(
                        webnotes.conn.get_value("Currency Exchange", exchange,
                                                "exchange_rate"))

                if not self.doc.currency:
                    self.doc.currency = self.doc.price_list_currency
                    self.doc.conversion_rate = self.doc.plc_conversion_rate

        if self.meta.get_field("currency"):
            if self.doc.currency and self.doc.currency != company_currency:
                if not self.doc.conversion_rate:
                    exchange = self.doc.currency + "-" + company_currency
                    self.doc.conversion_rate = flt(
                        webnotes.conn.get_value("Currency Exchange", exchange,
                                                "exchange_rate"))
            else:
                self.doc.conversion_rate = 1
Ejemplo n.º 3
0
	def set_price_list_currency(self, buying_or_selling):
		company_currency = get_company_currency(self.doc.company)
		# TODO - change this, since price list now has only one currency allowed
		if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
			not self.doc.price_list_currency:
				self.doc.fields.update(get_price_list_currency(self.doc.price_list_name))
				
				if self.doc.price_list_currency:
					if not self.doc.plc_conversion_rate:
						if self.doc.price_list_currency == company_currency:
							self.doc.plc_conversion_rate = 1.0
						else:
							exchange = self.doc.price_list_currency + "-" + company_currency
							self.doc.plc_conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
								exchange, "exchange_rate"))
						
					if not self.doc.currency:
						self.doc.currency = self.doc.price_list_currency
						self.doc.conversion_rate = self.doc.plc_conversion_rate
						
		if self.meta.get_field("currency") and self.doc.currency != company_currency and \
			not self.doc.conversion_rate:
				exchange = self.doc.currency + "-" + company_currency
				self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
					exchange, "exchange_rate"))