accodeing / fortnox-api

Gem that abstracts Fortnox's F3 API
GNU Lesser General Public License v3.0
9 stars 8 forks source link

Discount: Conditional min/max range for percent and amount #152

Open mbirman opened 6 years ago

mbirman commented 6 years ago

From @d-Pixie:

As for the AMOUNT/PERCENT problem above I think we should front a custom property here and take a tuple of the type and value of the discount. That is, as far as I can get from the docs, the only way to do this. Bad data modeling on Fortnox's part unfortunately ... So we have played with the idea before of fronting certain attributes an keeping the Fortnox values in private attributes, prefixed with underscores or some such, and use the custom property's constructor to set the internal attributes. In this case we would case the validation based on the type and verify that the provided value for a type of discount holds before updating the internal variables.

For amount it must be [-9_999_999_999.9, 9_999_999_999.9] For percent [-100.0, 100.0]