'check if exchange rates exist for all Price List currencies (to company\'s currency)'

def validate_exchange_rates_exist(self):

    company_currency = frappe.db.get_value(u'Company', self.company, u'default_currency')
    if (not company_currency):
        msgprint(((_(u'Please    specify    currency    in    Company') + u':    ') + self.company), raise_exception=ShoppingCartSetupError)
    price_list_currency_map = frappe.db.get_values(u'Price    List', [self.price_list], u'currency')
    for (price_list, currency) in price_list_currency_map.items():
        if (not currency):
            frappe.throw(_(u'Currency    is    required    for    Price    List    {0}').format(price_list))
    expected_to_exist = [((currency + u'-') + company_currency) for currency in price_list_currency_map.values() if (currency != company_currency)]
    from_currency = [currency for currency in price_list_currency_map.values() if (currency != company_currency)]
    to_currency = company_currency
    if expected_to_exist:
        exists = frappe.db.sql_list((u'select    CONCAT(from_currency,\'-\',to_currency)    from    `tabCurrency    Exchange`\n DCTB  DCTB  DCTB  DCTB where    from_currency    in    (%s)    and    to_currency    =    "%s"    and    date    <=    curdate()' % (u',    '.join(([u'%s'] * len(from_currency))), to_currency)), tuple(from_currency))
        missing = list(set(expected_to_exist).difference(exists))
        if missing:
            msgprint(_(u'Missing    Currency    Exchange    Rates    for    {0}').format(comma_and(missing)), raise_exception=ShoppingCartSetupError)
