Payment.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { User } from 'src/models/User'
  2. import { Invoice } from 'src/models/Invoice.js'
  3. import { Model, Collection } from 'js-abstract-model'
  4. import { Transaction } from 'src/models/Transaction.js'
  5. class Payment extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'creator' },
  10. {
  11. key: 'creator_info',
  12. relatedModel: User
  13. },
  14. { key: 'invoice' },
  15. {
  16. key: 'invoice_info',
  17. relatedModel: Invoice
  18. },
  19. { key: 'wallet' },
  20. { key: 'transaction' },
  21. {
  22. key: 'transaction_info',
  23. relatedModel: Transaction
  24. },
  25. { key: 'amount' },
  26. { key: 'description' },
  27. { key: 'type' }, // WITHDRAW - ...
  28. {
  29. key: 'additional_data',
  30. default: []
  31. },
  32. { key: 'creation_time' },
  33. { key: 'last_modification_time' },
  34. { key: 'receipt' },
  35. { key: 'IBAN' },
  36. { key: 'is_active' },
  37. { key: 'is_deleted' }
  38. ], {
  39. type: {
  40. infoKey: 'type_info',
  41. enumListKey: 'typeEnums',
  42. enums: [
  43. {
  44. label: 'برداشت',
  45. value: 'WITHDRAW'
  46. },
  47. {
  48. label: 'درخواست برداشت',
  49. value: 'WITHDRAW_REQUEST'
  50. },
  51. {
  52. label: 'برداشت رد شده',
  53. value: 'WITHDRAW_REJECT'
  54. },
  55. {
  56. label: 'واریز',
  57. value: 'DEPOSIT'
  58. }
  59. ]
  60. }
  61. })
  62. }
  63. }
  64. class PaymentList extends Collection {
  65. model () {
  66. return Payment
  67. }
  68. }
  69. export { Payment, PaymentList }