How to know the currency of a field?

Hi everyone,

I need to access the currency type (ISO 4217) of a currency field because I need to print it in a pdf. I'm using the pdf manager to get the values of the fields from the actual record. Is there a way to get the currency type from the pdf manager?

Parents
  • There is no easy way...

    There is only one currency per record, its id is in currency_id

    The PDF amounts are formatted using the currency symbol rather than the currency's ISO4217

    It would be really nice if there was a choice on which to use in the PDFs.

    The only way I can think of to do what you need is to add a custom field to your module to hold that value, then include it in your PDF using smarty to format the amount without a symbol.

    So your before_save logic hook will have something like:

     

    if ($bean->currency_id == '-99'){
        $bean->reporting_currency_c = 'USD';
    }else{
        $currencyBean = BeanFactory::retrieveBean('Currencies', $bean->currency_id);
        $bean->reporting_currency_c = $currencyBean->iso4217;
    }

    Note that your default currency has ID -99, for us that's USD

    Hope this helps,
    FrancescaS

Reply
  • There is no easy way...

    There is only one currency per record, its id is in currency_id

    The PDF amounts are formatted using the currency symbol rather than the currency's ISO4217

    It would be really nice if there was a choice on which to use in the PDFs.

    The only way I can think of to do what you need is to add a custom field to your module to hold that value, then include it in your PDF using smarty to format the amount without a symbol.

    So your before_save logic hook will have something like:

     

    if ($bean->currency_id == '-99'){
        $bean->reporting_currency_c = 'USD';
    }else{
        $currencyBean = BeanFactory::retrieveBean('Currencies', $bean->currency_id);
        $bean->reporting_currency_c = $currencyBean->iso4217;
    }

    Note that your default currency has ID -99, for us that's USD

    Hope this helps,
    FrancescaS

Children