summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/AA.pm4
-rw-r--r--LedgerSMB/GL.pm4
-rw-r--r--LedgerSMB/HR.pm6
-rw-r--r--LedgerSMB/IC.pm6
-rw-r--r--LedgerSMB/IR.pm33
-rw-r--r--LedgerSMB/IS.pm4
-rw-r--r--LedgerSMB/Location.pm1
-rw-r--r--LedgerSMB/OE.pm4
-rw-r--r--LedgerSMB/OP.pm12
-rw-r--r--LedgerSMB/PE.pm6
10 files changed, 27 insertions, 53 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm
index 5a523cd0..c29652b0 100644
--- a/LedgerSMB/AA.pm
+++ b/LedgerSMB/AA.pm
@@ -42,6 +42,8 @@ sub post_transaction {
# connect to database
my $dbh = $form->{dbh};
+ $form->{invnumber} = $form->update_defaults( $myconfig, $invnumber )
+ unless $form->{invnumber};
my $query;
my $sth;
@@ -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/GL.pm b/LedgerSMB/GL.pm
index 60761cf3..26f4021f 100644
--- a/LedgerSMB/GL.pm
+++ b/LedgerSMB/GL.pm
@@ -65,6 +65,8 @@ sub delete_transaction {
sub post_transaction {
my ( $self, $myconfig, $form ) = @_;
+ $form->{reference} = $form->update_defaults( $myconfig, 'glnumber', $dbh )
+ unless $form->{reference};
my $null;
my $project_id;
@@ -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..2fbd297a 100644
--- a/LedgerSMB/HR.pm
+++ b/LedgerSMB/HR.pm
@@ -98,6 +98,9 @@ sub get_employee {
sub save_employee {
my ( $self, $myconfig, $form ) = @_;
+ $form->{employeenumber} =
+ $form->update_defaults( $myconfig, "employeenumber", $dbh )
+ if !$form->{employeenumber};
my $dbh = $form->{dbh};
my $query;
@@ -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 c34aebbd..d3db12e8 100644
--- 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';
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index 25b305a7..612c45d8 100644
--- 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_$_"} ) {
@@ -406,6 +408,8 @@ sub post_invoice {
$form->update_balance( $dbh, "invoice", "allocated",
qq|id = $ref->{id}|,
$qty * -1 );
+ $form->update_balance( $dbh, "invoice", "allocated",
+ qq|id =$invoice_id|,$qty);
$allocated += $qty;
@@ -430,33 +434,6 @@ sub post_invoice {
};
}
- $query = qq|
- UPDATE invoice
- SET trans_id = ?,
- parts_id = ?,
- description = ?,
- qty = ?,
- sellprice = ?,
- fxsellprice = ?,
- discount = ?,
- allocated = ?,
- unit = ?,
- deliverydate = ?,
- project_id = ?,
- serialnumber = ?,
- notes = ?
- WHERE id = ?|;
- $sth = $dbh->prepare($query);
- $sth->execute(
- $form->{id}, $form->{"id_$i"},
- $form->{"description_$i"}, $form->{"qty_$i"} * -1,
- $form->{"sellprice_$i"}, $fxsellprice,
- $form->{"discount_$i"}, $allocated,
- $form->{"unit_$i"}, $form->{"deliverydate_$i"},
- $project_id, $form->{"serialnumber_$i"},
- $form->{"notes_$i"}, $invoice_id
- ) || $form->dberror($query);
-
}
}
@@ -712,8 +689,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 3ffbc1ed..66977173 100644
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -804,6 +804,8 @@ sub customer_details {
sub post_invoice {
my ( $self, $myconfig, $form ) = @_;
+ $form->{invnumber} = $form->update_defaults( $myconfig, "sinumber", $dbh )
+ unless $form->{invnumber};
my $dbh = $form->{dbh};
@@ -891,8 +893,6 @@ sub post_invoice {
($exchangerate)
? $exchangerate
: $form->parse_amount( $myconfig, $form->{exchangerate} );
- $form->{invnumber} = $form->update_defaults( $myconfig, "sinumber", $dbh )
- unless $form->{invnumber};
my $i;
my $item;
diff --git a/LedgerSMB/Location.pm b/LedgerSMB/Location.pm
index fd878774..cbd2fe9e 100644
--- a/LedgerSMB/Location.pm
+++ b/LedgerSMB/Location.pm
@@ -1,4 +1,3 @@
-
=head1 NAME
LedgerSMB::Location - LedgerSMB class for managing Business Locations
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm
index a2959d4b..2bcdbdbb 100644
--- a/LedgerSMB/OE.pm
+++ b/LedgerSMB/OE.pm
@@ -253,7 +253,6 @@ sub save {
"currency", "department_id", "employee_id", "language_code",
"ponumber", "terms"
);
-
# connect to database, turn off autocommit
my $dbh = $form->{dbh};
my @queryargs;
@@ -277,11 +276,12 @@ sub save {
? "sqnumber"
: "rfqnumber";
}
-
$form->{"$ordnumber"} =
$form->update_defaults( $myconfig, $numberfld, $dbh )
unless $form->{ordnumber};
+
+
my $query;
my $sth;
my $null;
diff --git a/LedgerSMB/OP.pm b/LedgerSMB/OP.pm
index 962011de..4b8d9121 100644
--- a/LedgerSMB/OP.pm
+++ b/LedgerSMB/OP.pm
@@ -37,6 +37,12 @@ package OP;
sub overpayment {
my ( $self, $myconfig, $form, $dbh, $amount, $ml ) = @_;
+ my $invnumber = $form->{invnumber};
+ $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};
@@ -57,12 +63,6 @@ sub overpayment {
$query = qq|SELECT id FROM $form->{arap} WHERE invnumber = '$uid'|;
($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 100644
--- 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