summaryrefslogtreecommitdiff
path: root/LedgerSMB/IR.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-02 23:40:18 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-02 23:40:18 +0000
commita2c93e1cde65e60b17e0204183033896cca70a4f (patch)
tree9149305e89ba89f7ab7c9983eb3495cf63badf6a /LedgerSMB/IR.pm
parent050d1f5d21a22e79ea575c182164540e6fb5d6da (diff)
Broke out price matrix logic (warning, this is untested but cannot test from
this machine so will be tested tonight) git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@183 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/IR.pm')
-rwxr-xr-xLedgerSMB/IR.pm42
1 files changed, 5 insertions, 37 deletions
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index b2acfa72..92e2c964 100755
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -32,7 +32,7 @@
#======================================================================
package IR;
-
+use LedgerSMB::PriceMatrix;
sub post_invoice {
my ($self, $myconfig, $form) = @_;
@@ -850,11 +850,7 @@ sub retrieve_invoice {
&exchangerate_defaults($dbh, $form);
# price matrix and vendor partnumber
- $query = qq|SELECT partnumber
- FROM partsvendor
- WHERE parts_id = ?
- AND vendor_id = $form->{vendor_id}|;
- my $pmh = $dbh->prepare($query) || $form->dberror($query);
+ my $pmh = PriceMatrix::PriceMatrixQuery($dbh, $form);
# tax rates for part
$query = qq|SELECT c.accno
@@ -885,7 +881,7 @@ sub retrieve_invoice {
# price matrix
$ref->{sellprice} = $form->round_amount($ref->{fxsellprice} * $form->{$form->{currency}}, $decimalplaces);
- &price_matrix($pmh, $ref, $decimalplaces, $form);
+ PriceMatrix::price_matrix($pmh, $ref, $decimalplaces, $form, $myconfig);
$ref->{sellprice} = $ref->{fxsellprice};
$ref->{qty} *= -1;
@@ -974,11 +970,7 @@ sub retrieve_item {
my $tth = $dbh->prepare($query) || $form->dberror($query);
# price matrix
- $query = qq|SELECT p.*
- FROM partsvendor p
- WHERE p.parts_id = ?
- AND vendor_id = $form->{vendor_id}|;
- my $pmh = $dbh->prepare($query) || $form->dberror($query);
+ my $pmh = PriceMatrix::price_matrix_query($dbh, $form);
my $ref;
my $ptref;
@@ -1000,7 +992,7 @@ sub retrieve_item {
chop $ref->{taxaccounts};
# get vendor price and partnumber
- &price_matrix($pmh, $ref, $decimalplaces, $form);
+ PriceMatrix::price_matrix($pmh, $ref, $decimalplaces, $form, $myconfig);
$ref->{description} = $ref->{translation} if $ref->{translation};
$ref->{partsgroup} = $ref->{grouptranslation} if $ref->{grouptranslation};
@@ -1060,30 +1052,6 @@ sub exchangerate_defaults {
}
-sub price_matrix {
- my ($pmh, $ref, $decimalplaces, $form) = @_;
-
- $pmh->execute($ref->{id});
- my $mref = $pmh->fetchrow_hashref(NAME_lc);
-
- if ($mref->{partnumber} ne "") {
- $ref->{partnumber} = $mref->{partnumber};
- }
-
- if ($mref->{lastcost}) {
- # do a conversion
- $ref->{sellprice} = $form->round_amount($mref->{lastcost} * $form->{$mref->{curr}}, $decimalplaces);
- }
- $pmh->finish;
-
- $ref->{sellprice} *= 1;
-
- # add 0:price to matrix
- $ref->{pricematrix} = "0:$ref->{sellprice}";
-
-}
-
-
sub vendor_details {
my ($self, $myconfig, $form) = @_;