diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-02 23:40:18 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-02 23:40:18 +0000 |
commit | a2c93e1cde65e60b17e0204183033896cca70a4f (patch) | |
tree | 9149305e89ba89f7ab7c9983eb3495cf63badf6a /LedgerSMB/JC.pm | |
parent | 050d1f5d21a22e79ea575c182164540e6fb5d6da (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/JC.pm')
-rwxr-xr-x | LedgerSMB/JC.pm | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/LedgerSMB/JC.pm b/LedgerSMB/JC.pm index b5c4d5d2..02fcb914 100755 --- a/LedgerSMB/JC.pm +++ b/LedgerSMB/JC.pm @@ -35,6 +35,7 @@ package JC; use LedgerSMB::IS; +use LedgerSMB::PriceMatrix; sub get_jcitems { my ($self, $myconfig, $form) = @_; @@ -268,12 +269,12 @@ sub jcparts { my $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); - my $pmh = price_matrix_query($dbh, $project_id, $customer_id); + my $pmh = PriceMatrix::price_matrix_query($dbh, $form); IS::exchangerate_defaults($dbh, $form); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { $ref->{description} = $ref->{translation} if $ref->{translation}; - IS::price_matrix($pmh, $ref, $form->datetonum($form->{transdate}), 4, $form, $myconfig); + PriceMatrix::price_matrix($pmh, $ref, $form->{transdate}, 4, $form, $myconfig); push @{ $form->{all_parts} }, $ref; } $sth->finish; @@ -552,49 +553,6 @@ sub save { } -sub price_matrix_query { - my ($dbh, $project_id, $customer_id) = @_; - - my $query = qq|SELECT p.id AS parts_id, 0 AS customer_id, 0 AS pricegroup_id, - 0 AS pricebreak, p.sellprice, NULL AS validfrom, NULL AS validto, - (SELECT substr(curr,1,3) FROM defaults) AS curr, '' AS pricegroup - FROM parts p - WHERE p.id = ? - - UNION - - SELECT p.*, g.pricegroup - FROM partscustomer p - LEFT JOIN pricegroup g ON (g.id = p.pricegroup_id) - WHERE p.parts_id = ? - AND p.customer_id = $customer_id - - UNION - - SELECT p.*, g.pricegroup - FROM partscustomer p - LEFT JOIN pricegroup g ON (g.id = p.pricegroup_id) - JOIN customer c ON (c.pricegroup_id = g.id) - WHERE p.parts_id = ? - AND c.id = $customer_id - - UNION - - SELECT p.*, '' AS pricegroup - FROM partscustomer p - WHERE p.customer_id = 0 - AND p.pricegroup_id = 0 - AND p.parts_id = ? - - ORDER BY customer_id DESC, pricegroup_id DESC, pricebreak - - |; - my $sth = $dbh->prepare($query) || $form->dberror($query); - - $sth; - -} - 1; |