From 7e5098563f4fec41ccff6c0907fc1558a5a61597 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 11 Jun 2013 00:34:19 -0700 Subject: [PATCH] multi-currency, RT#21565 --- FS/FS/cust_main.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index f3122aaa2..18ad9e337 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -58,6 +58,7 @@ use FS::cust_main_exemption; use FS::cust_tax_adjustment; use FS::cust_tax_location; use FS::agent; +use FS::agent_currency; use FS::cust_main_invoice; use FS::cust_tag; use FS::prepay_credit; @@ -1771,8 +1772,17 @@ sub check { if $error =~ /^Illegal or empty \(numeric\) refnum: /; return $error if $error; - return "Unknown agent" - unless qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); + my $agent = qsearchs( 'agent', { 'agentnum' => $self->agentnum } ) + or return "Unknown agent"; + + if ( $self->currency ) { + my $agent_currency = qsearchs( 'agent_currency', { + 'agentnum' => $agent->agentnum, + 'currency' => $self->currency, + }) + or return "Agent ". $agent->agent. + " not permitted to offer ". $self->currency. " invoicing"; + } return "Unknown refnum" unless qsearchs( 'part_referral', { 'refnum' => $self->refnum } ); -- 2.11.0