FC for Invoice currency detection

  • 269 Views
  • Last Post 30 January 2019
Ksawa posted this 20 November 2018

Hi 

I use FC for invoice, and try to capture only currency, but it seems difficult because the amount and the currency are very close to each other. The amount and currency look like this: USD236,000

I want to separate them to its own field such as currency field (USD)and amount field(236,000). 

Does anyone know any good ideas/ tips to detect only currency? 

I tried replacing USD with "" (space), the options in the data tab in document definition, and creating an element in FCLayout. 

 

Any ideas?

Order By: Standard | Newest | Votes
Ekaterina posted this 22 November 2018

Hello,

You may filled Amount and Currency fields by script rule. Also please make sure that datatype of these fields customize correctly

Ksawa posted this 28 November 2018

Hi 

Could you describe about the currency script rule more detail? 

Do I need to write some script to separate currency and number?

ilya evdokimov posted this 04 December 2018

In FCI USA there is already a script rule called "Separate currency from amount in Total field" in the field Total.  It also sets the Currency field.  Here is the default rule:

//CurrencyHelper is declared in Rule Global Script Module

string[] possibleCurrencies = CurrencyHelper.getpossibleCurrencyValues();

string amountValue = Context.Field( "Field" ).Text;

string newAmountValue = amountValue;

string currencyValue = "";

foreach( string currency in possibleCurrencies )

{

    if( amountValue.StartsWith( currency, System.StringComparison.InvariantCultureIgnoreCase ) )

    {

        newAmountValue = amountValue.Substring( currency.Length ).Trim();

        currencyValue = currency;

        break;

    }

    if( amountValue.EndsWith( currency, System.StringComparison.InvariantCultureIgnoreCase ) )

    {

        newAmountValue = amountValue.Substring( 0, amountValue.Length - currency.Length ).Trim();

        currencyValue = currency;

        break;

    }

}

 

if( currencyValue != "" )

{

    if( Context.Field( "Currency" ).Text == "" )

    {

        Context.Field( "Currency" ).Text = currencyValue;

    }

    Context.Field( "Field" ).Text = newAmountValue;

}

Ilya Evdokimov WiseTREND

Ksawa posted this 30 January 2019

Thank you so much. 

Close