wceu / camptix-invoices

A WordPress plugin that generates invoices for tickets purchased through Camptix
4 stars 0 forks source link

[Blocker] Add checks to prevent overwriting an invoice #24

Closed vedanshujain closed 5 years ago

vedanshujain commented 5 years ago

Currently invoice number can be configured in invoice settings, thereby making it possible for a new invoice to accidentally overwrite a previous one. Please add check to see if file already exists, and throw an error if that's the case before writing the file.

Also, another related suggestion, it could be a good idea to add some randomness in invoice name (maybe timestamp?) to make sure invoice don't get overwritten.

iandunn commented 5 years ago

Related https://github.com/wceu/camptix-invoices/issues/21#issuecomment-465246991

avillegasn commented 5 years ago

Some randomness has been added to the invoice name according to #21.

However, two invoices may have the same number when changing the next invoice number in the invoicing settings to a lower value (already in use).

It's just a legal thing, but probably two invoices should always have different invoice numbers. Should we control that? What's your opinion @vedanshujain @iandunn ?

iandunn commented 5 years ago

Yeah, it seems like it'd make sense to prevent that setting from being set lower than {latest ID + 1}.

I'm not sure we even need a setting for it though, to be honest. A filter maybe, but I'd probably recommend "decisions not options" in this case. How common would it be for a camp to want to change that?