[freeside-commits] freeside/FS/FS Maestro.pm,1.7,1.8
Ivan,,,
ivan at wavetail.420.am
Mon Sep 20 14:13:18 PDT 2010
- Previous message: [freeside-commits] freeside/FS/FS/cust_main Billing.pm, 1.3, 1.4 Billing_Realtime.pm, 1.3, 1.4 _Marketgear.pm, NONE, 1.1 Packages.pm, NONE, 1.1
- Next message: [freeside-commits] freeside/bin xmlrpc-customer_status.pl, NONE, 1.1 xmlrpc-order_pkg.pl, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv2290/FS/FS
Modified Files:
Maestro.pm
Log Message:
Maestro.order_pkg API
Index: Maestro.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Maestro.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- Maestro.pm 12 Sep 2010 00:47:39 -0000 1.7
+++ Maestro.pm 20 Sep 2010 21:13:16 -0000 1.8
@@ -1,9 +1,12 @@
package FS::Maestro;
+use strict;
use Date::Format;
use FS::Conf;
use FS::Record qw( qsearchs );
use FS::cust_main;
+use FS::cust_pkg;
+use FS::part_svc;
sub customer_status {
my( $custnum ) = shift; #@_;
@@ -138,4 +141,103 @@
}
+#some false laziness w/ MyAccount order_pkg
+sub order_pkg {
+ my $opt = ref($_[0]) ? shift : { @_ };
+
+ $opt->{'title'} = delete $opt->{'name'}
+ if !exists($opt->{'title'}) && exists($opt->{'name'});
+
+ my $custnum = $opt->{'custnum'};
+
+ my $curuser = $FS::CurrentUser::CurrentUser;
+
+ my $cust_main = qsearchs({
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => $custnum },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql,
+ })
+ or return { 'error' => "custnum $custnum not found" };
+
+ my $status = $cust_main->status;
+ #false laziness w/ClientAPI/Signup.pm
+
+ my $cust_pkg = new FS::cust_pkg ( {
+ 'custnum' => $custnum,
+ 'pkgpart' => $opt->{'pkgpart'},
+ } );
+ my $error = $cust_pkg->check;
+ return { 'error' => $error } if $error;
+
+ my @svc = ();
+ unless ( $opt->{'svcpart'} eq 'none' ) {
+
+ my $svcpart = '';
+ if ( $opt->{'svcpart'} =~ /^(\d+)$/ ) {
+ $svcpart = $1;
+ } else {
+ $svcpart = $cust_pkg->part_pkg->svcpart; #($svcdb);
+ }
+
+ my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
+ return { 'error' => "Unknown svcpart $svcpart" } unless $part_svc;
+
+ my $svcdb = $part_svc->svcdb;
+
+ my %fields = (
+ 'svc_acct' => [ qw( username domsvc _password sec_phrase popnum ) ],
+ 'svc_domain' => [ qw( domain ) ],
+ 'svc_phone' => [ qw( phonenum pin sip_password phone_name ) ],
+ 'svc_external' => [ qw( id title ) ],
+ 'svc_pbx' => [ qw( id title ) ],
+ );
+
+ my $svc_x = "FS::$svcdb"->new( {
+ 'svcpart' => $svcpart,
+ map { $_ => $opt->{$_} } @{$fields{$svcdb}}
+ } );
+
+ #snarf processing not necessary here (or probably at all, anymore)
+
+ my $y = $svc_x->setdefault; # arguably should be in new method
+ return { 'error' => $y } if $y && !ref($y);
+
+ $error = $svc_x->check;
+ return { 'error' => $error } if $error;
+
+ push @svc, $svc_x;
+
+ }
+
+ use Tie::RefHash;
+ tie my %hash, 'Tie::RefHash';
+ %hash = ( $cust_pkg => \@svc );
+ #msgcat
+ $error = $cust_main->order_pkgs( \%hash, '', 'noexport' => 1 );
+ return { 'error' => $error } if $error;
+
+# currently they're using this in the reseller scenario, so don't
+# bill the package immediately
+# my $conf = new FS::Conf;
+# if ( $conf->exists('signup_server-realtime') ) {
+#
+# my $bill_error = _do_bop_realtime( $cust_main, $status );
+#
+# if ($bill_error) {
+# $cust_pkg->cancel('quiet'=>1);
+# return $bill_error;
+# } else {
+# $cust_pkg->reexport;
+# }
+#
+# } else {
+ $cust_pkg->reexport;
+# }
+
+ my $svcnum = $svc[0] ? $svc[0]->svcnum : '';
+
+ return { error=>'', pkgnum=>$cust_pkg->pkgnum, svcnum=>$svcnum };
+
+}
+
1;
- Previous message: [freeside-commits] freeside/FS/FS/cust_main Billing.pm, 1.3, 1.4 Billing_Realtime.pm, 1.3, 1.4 _Marketgear.pm, NONE, 1.1 Packages.pm, NONE, 1.1
- Next message: [freeside-commits] freeside/bin xmlrpc-customer_status.pl, NONE, 1.1 xmlrpc-order_pkg.pl, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list