<% itemtocheck=orequest.form('itemtocheck') quantitytocheck=orequest.form('quantitytocheck') saletocheck=orequest.form('saletocheck') discounttocheck=orequest.form('discounttocheck') thepricing=nvl(orequest.form('thepricing'),0) =usesafe('itemmast') =Seek(itemtocheck,[itemmast],[itemid]) theclass=ITEMMAST.almara usesafe('itdisc') locate for allt(class)==allt(theclass) maximumAllowedDiscount=0 maximumAllowedDiscountP=0 actualcost=Iif(Empty(ITEMMAST.pcost),ITEMMAST.COST,ITEMMAST.pcost) thesalerate=ITEMMAST.sale Do Case Case ITEMMAST.Container actualcost=0 thesalerate=0 Return [] Case ITEMMAST.openprice Return [] Case ITEMMAST.exempt maximumAllowedDiscountP=ITEMMAST.disc Case XCOMPANY.saleokless Return [] Case Not Empty(itdisc.disc) maximumAllowedDiscountP=tempx.disc Otherwise * xcompany.discount OR user_discount maximumAllowedDiscountP=10 If Not Empty(XCOMPANY.maxdisc) maximumAllowedDiscountP=XCOMPANY.maxdisc Endif Endcase maximumAllowedDiscount=Round(ITEMMAST.sale*maximumAllowedDiscountP*quantitytocheck/100,2) theLeastAllowedNet=Round(ITEMMAST.sale*quantitytocheck-maximumAllowedDiscount,2) theProposedNet=Round(saletocheck*quantitytocheck-discounttocheck,2) If Round(saletocheck*quantitytocheck-discounttocheck,2)>=Round(actualcost*quantitytocheck,2) And thepricing>3 *actualcost=Round(actualcost*quantitytocheck,2) Return [] Endif If Round(saletocheck*quantitytocheck-discounttocheck,2)