[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4344] trunk
- Subject: SF.net SVN: ledger-smb:[4344] trunk
- From: ..hidden..
- Date: Thu, 23 Feb 2012 01:32:19 +0000
Revision: 4344
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4344&view=rev
Author: einhverfr
Date: 2012-02-23 01:32:19 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
Moving from Error to Try::Tiny, and adding error output calls. Now we can use die ->text('This is an error') to throw errors in a more generic way.
Modified Paths:
--------------
trunk/Changelog
trunk/LedgerSMB/DBObject/Business_Unit.pm
trunk/LedgerSMB/DBObject_Moose.pm
trunk/LedgerSMB/PGDate.pm
trunk/LedgerSMB/Scripts/business_unit.pm
trunk/UI/business_units/edit.html
trunk/UI/business_units/list_classes.html
trunk/lsmb-request.pl
trunk/old-handler.pl
Modified: trunk/Changelog
===================================================================
--- trunk/Changelog 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/Changelog 2012-02-23 01:32:19 UTC (rev 4344)
@@ -9,6 +9,7 @@
* Project/department mechanism generalized to support funds, etc (Chris T)
* Removed the Config::Std dependency and moved to Config::General (Chris T)
* Merged in transaction import add-on for 1.4, also for other csv's (Chris T)
+* Improved error handling using Try::Tiny and die (Chris T)
New Business Reporting Unit System (Chris T)
* Replaces Projects and Departments
Modified: trunk/LedgerSMB/DBObject/Business_Unit.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Business_Unit.pm 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/LedgerSMB/DBObject/Business_Unit.pm 2012-02-23 01:32:19 UTC (rev 4344)
@@ -27,7 +27,7 @@
=cut
-has 'id' => (is => 'rw', isa => 'Int');
+has 'id' => (is => 'rw', isa => 'Maybe[Int]');
=item class_id
@@ -61,7 +61,7 @@
=cut
-has 'start_date' => (is => 'rw', isa => 'LedgerSMB::PGDate');
+has 'start_date' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
=item end_date
@@ -70,7 +70,7 @@
=cut
-has 'end_date' => (is => 'rw', isa => 'LedgerSMB::PGDate');
+has 'end_date' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
=item parent_id
Modified: trunk/LedgerSMB/DBObject_Moose.pm
===================================================================
--- trunk/LedgerSMB/DBObject_Moose.pm 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/LedgerSMB/DBObject_Moose.pm 2012-02-23 01:32:19 UTC (rev 4344)
@@ -144,6 +144,13 @@
for (@in_args) { push @call_args, $_ } ;
$self->{call_args} = ..hidden..;
$logger->debug("exec_method: \$self = " . Data::Dumper::Dumper($self));
+ for my $arg(@call_args){
+ if (isa('LedgerSMB::PGDate', $arg) or
+ isa('LedgerSMB::PGNumber', $arg)){
+ $arg = $arg->to_db;
+ }
+ }
+
return $self->call_procedure( procname => $funcname,
args => ..hidden..,
order_by => $self->{_order_method}->{"$funcname"},
@@ -151,6 +158,13 @@
continue_on_error => $args{continue_on_error});
}
else {
+ for my $arg(@in_args){
+ if (isa('LedgerSMB::PGDate', $arg) or
+ isa('LedgerSMB::PGNumber', $arg)){
+ $arg = $arg->to_db;
+ }
+ }
+
return $self->call_procedure( procname => $funcname,
args => ..hidden..,
order_by => $self->{_order_method}->{"$funcname"},
Modified: trunk/LedgerSMB/PGDate.pm
===================================================================
--- trunk/LedgerSMB/PGDate.pm 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/LedgerSMB/PGDate.pm 2012-02-23 01:32:19 UTC (rev 4344)
@@ -152,8 +152,8 @@
sub from_input{
my ($self, $input, $has_time) = @_;
- my $format = $LedgerSMB::App_State::User->dateformat;
- my $dt = _parse_string($self, $input, $format, $has_time);
+ my $format = $LedgerSMB::App_State::User->{dateformat};
+ my $dt = _parse_string($self, $input, uc($format), $has_time);
return $self->new({date => $dt});
}
Modified: trunk/LedgerSMB/Scripts/business_unit.pm
===================================================================
--- trunk/LedgerSMB/Scripts/business_unit.pm 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/LedgerSMB/Scripts/business_unit.pm 2012-02-23 01:32:19 UTC (rev 4344)
@@ -48,6 +48,19 @@
sub add {
my ($request) = @_;
+ if (!$request->{class_id}){
+ $request->{class_id} = $request->{id};
+ }
+ $request->{id} = undef;
+ my $template = LedgerSMB::Template->new(
+ user =>$request->{_user},
+ locale => $request->{_locale},
+ path => 'UI/business_units',
+ template => 'edit',
+ format => 'HTML'
+ );
+ $template->render($request);
+
}
@@ -133,7 +146,12 @@
sub save {
my ($request) = @_;
+ $request->{start_date} = LedgerSMB::PGDate->from_input($request->{start_date}, 0)
+ if defined $request->{start_date};
+ $request->{end_date} = LedgerSMB::PGDate->from_input($request->{end_date}, 0)
+ if defined $request->{end_date};
my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
+ my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
$unit->save;
edit($request);
}
Modified: trunk/UI/business_units/edit.html
===================================================================
--- trunk/UI/business_units/edit.html 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/UI/business_units/edit.html 2012-02-23 01:32:19 UTC (rev 4344)
@@ -18,7 +18,7 @@
name = "control_code"
value = control_code
label = text('Control Code') #'
- size = 32
+ size = 16
} ?>
<?lsmb PROCESS select element_data = {
label = text('Parent')
@@ -36,6 +36,7 @@
label = text("Start Date") #"
type = "text"
value = start_date
+ size = 12
} ?>
<?lsmb PROCESS input element_data = {
name = "end_date"
@@ -43,6 +44,7 @@
label = text("End Date") #"
type = "text"
value = end_date
+ size = 12
} ?>
</div>
</div>
@@ -73,10 +75,10 @@
type = "submit"
class = "submit"
name = "action"
- value = "asset_save"
+ value = "save"
} ?>
</div>
-<?lsmb PROCESS inout element_data = {
+<?lsmb PROCESS input element_data = {
type = "hidden"
name = "class_id"
value = class_id
Modified: trunk/UI/business_units/list_classes.html
===================================================================
--- trunk/UI/business_units/list_classes.html 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/UI/business_units/list_classes.html 2012-02-23 01:32:19 UTC (rev 4344)
@@ -68,7 +68,7 @@
type = "submit"
class = "submit"
name = "action"
- value = "delete"
+ value = "delete_class"
text = text('Delete')
} ?>
</td>
@@ -85,7 +85,7 @@
type = "submit"
class = "submit"
name = "action"
- value = "delete"
+ value = "list"
text = text('List Units')#'
};
END; ?>
Modified: trunk/lsmb-request.pl
===================================================================
--- trunk/lsmb-request.pl 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/lsmb-request.pl 2012-02-23 01:32:19 UTC (rev 4344)
@@ -22,7 +22,7 @@
use LedgerSMB::Sysconfig;
use Digest::MD5;
-use Error qw(:try);
+use Try::Tiny;
$| = 1;
@@ -106,9 +106,8 @@
|| $request->error($locale->text("Action Not Defined: ") . $request->{action});
$script->can( $request->{action} )->($request);
}
- catch CancelFurtherProcessing with {
- my $ex = shift;
- $logger->debug("CancelFurtherProcessing \$ex=$ex");
+ catch {
+ $request->error($_);
};
}
1;
Modified: trunk/old-handler.pl
===================================================================
--- trunk/old-handler.pl 2012-02-22 11:13:29 UTC (rev 4343)
+++ trunk/old-handler.pl 2012-02-23 01:32:19 UTC (rev 4344)
@@ -48,7 +48,7 @@
use LedgerSMB::Sysconfig;
use Digest::MD5;
-use Error qw(:try);
+use Try::Tiny;
$| = 1;
@@ -168,8 +168,8 @@
}
}
-catch CancelFurtherProcessing with {
- my $ex = shift;
+catch {
+ $form->error($_);
};
$logger->trace("leaving after script=bin/$form->{script} action=$form->{action}");#trace flow
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.