Change regex to handle currency conversation USD hint.

I found a ticket today with payment-amount set as:

   "CUR AMOUNT ($OTHER_AMOUNT)"

Since the field is free-from I figured I probably need to accept
this.
This commit is contained in:
Bradley M. Kuhn 2020-09-15 10:50:35 -07:00
parent 927bb55547
commit 7d24d42788

View file

@ -60,7 +60,8 @@ sub FindMostRecentPaymentMethodForTicket ($) {
chomp $curAndAmount; $curAndAmount =~ s/^\s*cf.\{payment-amount\}\s*:\s+(.*)$/$1/i;
$ticketSpec =~ s%^\s*ticket\s*/\s*%%;
$curAndAmount = "USD -32767.69" if not defined $curAndAmount;
$curAndAmount =~ /^\s*([A-Z]{3,3})\s+([\-\d\,\.]+)\s*$/ or die "Ticket, $ticketSpec, has amount of $curAndAmount";
$curAndAmount =~ /^\s*([A-Z]{3,3})\s+([\-\d\,\.]+)(\s+\(\s*\$\s*[\-\d\,\.]+\s*\))?\s*$/
or die "Ticket, $ticketSpec, has amount of $curAndAmount";
($AMOUNTS{$ticketSpec}{currency}, $AMOUNTS{$ticketSpec}{amount}) = ($1, $2);
$AMOUNTS{$ticketSpec}{amount} =~ s/\$//g; $AMOUNTS{$ticketSpec}{amount} =~ s/,//g;
$AMOUNTS{$ticketSpec}{currency} =~ s/\s//g;