27e5f04b7ca2e8e4432730e915d4f17bb5ba339e
[xtuple] / foundation-database / public / tables / metasql / updatePrices-update.mql
1 -- Group: updateprices
2 -- Name: update
3 -- Notes:
4 -- Notes:
5 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
6 -- See www.xtuple.com/CPAL for the full text of the software license.
7
8 UPDATE ipsiteminfo SET
9   ipsitem_price=
10 <? if exists("updateByValue") ?>
11   ipsitem_price + <? value("updateBy") ?>
12 <? else ?>
13   roundSale(ipsitem_price * (1.0 + (<? value("updateBy") ?> / 100.0)))
14 <? endif ?>
15 FROM selsched, item
16 <? if reExists("itemgrp") ?>
17   JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)
18   JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)
19 <? elseif reExists("prodcat") ?>
20   JOIN prodcat ON (prodcat_id=item_prodcat_id)
21 <? endif ?>
22 WHERE ( ipsitem_item_id=item_id
23   AND selsched_ipshead_id=ipsitem_ipshead_id
24 <? if exists("item_id") ?>
25   AND item_id=<? value("item_id") ?>
26 <? elseif exists("itemgrp_id") ?>
27   AND itemgrp_id=<? value("itemgrp_id") ?>
28 <? elseif exists("itemgrp_pattern") ?>
29   AND itemgrp_name ~ <? value("itemgrp_pattern") ?>
30 <? elseif exists("prodcat_id") ?>
31   AND prodcat_id=<? value("prodcat_id") ?>
32 <? elseif exists("prodcat_pattern") ?>
33   AND prodcat_code ~ <? value("prodcat_pattern") ?>
34 <? endif ?>
35 );