devartis / passbook

Python library to create Apple Passbook (.pkpass) files
http://www.devartis.com/
MIT License
272 stars 108 forks source link

Bug: Apple doesn't support passing both a currencyCode and numberStyle #37

Closed johnksterling closed 7 years ago

johnksterling commented 8 years ago

We are running into a problem where we set the currencyCode on the balance field of a pass, but never set the numberStyle - yet the passbook python library re-injects a default numberStyle. Apple, however, doesn't support having both a numberStyle and a currency field.

There are a few ways to resolve this, but I chose to just over-ride the json generation on CurrencyField to only strip numberStyle if currencyCode is present (which looks to be almost always, unless someone explicitly deletes one of them).

Note that the proposed solution will leave 'empty' the json as-is if one of them is an empty string. I am not sure if this is the desired behavior since we don't set either to empty string - bit it would be an easy change to check json_dictionary.get('currencyCode') and json_dictionary.get('currencyCode').strip() if that was preferred.

I have tested this with a couple of version of the ios and it seems to work well. Anyone else running into this and interested in fixing it?

Closes #38

driskell commented 6 years ago

@johnksterling @mbaechtold Hi guys. Did something need to happen to merge this? I can see it didn't reach the master. Thanks!

driskell commented 6 years ago

Would just changing CurrencyField(NumberField) to CurrencyField(Field) not suffice?