Transaction.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { User } from 'src/models/User'
  2. import { Invoice } from 'src/models/Invoice.js'
  3. import { Model, Collection } from 'js-abstract-model'
  4. class Transaction extends Model {
  5. constructor (data) {
  6. super(data, [
  7. { key: 'id' },
  8. { key: 'is_active' },
  9. { key: 'is_deleted' },
  10. { key: 'amount' },
  11. { key: 'authority_code' },
  12. { key: 'reference_code' },
  13. { key: 'description' },
  14. { key: 'status' }, // IN_PROGRESS
  15. {
  16. key: 'additional_data',
  17. default: []
  18. },
  19. { key: 'creation_time' },
  20. { key: 'last_modification_time' },
  21. { key: 'creator' },
  22. {
  23. key: 'creator_info',
  24. relatedModel: User
  25. },
  26. { key: 'owner' },
  27. {
  28. key: 'owner_info',
  29. relatedModel: User
  30. },
  31. { key: 'invoice' },
  32. {
  33. key: 'invoice_info',
  34. relatedModel: Invoice
  35. }
  36. ], {
  37. status: {
  38. infoKey: 'status_info',
  39. enumListKey: 'statusEnums',
  40. enums: [
  41. { label: 'لغو شده', value: 'CANCELED' },
  42. { label: 'ناموفق', value: 'FAILED' },
  43. { label: 'موفق', value: 'SUCCESS' },
  44. { label: 'خطا', value: 'ERRORED' },
  45. { label: 'ناشناخته', value: 'UNKNOWN' },
  46. { label: 'در حال انجام', value: 'IN_PROGRESS' },
  47. { label: 'در حال اعتبارسنجی', value: 'VERIFYING' }
  48. ]
  49. }
  50. })
  51. }
  52. }
  53. class TransactionList extends Collection {
  54. model () {
  55. return Transaction
  56. }
  57. }
  58. export { Transaction, TransactionList }