[v11] Can Deferred Revenue be used for Gift Cards?


I am trying to add a feature to handle Gift Cards in a custom app. So far, regarding Gift Cards, these are the only two related posts I could find -

These are the changes I thought of adding to the custom app for this feature.

  • Create custom fields in Item to set the whether Item is_gift_card and hold gift_card_value and gift_card_validity.
    • Make Gift Card Items serialized and use deferred_revenue_account.
  • Create custom doctype Gift Card that map one-to-one to Serial No. (Or maybe just use Serial No with custom fields.)
  • Hook into Serial No after_insert to create Gift Card with card_amount.
    • Stock Entry et al. can be used to receive stock, the standard ERPNExt way.
  • Selling Gift Card Item to Customer with Sales Invoice would need no changes as the sale would be registered against the deferred_revenue_account. The card_validity would need to be updated though, so hook into on_submit.
  • Add a Mode of Payment with the account for the company set to the same deferred_revenue_account.
  • Create custom fields in Sales Invoice to select Gift Card, fetch gift_card_balance. (Also check card_validity)
  • When a Sales Invoice is inserted with the Gift Card Mode of Payment, validate amount against gift_card_balance.
  • When the Sales Invoice is submitted, the paid amount from deferred_revenue_account should move from this account to the proper income account (hopefully with no changes further changes to the code).
  • Hook into on_submit here, to update the gift_card_balance. These might be achieved by one of two ways.
    • Updating in-place a card_balance field in Gift Card.
    • Maintaining a transaction record, Gift Card Entry, similar to Loyalty Point Entry

My concerns are -

  • Will this be achievable?
  • Am I allowed to use Deferred Revenue like this?

Any other thoughts would be appreciated.