Hi,
I have an xml instance as follow <PO> <LineItem> <Id>1</Id> <Quantity>10</Quantity> <UnitPrice>0.5</UnitPrice> <SubTotal>5</SubTotal> </LineItem> <LineItem> <Id>1</Id> <Quantity>20</Quantity> <UnitPrice>1</UnitPrice> <SubTotal>20</SubTotal> </LineItem> <TotalAmount>25</TotalAmount> </PO> SubTotal = Quantity * UnitPrice Total Amount = sum of subtotal of all line items I have prepare a binding on LineItem/SubTotal and TotalAmount As follow: <xforms:bind nodeset="OrderLineItem/SubTotal" calculate="../Quantity * ../UnitPrice"/> <xforms:bind nodeset="TotalAmount" calculate="sum(instance('doc-instance')/LineItem/SubTotal)"/> The subtotal is updated successfully when the quantity and unit price is changed. It is expected that the change in subtotal by the calculation will trigger the change in total amount immediately. However, the TotalAmount is not updated unless a change in any other fields is triggered. Any suggestion on how can I calculate both the subtotal and totalamount together when quantity or unit price is updated? Another question: if in my instance there is no sub-total element under order line item, and I want to calcuate the total amount as follow: Total Amount = Sum of (Quantity * UnitPrice) for all line item How can I write teh caculate? I have tried the following: <xforms:bind nodeset="TotalAmount" calculate="sum(instance(doc-instace)/LineItem/Quantity * instance(doc-instace)/LineItem/UnitPrice")/> but it return error saying that "A sequence of more than one item is not allowed as the first operand of '*'" How should I write such calculation? Thanks in advance Queenie |
quinquin2209 schrieb:
> Any suggestion on how can I calculate both the subtotal and totalamount > together when quantity or unit price is updated? Maybe it helps if you add an <xforms:refresh ev:event="xforms-value-changed" /> to the controls for the quantities and unit prices. (didn't test it). HTH florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
In reply to this post by quinquin2209
Queenie,
It should work as is. Can you send the entire XForms that runs in the XForms sandbox? -Erik On Mar 12, 2008, at 12:44 AM, quinquin2209 wrote: > > Hi, > > I have an xml instance as follow > > <PO> > <LineItem> > <Id>1</Id> > <Quantity>10</Quantity> > <UnitPrice>0.5</UnitPrice> > <SubTotal>5</SubTotal> > </LineItem> > <LineItem> > <Id>1</Id> > <Quantity>20</Quantity> > <UnitPrice>1</UnitPrice> > <SubTotal>20</SubTotal> > </LineItem> > <TotalAmount>25</TotalAmount> > </PO> > > > SubTotal = Quantity * UnitPrice > Total Amount = sum of subtotal of all line items > > I have prepare a binding on LineItem/SubTotal and TotalAmount As > follow: > > > <xforms:bind nodeset="OrderLineItem/SubTotal" calculate="../Quantity * > ../UnitPrice"/> > <xforms:bind nodeset="TotalAmount" > calculate="sum(instance('doc-instance')/LineItem/SubTotal)"/> > > > The subtotal is updated successfully when the quantity and unit > price is > changed. > > It is expected that the change in subtotal by the calculation will > trigger > the change in total amount immediately. However, the TotalAmount is > not > updated unless a change in any other fields is triggered. > > Any suggestion on how can I calculate both the subtotal and > totalamount > together when quantity or unit price is updated? > > Thanks in advance > > Queenie Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Erik,
Thanks for your reply. I find that my approach work in one testing case but not in my real case, which is a bit more complex xml. This one is the simplified version, which works perfectly test.jsp This is the real case which I am dealing with, and the total amount cannot be updated correctly test2.jsp I am still finding what's the differences between these 2. |
Free forum by Nabble | Edit this page |