This is not a programming question, I suppose is a logic question or a database design question.
To answer this you need to know something about bank transactions.
Basically for every transaction (sale, refund,force sale) you make and if the host approves that transaction, the host sends you an RRN (Reference Retrieval Number), this is a number to identify that transaction.
The problem is that I don't know how the host manage this number, I mean I suppose this approach:
The RRN is generated with:
- Type of transaction
- RRN
- Membership (depends of the currency)
- Number of batch or lot
These four entities could make a UNIQUE KEY in database, the problem is that how do I know when I have to reset the RRN value.
I cannot restrict that UNIQUE KEY in DB, because if you make transactions today, and I don't know if the host reset the RRN value without knowing it I would probably repeat the number of the RRN in the next day and I will throw an error sending that a unique KEY is violated, but that is no the behavior is expected, in theory I don't have to control the RRN number, cause that is a job of the host, but, How do I identify that transaction in the DB if I want to make a cancellation or rolled back that transaction.
I can't have multiple rows if I want to query a unique transaction.
The only thing I have in mind is to identify the transaction with those four entities without making the UNIQUE restriction, but if I query that transaction and I have more than one result, throw an error saying the data is corrupted.