X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fa2billing.pm;h=f6366547f11816fb2edd07db9cdf924dc689d820;hb=38e34bbc53a4222c7507e95914e1364a5a74623f;hp=0547a21d0f009427b922b19f52b16251448592f6;hpb=06fd3d9f3ca53b2d2f7595e55be4b129ca69511c;p=freeside.git diff --git a/FS/FS/part_export/a2billing.pm b/FS/FS/part_export/a2billing.pm index 0547a21d0..f6366547f 100644 --- a/FS/FS/part_export/a2billing.pm +++ b/FS/FS/part_export/a2billing.pm @@ -11,6 +11,7 @@ use FS::svc_phone; use Locale::Country qw(country_code2code); use Date::Format qw(time2str); use Carp qw( cluck ); +use FS::DBI; @ISA = qw(FS::part_export); @@ -24,7 +25,7 @@ tie %options, 'Tie::IxHash', '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' } ; @@ -55,11 +56,11 @@ END sub dbh { my $self = shift; - $self->{dbh} ||= DBI->connect( + $self->{dbh} ||= FS::DBI->connect( $self->option('datasrc'), $self->option('username'), $self->option('password') - ) or die $DBI::errstr; + ) or die $FS::DBI::errstr; $self->{dbh}->trace(1, '%%%FREESIDE_LOG%%%/a2b_exportlog.'.$self->exportnum) if $DEBUG; @@ -105,7 +106,7 @@ sub replace { ''; } -sub export_insert { +sub _export_insert { my $self = shift; my $svc = shift; my $cust_pkg = $svc->cust_svc->cust_pkg; @@ -131,7 +132,7 @@ sub export_insert { username => $username, useralias => $username, uipass => $svc->_password, - credit => $self->option('credit') || 0, + creditlimit => $cust_main->credit_limit || $self->option('credit') || 0, tariff => $part_pkg->option('a2billing_tariff'), status => 1, lastname => $cust_main->last, # $svc->finger? @@ -142,7 +143,11 @@ sub export_insert { state => $location->state, country => $country3, zipcode => $location->zip, + 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', @@ -220,9 +225,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 +243,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 @@ -278,7 +291,7 @@ sub export_insert { ''; } -sub export_delete { +sub _export_delete { my $self = shift; my $svc = shift; @@ -364,7 +377,7 @@ sub export_delete { ''; } -sub export_replace { +sub _export_replace { my $self = shift; my $new = shift; my $old = shift || $self->replace_old; @@ -396,7 +409,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) @@ -409,7 +422,7 @@ sub export_replace { ''; } -sub export_suspend { +sub _export_suspend { my $self = shift; my $svc = shift; @@ -434,7 +447,7 @@ sub export_suspend { $error || ''; } -sub export_unsuspend { +sub _export_unsuspend { my $self = shift; my $svc = shift;