X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fa2billing.pm;h=15410aebfec47ab353d7b5f5f8066c6f2795b285;hp=52680dc175d6e4986dc0d9ab691b7c81ed7af535;hb=674cb2d9d7105f4cc2871539b2e9f7088cdaa750;hpb=af12e29224dd69ef1d577c5e9943644feafe5525 diff --git a/FS/FS/part_export/a2billing.pm b/FS/FS/part_export/a2billing.pm index 52680dc17..15410aebf 100644 --- a/FS/FS/part_export/a2billing.pm +++ b/FS/FS/part_export/a2billing.pm @@ -21,11 +21,10 @@ tie %options, 'Tie::IxHash', 'username' => { label=>'Database username' }, 'password' => { label=>'Database password' }, 'didgroup' => { label=>'DID group ID', default=>1 }, - 'tariffgroup' => { label=>'Tariff group ID', default=>1 }, 'credit' => { label=>'Default credit limit' }, 'billtype' => {label=>'Billing type', type => 'select', - options => ['monthly', 'weekly'] + options => ['Dial Out Rate', 'Free'] }, 'debug' => { label=>'Enable debugging', type=>'checkbox' } ; @@ -112,6 +111,7 @@ sub export_insert { my $cust_pkg = $svc->cust_svc->cust_pkg; my $cust_main = $cust_pkg->cust_main; my $location = $cust_pkg->cust_location; + my $part_pkg = $cust_pkg->part_pkg; my $error; $DEBUG ||= $self->option('debug'); @@ -131,9 +131,8 @@ sub export_insert { username => $username, useralias => $username, uipass => $svc->_password, - # XXX these options may move to a part_pkg at some point - credit => $self->option('credit') || 0, - tariff => $self->option('tariffgroup'), + creditlimit => $cust_main->credit_limit || $self->option('credit') || 0, + tariff => $part_pkg->option('a2billing_tariff'), status => 1, lastname => $cust_main->last, # $svc->finger? firstname => $cust_main->first, @@ -143,9 +142,14 @@ sub export_insert { state => $location->state, country => $country3, zipcode => $location->zip, - typepaid => 1, + simultaccess => $part_pkg->option('a2billing_simultaccess'), + typepaid => $part_pkg->option('a2billing_type'), + email_notification => $cust_main->invoicing_list_emailonly_scalar, + notify_email => ($cust_main->invoicing_list_emailonly_scalar ? 1 : 0), + credit_notification => $cust_main->credit_limit || $self->option('credit') || 0, sip_buddy => 1, company_name => $cust_main->company, + activated => 't', ); warn "creating A2B cc_card record for $username\n" if $DEBUG; $error = $self->a2b_insert_or_replace('cc_card', 'svcnum', \%cc_card); @@ -220,9 +224,15 @@ sub export_insert { id_cc_didgroup => $self->option('didgroup'), id_cc_country => $cc_country_id, iduser => $cc_card_id, - did => $svc->phonenum, - billingtype => ($self->option('billtype') eq 'weekly' ? 1 : 0), + did => $svc->countrycode. $svc->phonenum, + billingtype => ($self->option('billtype') eq 'Dial Out Rate' ? 2 : 3), activated => 1, + aleg_carrier_cost_min_offp => $part_pkg->option('a2billing_carrier_cost_min'), + aleg_carrier_initblock_offp => $part_pkg->option('a2billing_carrier_initblock_offp'), + aleg_carrier_increment_offp => $part_pkg->option('a2billing_carrier_increment_offp'), + aleg_retail_cost_min_offp => $part_pkg->option('a2billing_retail_cost_min_offp'), + aleg_retail_initblock_offp => $part_pkg->option('a2billing_retail_initblock_offp'), + aleg_retail_increment_offp => $part_pkg->option('a2billing_retail_increment_offp'), ); # use 'did' as the key here so that if the DID already exists, we @@ -232,12 +242,14 @@ sub export_insert { my $cc_did_id = $self->a2b_find('cc_did', 'svcnum', $svc->svcnum); - my $destination = 'SIP/' . $svc->phonenum . '@' . $svc_acct->username; + my $destination = 'SIP/user-'. $svc_acct->username. '@'. $svc->sip_server. "!". $svc->countrycode. $svc->phonenum; my %cc_did_destination = ( destination => $destination, priority => 1, id_cc_card => $cc_card_id, id_cc_did => $cc_did_id, + validated => 1, + voip_call => 1, ); # and if there's already a destination, change it to point to @@ -396,7 +408,7 @@ sub export_replace { } elsif ( $new->isa('FS::svc_phone') ) { # if the phone number has changed, need to create a new DID. - if ( $new->phonenum ne $old->phonenum ) { + if ( $new->phonenum ne $old->phonenum || $new->countrycode ne $old->countrycode ) { # deactivate/unlink/close the old DID # and create/link the new one $error = $self->export_delete($old) @@ -444,7 +456,7 @@ sub export_unsuspend { if ( $svc->isa('FS::svc_acct') ) { $error = $self->a2b_insert_or_replace('cc_card', 'svcnum', { svcnum => $svc->svcnum, - status => 0, #"ACTIVE" + status => 1, #"ACTIVE" activated => 1, } );