<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Greetings,</p>
    <p>I am trying to add a shares purchase transaction. I've account
      for given stock/commodity and a cash account from which money will
      be transferred</p>
    <p>As I understand one part of the split should come from cash which
      will be currency or dollar value. Other split will be number of
      shares purchased for that money. </p>
    <p>I am trying to use API (through my Java library) to create a
      transaction and not able to get it right. I am especially getting
      confused about the value and amount parts. I am not sure which
      field will represent the quantity or number of shares purchased.</p>
    <p>Here is the general flow I am calling from Java </p>
    <p><br>
    </p>
    <p>Create transaction - <span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccMallocTransaction</span></span></span></p>
    <p>Set currency as my commodity of stock - <span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccTransSetCurrency</span></span></span></p>
    <p>Create split <span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccTransSetCurrency</span></span></span></p>
    <p><br>
    </p>
    <p>Set appropriate account and parent <span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccSplitSetAccount, </span></span></span><span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccSplitSetParent</span></span></span></p>
    <p><br>
    </p>
    <p>I now have three data fields available - total amount in dollar 
      (moneySpent), number of shares purchased (quantity) and price 
      (price) at which they were purchased. I tried various combinations
      of <span style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccSplitSetAmount, </span></span></span><span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccSplitSetValue, </span></span></span><span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><span
        style="color:#000000;"></span><span
style="color:#000000;background-color:#d4d4d4;font-style:italic;">xaccSplitSetSharePriceAndAmount</span></span></span></p>
    <p><br>
    </p>
    <p>But not matter what I do, I always get imbalance record or price
      gets calculated wrong. In general split entry is wrong. Mirroring
      split from cash account looks correct. At least that account shows
      the entry the way it should be.</p>
    <p>Can you please help me with the right method calls and parameters
      I need to pass get the transaction right. I've intentionally used
      slightly different variable names in the email so as to avoid the
      confusion with the actual parameter names used in header files.</p>
    <p><br>
    </p>
    <p>Regards,</p>
    <p>Niranjan</p>
    <p><br>
    </p>
  </body>
</html>