{"id":43,"date":"2008-01-30T02:48:33","date_gmt":"2008-01-30T02:48:33","guid":{"rendered":"http:\/\/ibizsoftinc.com\/blogs\/istore\/automating-pricing-agreement-in-istore"},"modified":"2008-01-31T02:54:28","modified_gmt":"2008-01-31T02:54:28","slug":"automating-pricing-agreement-in-istore","status":"publish","type":"post","link":"https:\/\/www.ibizsoftinc.com\/blog\/automating-pricing-agreement-in-istore\/","title":{"rendered":"Automating Pricing Agreement in iStore"},"content":{"rendered":"<p>I came across a unique requirement when we were implementing iStore for GE Security. iStore has a gap, wherein, the Pricing Agreement(s) related to customer accounts need to be applied manually, unlike Order Management where the Agreements are picked up automatically. It was challenge for us, at iBizSoft, to provide a similiar, if not same, kind of functionality for GE Secutity B2B customers. <\/p>\n<p><!--more--><\/p>\n<p>We had a good look of how Pricing Agreements worked in Order Management and realized that for the same functionality to work in iStore, we needed to make sure that the same item(s), to which agreement is applied on, existed in the Price List that&#8217;s associated to or picked by iStore (using the getBestListPrice java api, that uses the inherent pricing engine). Secondly, we definitely knew that this involved customization the cart related page, since the price should get adjusted when the item is added to the cart. <\/p>\n<p>This involved a change to the ibeCScpAddItem.jsp. Here is a snippet of the code that we added<\/p>\n<p>           if(cartId != null &#038;&#038; !(cartId ==&#8221;&#8221;) )<br \/>\n           {<br \/>\n\t\t\t\tString cart_sql = &#8220;&#8221;;<br \/>\n\t\t\t\tString agree_sql = &#8220;&#8221;;<br \/>\n\t\t\t\tString v_item_id = &#8220;&#8221;;<br \/>\n\t\t\t\tString v_quote_line_id = &#8220;&#8221;;<\/p>\n<p>\t\t\t\tBigDecimal  v_accountId = RequestCtx.getAccountId();<\/p>\n<p>\t\t\t\tcart_sql = &#8221; select inventory_item_id, quote_line_id &#8221; ;<br \/>\n\t\t\t\tcart_sql = cart_sql + &#8221; from aso_quote_lines_all where quote_header_id = &#8216;&#8221; + cartId + &#8220;&#8216; &#8220;;<\/p>\n<p>\t\t\tResultSet rscart = null;<br \/>\n\t\t\tResultSet rsagree = null;<br \/>\n\t\t\tResultSet rsagree_2 = null;<br \/>\n\t\t\tjava.sql.Statement stmt=null;<br \/>\n\t\t\tjava.sql.Statement stmt_agree=null;<br \/>\n\t\t\tjava.sql.Statement stmt_agree_2=null;<\/p>\n<p>\t\t\toracle.jdbc.driver.OracleConnection con = null;<\/p>\n<p>\t\t\tcon = (OracleConnection)TransactionScope.getConnection();<\/p>\n<p>\t\t\t\/\/ Create a Statement object<br \/>\n\t\t\tstmt = con.createStatement();<br \/>\n\t\t\tstmt_agree = con.createStatement();<br \/>\n\t\t\tstmt_agree_2 = con.createStatement();<\/p>\n<p>\t\t\trscart = stmt.executeQuery(cart_sql);<\/p>\n<p><strong>\/\/For every item in the Cart <\/strong><\/p>\n<p>\t\t\twhile (rscart.next())<br \/>\n\t\t\t {<\/p>\n<p>\t\t\t\tboolean reprice              = true;<\/p>\n<p>\t\t\t\tShoppingCart SC             = new ShoppingCart(cartId,cartDate);<br \/>\n\t\t\t\tShoppingCartItem []SCIs     = new ShoppingCartItem[1];<br \/>\n\t\t\t\tShoppingCartItem currItem   = new ShoppingCartItem();<\/p>\n<p>\t\t\t\tv_item_id = rscart.getString(&#8220;inventory_item_id&#8221;);<br \/>\n\t\t\t\tv_quote_line_id = rscart.getString(&#8220;quote_line_id&#8221;);<\/p>\n<p>\t\t\t\tcurrItem.setCartLineId(v_quote_line_id);<\/p>\n<p><strong>\/\/ Query for the Agreement ID associated to the Price List that has the Item added to the Cart<\/strong><\/p>\n<p>\t\t\t\tagree_sql = &#8220;SELECT agreement_id, a.price_list_id&#8221;;<br \/>\n\t\t\t\tagree_sql = agree_sql + &#8221; FROM\t  oe_agreements_vl a, qp_list_lines_v c&#8221;;<br \/>\n\t\t\t\tagree_sql = agree_sql + &#8221; where a.sold_to_org_id = &#8221; + v_accountId + &#8221; &#8220;;<br \/>\n\t\t\t\tagree_sql = agree_sql + &#8221; AND SYSDATE BETWEEN NVL(a.START_DATE_ACTIVE,SYSDATE-1) AND NVL(a.end_DATE_ACTIVE  ,SYSDATE+1) and &#8221;  ;<br \/>\n\t\t\t\tagree_sql = agree_sql + &#8221; product_attr_value = &#8216;&#8221; + v_item_id + &#8220;&#8216; &#8220;;<br \/>\n\t\t\t\tagree_sql = agree_sql + &#8221; and list_header_id = a.price_list_id &#8220;;<\/p>\n<p>\t\t\t\trsagree = stmt_agree.executeQuery(agree_sql);<\/p>\n<p>\t\t\t\tboolean hasagreement=false;<\/p>\n<p><strong>\/\/ Associate the AgreementId to the Item in the Cart<\/strong><\/p>\n<p>\t\t\t\tif (rsagree.next())<br \/>\n\t\t\t\t {<br \/>\n\t\t\t\t   currItem.setAgreementId(rsagree.getString(&#8220;agreement_id&#8221;));<br \/>\n\t\t\t\t\thasagreement=true;<br \/>\n\t\t\t\t }<\/p>\n<p><strong>\/\/ This query is used if there are Related Accounts <\/strong><\/p>\n<p>\t\t\t\t\telse<br \/>\n\t\t\t\t\t{<br \/>\n\t\t\t\t\t   agree_sql = &#8221; SELECT agreement_id  FROM   OE_AGREEMENTS_V a, qp_list_lines_v b &#8220;;<br \/>\n\t\t\t\t\t   agree_sql = agree_sql + &#8221; where sold_to_org_id in (select cust_account_id &#8220;;<br \/>\n\t\t\t\t\t   \/\/agree_sql = agree_sql + &#8221; where sold_to_org_id = (select cust_account_id &#8220;;<br \/>\n\t\t\t\t\t   agree_sql = agree_sql + &#8221; from hz_cust_acct_relate_all where related_cust_account_id= &#8221; + v_accountId + &#8221; ) &#8220;;<br \/>\n\t\t\t\t\t   agree_sql = agree_sql + &#8221; AND    NVL(a.END_DATE_ACTIVE,SYSDATE+1) > SYSDATE  and product_attr_value = &#8216;&#8221; + v_item_id + &#8220;&#8216; and list_header_id = a.price_list_id &#8220;;<\/p>\n<p>\t\t\t\t\t\trsagree_2 = stmt_agree_2.executeQuery(agree_sql);<\/p>\n<p>\t\t\t\t\t\tif (rsagree_2.next())<br \/>\n\t\t\t\t\t\t{<br \/>\n\t\t\t\t\t\t\tcurrItem.setAgreementId(rsagree_2.getString(&#8220;agreement_id&#8221;));<br \/>\n\t\t\t\t\t\t\thasagreement=true;<br \/>\n\t\t\t\t\t\t}<br \/>\n\t\t\t\t\t} <\/p>\n<p>\t\t\t\t\tSCIs[0]                     = currItem;<br \/>\n\t\t\t\t\tSC.setShoppingCartItems(SCIs);<br \/>\n\t\t\t\t\tObject txnLock              = new Object();<br \/>\n\t\t\t\t\tboolean commitFlag          = false;<\/p>\n<p><strong>\/\/ Reprice the Cart if there is an Agreement<\/strong><\/p>\n<p>\t\t\t\t\tif(hasagreement)<br \/>\n\t\t\t\t\t{<br \/>\n\t\t\t\t\t\ttry<br \/>\n\t\t\t\t\t\t{<br \/>\n\t\t\t\t\t\t   TransactionScope.begin(txnLock);<br \/>\n\t\t\t\t\t\t\tSC.updateAgreements(reprice);<br \/>\n\t\t\t\t\t\t\tcommitFlag = true;<\/p>\n<p>\t\t\t\t\t\t}<br \/>\n\t\t\t\t\t\tcatch (FrameworkException e)<br \/>\n\t\t\t\t\t\t{<br \/>\n\t\t\t\t\t\t\t String errorMsg = IBEUtil.getMessages(e);<br \/>\n\t\t\t\t\t\t\t pageContext.setAttribute(&#8220;errMsg&#8221;, mm.getMessage(&#8220;IBE&#8221;, &#8220;IBE_AGRMT_ERR_SAVEPROB&#8221;) + &#8221; : &#8221; + errorMsg, PageContext.REQUEST_SCOPE);<br \/>\n\t\t\t\t\t\t}<br \/>\n\t\t\t\t\t\tfinally<br \/>\n\t\t\t\t\t\t{<br \/>\n\t\t\t\t\t\t   if (!commitFlag)   TransactionScope.setRollbackOnly();<br \/>\n\t\t\t\t\t\t   TransactionScope.end(txnLock);<br \/>\n\t\t\t\t\t\t}<br \/>\n\t\t\t\t\t}<br \/>\n\t\t\t\t   } \/\/ end of while in aso_quote<\/p>\n<p>\t\t\t\t   TransactionScope.releaseConnection(con);<br \/>\n\t\t\t\t  } \/\/ end of if cartId != null<\/p>\n<p><strong>\t\/\/ This is where the Code for Automating Agreement ENDs<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across a unique requirement when we were implementing iStore for GE Security. iStore has a gap, wherein, the Pricing Agreement(s) related to customer accounts need to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ibizsoftinc.com\/blog\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}