summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB/AA.pm4
-rwxr-xr-xLedgerSMB/CT.pm12
-rwxr-xr-xLedgerSMB/GL.pm4
-rwxr-xr-xLedgerSMB/HR.pm6
-rwxr-xr-xLedgerSMB/IC.pm15
-rwxr-xr-xLedgerSMB/IR.pm4
-rwxr-xr-xLedgerSMB/IS.pm4
-rwxr-xr-xLedgerSMB/OE.pm12
-rwxr-xr-xLedgerSMB/OP.pm10
-rwxr-xr-xLedgerSMB/PE.pm6
10 files changed, 36 insertions, 41 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm
index 3f8b35af..bca7f391 100755
--- a/LedgerSMB/AA.pm
+++ b/LedgerSMB/AA.pm
@@ -39,6 +39,8 @@ use LedgerSMB::Sysconfig;
sub post_transaction {
my ( $self, $myconfig, $form ) = @_;
+ $form->{invnumber} = $form->update_defaults( $myconfig, $invnumber )
+ unless $form->{invnumber};
# connect to database
my $dbh = $form->{dbh};
@@ -286,8 +288,6 @@ sub post_transaction {
$form->{datepaid} = $form->{transdate} unless $form->{datepaid};
my $datepaid = ($paid) ? qq|'$form->{datepaid}'| : 'NOW';
- $form->{invnumber} = $form->update_defaults( $myconfig, $invnumber )
- unless $form->{invnumber};
$query = qq|
UPDATE $table
diff --git a/LedgerSMB/CT.pm b/LedgerSMB/CT.pm
index e40b3336..636d645f 100755
--- a/LedgerSMB/CT.pm
+++ b/LedgerSMB/CT.pm
@@ -208,6 +208,9 @@ sub save_customer {
my $sth;
my $null;
+ $form->{customernumber} =
+ $form->update_defaults( $myconfig, "customernumber", $dbh )
+ if !$form->{customernumber};
# remove double spaces
$form->{name} =~ s/ / /g;
@@ -301,9 +304,6 @@ sub save_customer {
my $language_code;
( $null, $language_code ) = split /--/, $form->{language};
- $form->{customernumber} =
- $form->update_defaults( $myconfig, "customernumber", $dbh )
- if !$form->{customernumber};
$query = qq|
UPDATE customer
@@ -388,6 +388,9 @@ sub save_vendor {
# connect to database
my $dbh = $form->{dbh};
+ $form->{vendornumber} =
+ $form->update_defaults( $myconfig, "vendornumber", $dbh )
+ if !$form->{vendornumber};
my $query;
my $sth;
@@ -476,9 +479,6 @@ sub save_vendor {
my $language_code;
( $null, $language_code ) = split /--/, $form->{language};
- $form->{vendornumber} =
- $form->update_defaults( $myconfig, "vendornumber", $dbh )
- if !$form->{vendornumber};
$form->{startdate} = undef unless $form->{startdate};
$form->{enddate} = undef unless $form->{enddate};
diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm
index a3e10b8b..03b6d678 100755
--- a/LedgerSMB/GL.pm
+++ b/LedgerSMB/GL.pm
@@ -70,6 +70,8 @@ sub post_transaction {
my $project_id;
my $department_id;
my $i;
+ $form->{reference} = $form->update_defaults( $myconfig, 'glnumber', $dbh )
+ unless $form->{reference};
# connect to database, turn off AutoCommit
my $dbh = $form->{dbh};
@@ -117,8 +119,6 @@ sub post_transaction {
( $null, $department_id ) = split /--/, $form->{department};
$department_id *= 1;
- $form->{reference} = $form->update_defaults( $myconfig, 'glnumber', $dbh )
- unless $form->{reference};
$form->{reference} ||= $form->{id};
$query = qq|
diff --git a/LedgerSMB/HR.pm b/LedgerSMB/HR.pm
index 105a4365..4f1f4dab 100755
--- a/LedgerSMB/HR.pm
+++ b/LedgerSMB/HR.pm
@@ -102,6 +102,9 @@ sub save_employee {
my $dbh = $form->{dbh};
my $query;
my $sth;
+ $form->{employeenumber} =
+ $form->update_defaults( $myconfig, "employeenumber", $dbh )
+ if !$form->{employeenumber};
if ( !$form->{id} ) {
my $uid = localtime;
@@ -124,9 +127,6 @@ sub save_employee {
$managerid *= 1;
$form->{sales} *= 1;
- $form->{employeenumber} =
- $form->update_defaults( $myconfig, "employeenumber", $dbh )
- if !$form->{employeenumber};
$query = qq|
UPDATE employee
diff --git a/LedgerSMB/IC.pm b/LedgerSMB/IC.pm
index 3132a8a7..749a94e3 100755
--- a/LedgerSMB/IC.pm
+++ b/LedgerSMB/IC.pm
@@ -204,6 +204,9 @@ sub get_part {
sub save {
my ( $self, $myconfig, $form ) = @_;
+ $form->{partnumber} =
+ $form->update_defaults( $myconfig, "partnumber", $dbh )
+ if !$form->{partnumber};
( $form->{inventory_accno} ) = split( /--/, $form->{IC_inventory} );
( $form->{expense_accno} ) = split( /--/, $form->{IC_expense} );
@@ -378,9 +381,6 @@ sub save {
( $null, $partsgroup_id ) = split /--/, $form->{partsgroup};
$partsgroup_id *= 1;
- $form->{partnumber} =
- $form->update_defaults( $myconfig, "partnumber", $dbh )
- if !$form->{partnumber};
if ( !$form->{priceupdate} ) {
$form->{priceupdate} = 'now';
@@ -1599,13 +1599,8 @@ sub include_assembly {
$form->{$id} = 1;
my @a = qw(partnumber description bin);
- if ( $form->{sort} eq 'partnumber' ) {
- $sortorder = "TRUE";
- }
- else {
- @a = grep !/$form->{sort}/, @a;
- $sortorder = "$form->{sort} $form->{direction}, " . join ',', @a;
- }
+ @a = grep !/$form->{sort}/, @a;
+ $sortorder = "$form->{sort} $form->{direction}, " . join ',', @a;
@a = ();
my $query = qq|
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index 709d5dcf..c79b3b33 100755
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -41,6 +41,8 @@ sub post_invoice {
my ( $self, $myconfig, $form ) = @_;
my $dbh = $form->{dbh};
+ $form->{invnumber} = $form->update_defaults( $myconfig, "vinumber", $dbh )
+ unless $form->{invnumber};
for ( 1 .. $form->{rowcount} ) {
unless ( $form->{"deliverydate_$_"} ) {
@@ -671,8 +673,6 @@ sub post_invoice {
# set values which could be empty
$form->{taxincluded} *= 1;
- $form->{invnumber} = $form->update_defaults( $myconfig, "vinumber", $dbh )
- unless $form->{invnumber};
# save AP record
$query = qq|
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm
index 8368c986..820024b9 100755
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -808,6 +808,8 @@ sub post_invoice {
my ( $self, $myconfig, $form ) = @_;
my $dbh = $form->{dbh};
+ $form->{invnumber} = $form->update_defaults( $myconfig, "sinumber", $dbh )
+ unless $form->{invnumber};
my $query;
my $sth;
@@ -1368,8 +1370,6 @@ sub post_invoice {
$form->{terms} *= 1;
$form->{taxincluded} *= 1;
- $form->{invnumber} = $form->update_defaults( $myconfig, "sinumber", $dbh )
- unless $form->{invnumber};
# save AR record
$query = qq|
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm
index fddd0fd2..26934f04 100755
--- a/LedgerSMB/OE.pm
+++ b/LedgerSMB/OE.pm
@@ -246,6 +246,9 @@ sub transactions {
sub save {
my ( $self, $myconfig, $form ) = @_;
+ $form->{"$ordnumber"} =
+ $form->update_defaults( $myconfig, $numberfld, $dbh )
+ unless $form->{ordnumber};
$form->db_prepare_vars(
"quonumber", "transdate", "vendor_id", "customer_id",
@@ -278,9 +281,6 @@ sub save {
: "rfqnumber";
}
- $form->{"$ordnumber"} =
- $form->update_defaults( $myconfig, $numberfld, $dbh )
- unless $form->{ordnumber};
my $query;
my $sth;
@@ -2298,6 +2298,7 @@ sub generate_orders {
foreach $vendor_id ( keys %a ) {
%tax = ();
+ my $ordnumber = $form->update_defaults( $myconfig, 'ponumber' );
$query = qq|
SELECT v.curr, v.taxincluded, t.rate, c.accno
@@ -2401,7 +2402,6 @@ sub generate_orders {
}
- my $ordnumber = $form->update_defaults( $myconfig, 'ponumber' );
my $null;
my $employee_id;
@@ -2519,6 +2519,8 @@ sub consolidate_orders {
$form->{"$form->{vc}_id"} = $vc_id;
$amount = 0;
$netamount = 0;
+ $ordnumber ||=
+ $form->update_defaults( $myconfig, $numberfld, $dbh );
foreach $id ( @{ $oe{orders}{$curr}{$vc_id} } ) {
@@ -2549,8 +2551,6 @@ sub consolidate_orders {
$dbh->do($query) || $form->dberror($query);
}
- $ordnumber ||=
- $form->update_defaults( $myconfig, $numberfld, $dbh );
#fixme: Change this
$query = qq|
diff --git a/LedgerSMB/OP.pm b/LedgerSMB/OP.pm
index 3a07f036..f5592086 100755
--- a/LedgerSMB/OP.pm
+++ b/LedgerSMB/OP.pm
@@ -37,6 +37,11 @@ package OP;
sub overpayment {
my ( $self, $myconfig, $form, $dbh, $amount, $ml ) = @_;
+ $invnumber =
+ $form->update_defaults( $myconfig, ( $form->{arap} eq 'ar' )
+ ? "sinumber"
+ : "vinumber", $dbh )
+ unless $invnumber;
my $fxamount = $form->round_amount( $amount * $form->{exchangerate}, 2 );
my ($paymentaccno) = split /--/, $form->{account};
@@ -58,11 +63,6 @@ sub overpayment {
($uid) = $dbh->selectrow_array($query);
my $invnumber = $form->{invnumber};
- $invnumber =
- $form->update_defaults( $myconfig, ( $form->{arap} eq 'ar' )
- ? "sinumber"
- : "vinumber", $dbh )
- unless $invnumber;
$query = qq|
UPDATE $form->{arap}
diff --git a/LedgerSMB/PE.pm b/LedgerSMB/PE.pm
index 377a1c52..fa3bcb8b 100755
--- a/LedgerSMB/PE.pm
+++ b/LedgerSMB/PE.pm
@@ -568,6 +568,9 @@ sub get_customer {
sub save_job {
my ( $self, $myconfig, $form ) = @_;
+ $form->{projectnumber} =
+ $form->update_defaults( $myconfig, "projectnumber", $dbh )
+ unless $form->{projectnumber};
my $dbh = $form->{dbh};
@@ -597,9 +600,6 @@ sub save_job {
( $form->{id} ) = $dbh->selectrow_array($query);
}
- $form->{projectnumber} =
- $form->update_defaults( $myconfig, "projectnumber", $dbh )
- unless $form->{projectnumber};
$query = qq|
UPDATE project