Comment by abdullahkhalids

Comment by abdullahkhalids 9 hours ago

5 replies

How would this handle Canadian guidelines for dealing with cents in cash, where you round to the nearest 5c [1]?

    Amounts ending in 1 cent and 2 cents are rounded down to the nearest 10 cents;
    Amounts ending in 3 cents and 4 cents are rounded up to the nearest 5 cents;
    Amounts ending in 6 cents and 7 cents are rounded down to the nearest 5 cents;
    Amounts ending in 8 cents and 9 cents are rounded up to the nearest 10 cents;
    Amounts ending in 0 cent and 5 cents remain unchanged.
EDIT: I think if you send 12 cents,

    send [CADCASH/2 12] ( source = @user1 destination = @user2 )
It should result in sending 10 cents.

    "postings": [{"source": "user1",
                  "destination": "user2",
                  "amount": 10,
                  "asset": "CADCASH/2"}]
Can this happen?

[1] https://www.canada.ca/en/revenue-agency/programs/about-canad...

superzamp 8 hours ago

Well that's definitely a good puzzle. I've tried to model it for a bit, but it indeed looks like we'd need to add something to the language to make it possible at all! Thanks for bringing this up.

  • fallat 8 hours ago

    Same thing with income tax brackets. You need conditional logic.

    • superzamp 7 hours ago

      For this particular case, I would say that tax-brackets sort of logic can be expressed in the destination block with ordered destinations.

      For example, you could have something like this:

          send [USD/2 *] (
            source = @users:1234
            destination = {
              // first $1000 are taxed at 10%
              max [USD/2 100000] to {
                10% to @taxes
                remaining kept
              }
              // Anything above that is, taxed at 20%
              remaining to {
                20% to @taxes
                remaining kept
              }
            }
          )
      
      (You can test it on the playground, you'll just want to feed the "users:1234" account with an initial balance in the input section)
euroderf 7 hours ago

The rules listed (1,2,6,7 round down; 3,4,8,9 round up). AFAIK these are also the official Eurozone cash rules for countries that choose not to circulate 1 and 2 eurocent coins. (Altho of course, electronic transactions are exact to the penny.) So you might want to cover this use case.

wombatpm 2 hours ago

I’m assuming there are guidelines as to when this conversion happens and how often. Must make itemized invoices lots of fun. Specially when you have returns or cancellations