pamt and samt

mark's Avatar

mark

27 Jul, 2023 06:58 PM

I'm writing a raw JSON parser, to load information into an SQL database for further analysis. And just for fun :).

I notice that transactions typically (maybe always) specify both an "pamt" and an "samt", with opposite signs. For example:

"0.pamt": "24000" "0.samt": "-24000"

The "0." simply indicates the split number.

What is the definition/purpose of storing both values? Enquiring minds want to know :)!

  1. 1 Posted by Stuart Beesley ... on 27 Jul, 2023 07:11 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    One is that split’s amount (samt) and the other is the amount that impacts the parent (pamt). The signs are opposite as clearly one will credit one account and debit the other. The amounts can vary if the currency of the parent is different, or on security share purchases.

  2. 2 Posted by Stuart Beesley ... on 27 Jul, 2023 07:12 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    .

  3. 3 Posted by Stuart Beesley ... on 27 Jul, 2023 07:22 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    With shares I think the samt is zero, or perhaps the pamt is zero… can’t remember which, but you’ll work that out.

  4. 4 Posted by mark on 27 Jul, 2023 10:31 PM

    mark's Avatar

    For shares, it looks like pamt is 0 and samt is the number of shares, as an integer which you have to scale by a factor of ten defined in the definition of the security the shares relate to.

  5. 5 Posted by Stuart Beesley ... on 28 Jul, 2023 05:16 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Yup 👍

  6. Support Staff 6 Posted by Sean Reilly on 28 Jul, 2023 08:08 AM

    Sean Reilly's Avatar

    For some background as to why there are two amounts for every split, in the first version of moneydance we would store the split amount and a 64bit float for the rate. This wasn't good as it relied upon a floating point value for the parent amount which wasn't accurate enough. It also didn't allow for situations in which one of the amounts was zero and the other one non-zero, which can occur in some cases. Either way, storing both amounts as 64 bit integers avoids any floating point inaccuracies.

    Thanks,
    Sean

    --
    Sean Reilly
    Developer, The Infinite Kind
    https://infinitekind.com

  7. 7 Posted by mark on 30 Jul, 2023 07:28 PM

    mark's Avatar

    I'm finding both writing this library and these discussions fascinating, thanx.

    FWIW, in parsing over 50,000 transactions (spread over a 30+ year period, going back to when I was using shudder Quicken :)) I didn't find a single one where pamt and samt aren't simply negatives of each other (i.e., summing them always results in 0).

    That's even true for transactions having splits, where the splits have different values.

    So it looks like, whatever the reason for having samt and pamt, it isn't to hold "different" values.

    Thoughts?

  8. 8 Posted by Stuart Beesley ... on 30 Jul, 2023 08:43 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    It will for transfers between different currency accounts/categories.

    As already pointed out, also different for securities too.

  9. 9 Posted by Stuart Beesley ... on 30 Jul, 2023 09:15 PM

    Stuart Beesley (Mr Toolbox)'s Avatar
  10. 10 Posted by mark on 30 Jul, 2023 10:36 PM

    mark's Avatar

    My bad: the sql query I wrote was bad

  11. 11 Posted by Stuart Beesley ... on 31 Jul, 2023 07:24 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    👍

  12. System closed this discussion on 30 Oct, 2023 07:30 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

15 Apr, 2024 03:02 PM
15 Apr, 2024 01:56 PM
15 Apr, 2024 12:32 PM
15 Apr, 2024 12:20 PM
15 Apr, 2024 11:56 AM