AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.04.2022, 01:03   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
How to change currency symbol in a given number format
Источник: http://alexvoy.blogspot.com/2022/04/...-in-given.html
==============

Say, we need to print a Vendor payment advice in the vendor's language, whic is es (Spanish) in the example below. Once the report parameter AX_RenderingCulture is set to 'es', all related number formatting will be applied to amounts cells.

However, the payment may be made in different currencies; thus its currency symbol $ must be used instead of Euro.






Basically, such parameters, like currency symbol etc, can be changed through System.Globalization.CultureInfo class created for the rendering culture. I did not find a way how to achieve it for a particular textbox in SSRS design. So, I formatted the amount directly in X++.




I used Global::strFmtByLanguage method as a basis for my method to replace the culture number format currency symbol to a given one. There are a few other interesting methods you can check to see how to deal with formatting dates and numbers.



///
/// Replaces language rendering culture currency symbol with the given one
///
/// language rendering culture
/// AmountCur
/// New currency symbol
/// Formatted string
public str eogChangeCurSymbolForAmountStr(LanguageId _languageId, System.Double _amountCur, CurrencySymbol _currencySymbol)
{
System.Globalization.CultureInfo culture;
str res;
System.Exception e;
str curSymbol;

culture = new System.Globalization.CultureInfo(_languageId);

try
{
res = _amountCur.ToString("C", culture);
curSymbol = culture.NumberFormat.CurrencySymbol;
res = strReplace(res, curSymbol, _currencySymbol);
}
catch(Exception::CLRError)
{
e = CLRInterop::getLastException();
while( e )
{
error( e.get_Message() );
e = e.get_InnerException();
}
throw Exception::Error;
}
return res;
}

///
/// Gets amount with currency symbol
///
/// Amount in currency
/// Currency to present symbol
/// Language for rendering culture
/// Formatted string for amunt cur with currency symbol
public EOGAmountStringWithCurrencySymbol eogAmountStringWithCurrencySymbol(AmountCur _amountCur, CurrencyCode _currency, LanguageId _languageId)
{
Currency currency = Currency::find(_currency);

return this.eogChangeCurSymbolForAmountStr(_languageId, _amountCur, currency.Symbol);;
}

///
/// Populates BankPaymAdviceVendTmp and inserts the report information for a single invoice and related payment.
///
protected void insertBankPaymAdviceTmp()
{
BankPaymAdviceVendTmp bankPaymAdviceVendTmp;
str email;

next insertBankPaymAdviceTmp();

bankPaymAdviceVendTmp = this.bankPaymAdviceTmp as BankPaymAdviceVendTmp;

if (bankPaymAdviceVendTmp.RecId)
{
ttsbegin;
bankPaymAdviceVendTmp.selectForUpdate(true);
bankPaymAdviceVendTmp.EOGBalance01Total+=bankPaymAdviceVendTmp.Balance01;
bankPaymAdviceVendTmp.EOGAmountStringWithCurrencySymbol = this.eogAmountStringWithCurrencySymbol(bankPaymAdviceVendTmp.EOGBalance01Total, bankPaymAdviceVendTmp.CurrencyCode, VendTable::find(bankPaymAdviceVendTmp.AccountNum).languageId());
bankPaymAdviceVendTmp.update();
ttscommit;
}
}



The final string can be referenced in Total textbox as Last(bankPaymAdviceVendTmp.EOGAmountStringWithCurrencySymbol) and with default format.














Источник: http://alexvoy.blogspot.com/2022/04/...-in-given.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: Changes to Microsoft Dynamics NAV Change Log System: How to Revert its Behavior Blog bot NAV: Blogs 0 23.06.2016 20:13
ax-erp: How to format your number the CLR style Blog bot DAX Blogs 0 27.04.2012 22:11
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 15:47.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.