@questwork/q-store-model 0.1.40 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,6 +84,7 @@ __webpack_require__.d(__webpack_exports__, {
84
84
  Status: () => (/* reexport */ Status),
85
85
  StatusQStore: () => (/* reexport */ StatusQStore),
86
86
  StatusQStoreInvoice: () => (/* reexport */ StatusQStoreInvoice),
87
+ StatusQStoreOrder: () => (/* reexport */ StatusQStoreOrder),
87
88
  StatusQStoreOrderLine: () => (/* reexport */ StatusQStoreOrderLine),
88
89
  StoreItem: () => (/* reexport */ StoreItem),
89
90
  Transaction: () => (/* reexport */ Transaction),
@@ -145,6 +146,7 @@ __webpack_require__.d(models_namespaceObject, {
145
146
  Status: () => (Status),
146
147
  StatusQStore: () => (StatusQStore),
147
148
  StatusQStoreInvoice: () => (StatusQStoreInvoice),
149
+ StatusQStoreOrder: () => (StatusQStoreOrder),
148
150
  StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
149
151
  StoreItem: () => (StoreItem),
150
152
  Transaction: () => (Transaction),
@@ -1949,7 +1951,7 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
1949
1951
  super(options)
1950
1952
 
1951
1953
  const { _ItemOption, _ItemOptionFillIn, _MerchandiseOption, _Price, _Product } = options._constructor || {}
1952
- this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _I_ItemOptiontemOptionFillIn : ItemOption
1954
+ this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _ItemOption : ItemOption
1953
1955
  this._ItemOptionFillIn = _ItemOptionFillIn && (_ItemOptionFillIn._superclass === ItemOptionFillIn._superclass) ? _ItemOptionFillIn : ItemOptionFillIn
1954
1956
  this._MerchandiseOption = _MerchandiseOption && (_MerchandiseOption._superclass === MerchandiseOption._superclass) ? _MerchandiseOption : MerchandiseOption
1955
1957
  this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
@@ -2286,11 +2288,20 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
2286
2288
  }
2287
2289
  getPreservedData() {
2288
2290
  return {
2291
+ allowEditQty: this.allowEditQty,
2292
+ allowEditUnitPrice: this.allowEditUnitPrice,
2293
+ defaultCurrency: this.defaultCurrency,
2294
+ description: this.description,
2295
+ merchandiseCategoryCodes: this.merchandiseCategoryCodes,
2289
2296
  merchandiseCode: this.merchandiseCode,
2297
+ merchandiseOptions: this.merchandiseOptions,
2290
2298
  merchandiseType: this.merchandiseType,
2291
2299
  metadata: this.metadata,
2292
2300
  name: this.name,
2301
+ priority: this.priority,
2293
2302
  productCodes: this.productCodes,
2303
+ sku: this.sku,
2304
+ stock: this.stock,
2294
2305
  tenantCode: this.tenantCode,
2295
2306
  }
2296
2307
  }
@@ -3917,10 +3928,10 @@ class StatusQStoreInvoice extends StatusQStore {
3917
3928
  return 'StatusQStoreInvoice'
3918
3929
  }
3919
3930
  get isClosed() {
3920
- return this.closed?.timestamp > Date.now()
3931
+ return this.closed?.timestamp > 0
3921
3932
  }
3922
3933
  get isOpen() {
3923
- return this.open?.timestamp > Date.now()
3934
+ return this.open?.timestamp > 0
3924
3935
  }
3925
3936
  get isValid() {
3926
3937
  return super.isValid
@@ -3933,6 +3944,64 @@ class StatusQStoreInvoice extends StatusQStore {
3933
3944
  }
3934
3945
  }
3935
3946
 
3947
+ ;// ./lib/models/statusQStore/statusQStoreOrder.js
3948
+
3949
+
3950
+ const statusQStoreOrder_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
3951
+ ]))
3952
+
3953
+ class StatusQStoreOrder extends StatusQStore {
3954
+ constructor(options) {
3955
+ options = options || {}
3956
+ super(options)
3957
+ this.closed = this._ActionRecord.init(options.closed)
3958
+ // this.expired = this._ActionRecord.init(options.expired)
3959
+ // this.fulfilled = this._ActionRecord.init(options.fulfilled)
3960
+ // this.invalid = this._ActionRecord.init(options.invalid)
3961
+ // this.posted = this._ActionRecord.init(options.posted)
3962
+ }
3963
+
3964
+ static get _classname() {
3965
+ return 'StatusQStoreOrder'
3966
+ }
3967
+ get _classname() {
3968
+ return 'StatusQStoreOrder'
3969
+ }
3970
+ get isClosed() {
3971
+ return this.closed?.timestamp > 0
3972
+ }
3973
+ // get isExpired() {
3974
+ // return this.expired?.timestamp < Date.now()
3975
+ // }
3976
+ // get isFulfilled() {
3977
+ // return this.fulfilled?.timestamp > 0
3978
+ // }
3979
+ // get isInvalid() {
3980
+ // return this.invalid?.timestamp < Date.now()
3981
+ // }
3982
+ // get isPosted() {
3983
+ // return this.posted?.timestamp > 0
3984
+ // }
3985
+ // get isValid() {
3986
+ // return super.isValid
3987
+ // }
3988
+ setClosed(value, actorCode) {
3989
+ return this.setValue(value, actorCode, 'closed')
3990
+ }
3991
+ // setExpired(value, actorCode) {
3992
+ // return this.setValue(value, actorCode, 'expired')
3993
+ // }
3994
+ // setFulfilled(value, actorCode) {
3995
+ // return this.setValue(value, actorCode, 'fulfilled')
3996
+ // }
3997
+ // setInvalid(value, actorCode) {
3998
+ // return this.setValue(value, actorCode, 'invalid')
3999
+ // }
4000
+ // setPosted(value, actorCode) {
4001
+ // return this.setValue(value, actorCode, 'posted')
4002
+ // }
4003
+ }
4004
+
3936
4005
  ;// ./lib/models/statusQStore/statusQStoreOrderLine.js
3937
4006
 
3938
4007
 
@@ -3945,7 +4014,9 @@ class StatusQStoreOrderLine extends StatusQStore {
3945
4014
  super(options)
3946
4015
 
3947
4016
  this.expired = this._ActionRecord.init(options.expired)
4017
+ this.fulfilled = this._ActionRecord.init(options.fulfilled)
3948
4018
  this.invalid = this._ActionRecord.init(options.invalid)
4019
+ this.posted = this._ActionRecord.init(options.posted)
3949
4020
  }
3950
4021
 
3951
4022
  static get _classname() {
@@ -3955,20 +4026,32 @@ class StatusQStoreOrderLine extends StatusQStore {
3955
4026
  return 'StatusQStoreOrderLine'
3956
4027
  }
3957
4028
  get isExpired() {
3958
- return this.expired?.timestamp > Date.now()
4029
+ return this.expired?.timestamp < Date.now()
4030
+ }
4031
+ get isFulfilled() {
4032
+ return this.fulfilled?.timestamp > 0
3959
4033
  }
3960
4034
  get isInvalid() {
3961
- return this.invalid?.timestamp > Date.now()
4035
+ return this.invalid?.timestamp < Date.now()
3962
4036
  }
3963
- get isValid() {
3964
- return super.isValid
4037
+ get isPosted() {
4038
+ return this.posted?.timestamp > 0
3965
4039
  }
4040
+ // get isValid() {
4041
+ // return super.isValid
4042
+ // }
3966
4043
  setExpired(value, actorCode) {
3967
4044
  return this.setValue(value, actorCode, 'expired')
3968
4045
  }
4046
+ setFulfilled(value, actorCode) {
4047
+ return this.setValue(value, actorCode, 'fulfilled')
4048
+ }
3969
4049
  setInvalid(value, actorCode) {
3970
4050
  return this.setValue(value, actorCode, 'invalid')
3971
4051
  }
4052
+ setPosted(value, actorCode) {
4053
+ return this.setValue(value, actorCode, 'posted')
4054
+ }
3972
4055
  // update(update) {
3973
4056
  // Object.keys(update).forEach((key) => {
3974
4057
  // if (!notUpdateAllowedProps.includes(key)) {
@@ -3986,6 +4069,7 @@ class StatusQStoreOrderLine extends StatusQStore {
3986
4069
 
3987
4070
 
3988
4071
 
4072
+
3989
4073
  ;// ./lib/models/paymentCharge/paymentCharge.js
3990
4074
 
3991
4075
 
@@ -4099,7 +4183,12 @@ function paymentCharge_setId(id) {
4099
4183
 
4100
4184
  const receiptLine_updateAllowedProps = [
4101
4185
  'additionalData',
4186
+ 'amount',
4187
+ 'paidAmount',
4188
+ 'paymentGatewayCode',
4189
+ 'receiptDate',
4102
4190
  'status',
4191
+ 'surcharge'
4103
4192
  ]
4104
4193
 
4105
4194
  class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
@@ -4208,6 +4297,8 @@ class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
4208
4297
  this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(obj[key])
4209
4298
  } else if (key === 'status') {
4210
4299
  this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
4300
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4301
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4211
4302
  } else {
4212
4303
  this[key] = obj[key]
4213
4304
  }
@@ -4238,7 +4329,12 @@ function receiptLine_setId(id) {
4238
4329
 
4239
4330
 
4240
4331
  const receipt_updateAllowedProps = [
4332
+ 'amount',
4333
+ 'paidAmount',
4334
+ 'receiptDate',
4335
+ 'revisionNumber',
4241
4336
  'status',
4337
+ 'surcharge'
4242
4338
  ]
4243
4339
 
4244
4340
  class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
@@ -4258,7 +4354,6 @@ class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
4258
4354
  this._type = options._type || 'Receipt'
4259
4355
  this.amount = this._Amount.init(options.amount)
4260
4356
  this.paidAmount = this._Amount.init(options.paidAmount)
4261
- this.paymentGatewayCode = options.paymentGatewayCode
4262
4357
  this.receiptCode = options.receiptCode
4263
4358
  this.receiptDate = options.receiptDate || (new Date()).valueOf()
4264
4359
  this.receiptNumber = options.receiptNumber
@@ -4343,6 +4438,8 @@ class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
4343
4438
  if (receipt_updateAllowedProps.includes(key)) {
4344
4439
  if (key === 'status') {
4345
4440
  this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
4441
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4442
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4346
4443
  } else {
4347
4444
  this[key] = obj[key]
4348
4445
  }
@@ -5776,17 +5873,53 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5776
5873
  return 'OrderLine'
5777
5874
  }
5778
5875
 
5876
+ get currentStatus() {
5877
+ if (this.isPosted) {
5878
+ return 'posted'
5879
+ } else if (this.isBillable) {
5880
+ return 'billable'
5881
+ } else if (this.isCancelled) {
5882
+ return 'cancelled'
5883
+ } else if (this.isInvalid) {
5884
+ return 'invalid'
5885
+ } else if (this.isExpired) {
5886
+ return 'expired'
5887
+ } else {
5888
+ return 'open'
5889
+ }
5890
+ }
5891
+ get isActive() {
5892
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid
5893
+ }
5894
+ get isBillable() {
5895
+ return this.isFulfilled && !this.isPosted && !this.isCancelled
5896
+ }
5897
+ get isOpen() {
5898
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid && !this.isFulfilled
5899
+ }
5900
+
5779
5901
  get isCompleted() {
5780
5902
  return this.status.isCompleted
5781
5903
  }
5782
-
5783
- get isProcessing() {
5784
- return this.status.isProcessing
5904
+ get isCancelled() {
5905
+ return this.status.isCancelled
5785
5906
  }
5786
-
5787
- get isTerminated() {
5788
- return this.status.isTerminated
5907
+ get isExpired() {
5908
+ return !this.isPosted && !this.isCancelled && this.status.isExpired
5789
5909
  }
5910
+ get isFulfilled() {
5911
+ return this.status.isFulfilled
5912
+ }
5913
+ get isInvalid() {
5914
+ return !this.isPosted && !this.isCancelled && this.status.isInvalid
5915
+ }
5916
+ get isPosted() {
5917
+ return this.status.isPosted
5918
+ }
5919
+
5920
+ // get isTerminated() {
5921
+ // return this.status.isTerminated
5922
+ // }
5790
5923
 
5791
5924
  get isValid() {
5792
5925
  return super.isValid && !!this.merchandiseCode
@@ -5830,6 +5963,7 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5830
5963
 
5831
5964
  getPreservedData() {
5832
5965
  return {
5966
+ created: this.created,
5833
5967
  orderCode: this.orderCode,
5834
5968
  orderLineCode: this.orderLineCode,
5835
5969
  orderLineType: this.orderLineType,
@@ -5854,11 +5988,31 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5854
5988
  return this.amount ? this.amount.getCurrencyCode() : null
5855
5989
  }
5856
5990
 
5991
+ setCancelled(value, actorCode) {
5992
+ this.status.setCancelled(value, actorCode)
5993
+ return this.setModified()
5994
+ }
5995
+
5857
5996
  setCompleted(value, actorCode) {
5858
5997
  this.status.setCompleted(value, actorCode)
5859
5998
  return this.setModified()
5860
5999
  }
5861
6000
 
6001
+ setFulfilled(value, actorCode) {
6002
+ this.status.setFulfilled(value, actorCode)
6003
+ return this.setModified()
6004
+ }
6005
+
6006
+ setInvalid(value, actorCode) {
6007
+ this.status.setInvalid(value, actorCode)
6008
+ return this.setModified()
6009
+ }
6010
+
6011
+ setPosted(value, actorCode) {
6012
+ this.status.setPosted(value, actorCode)
6013
+ return this.setModified()
6014
+ }
6015
+
5862
6016
  setQty(qty) {
5863
6017
  if (typeof qty === 'number' && qty > 0) {
5864
6018
  this.qty = qty
@@ -5867,42 +6021,20 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5867
6021
  return this.qty
5868
6022
  }
5869
6023
 
5870
- settle(service) {
5871
- if (!service) {
5872
- return this
5873
- }
5874
-
5875
- if (service.end) {
5876
- this.setCompleted()
5877
- }
5878
-
5879
- return this
5880
- }
5881
-
5882
- // setCompleted() {
5883
- // this.status.setCompleted()
6024
+ // setProcessing() {
6025
+ // this.status.setProcessing()
5884
6026
  // return this.setModified()
5885
6027
  // }
5886
6028
 
5887
- setCancelled() {
5888
- this.status.setCancelled()
5889
- return this.setModified()
5890
- }
5891
-
5892
- setProcessing() {
5893
- this.status.setProcessing()
5894
- return this.setModified()
5895
- }
5896
-
5897
- setTerminated() {
5898
- this.status.setTerminated()
6029
+ setTerminated(value, actorCode) {
6030
+ this.status.setTerminated(value, actorCode)
5899
6031
  return this.setModified()
5900
6032
  }
5901
6033
 
5902
- setWaived() {
5903
- this.status.setWaived()
5904
- return this.setModified()
5905
- }
6034
+ // setWaived() {
6035
+ // this.status.setWaived()
6036
+ // return this.setModified()
6037
+ // }
5906
6038
 
5907
6039
  update(obj) {
5908
6040
  Object.keys(obj).forEach((key) => {
@@ -5969,7 +6101,7 @@ class Order extends q_utilities_namespaceObject.TenantAwareEntity {
5969
6101
  const { _Amount, _OrderLine, _Status } = options._constructor || {}
5970
6102
  this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
5971
6103
  this._OrderLine = _OrderLine && (_OrderLine._superclass === OrderLine._superclass) ? _OrderLine : OrderLine
5972
- this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
6104
+ this._Status = _Status && (_Status._superclass === StatusQStoreOrder._superclass) ? _Status : StatusQStoreOrder
5973
6105
 
5974
6106
  this._orderLines = options._orderLines
5975
6107
 
@@ -6036,6 +6168,11 @@ class Order extends q_utilities_namespaceObject.TenantAwareEntity {
6036
6168
  return this
6037
6169
  }
6038
6170
 
6171
+ setClosed(value, actorCode) {
6172
+ this.status.setClosed(value, actorCode)
6173
+ return this.setModified()
6174
+ }
6175
+
6039
6176
  setCompleted() {
6040
6177
  this.status.setCompleted()
6041
6178
  return this.setModified()
package/dist/index.min.js CHANGED
@@ -72,6 +72,7 @@ __webpack_require__.d(__webpack_exports__, {
72
72
  nW: () => (/* reexport */ Status),
73
73
  TM: () => (/* reexport */ StatusQStore),
74
74
  M: () => (/* reexport */ StatusQStoreInvoice),
75
+ z9: () => (/* reexport */ StatusQStoreOrder),
75
76
  Dy: () => (/* reexport */ StatusQStoreOrderLine),
76
77
  vB: () => (/* reexport */ StoreItem),
77
78
  ZX: () => (/* reexport */ Transaction),
@@ -133,6 +134,7 @@ __webpack_require__.d(models_namespaceObject, {
133
134
  Status: () => (Status),
134
135
  StatusQStore: () => (StatusQStore),
135
136
  StatusQStoreInvoice: () => (StatusQStoreInvoice),
137
+ StatusQStoreOrder: () => (StatusQStoreOrder),
136
138
  StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
137
139
  StoreItem: () => (StoreItem),
138
140
  Transaction: () => (Transaction),
@@ -1945,7 +1947,7 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
1945
1947
  super(options)
1946
1948
 
1947
1949
  const { _ItemOption, _ItemOptionFillIn, _MerchandiseOption, _Price, _Product } = options._constructor || {}
1948
- this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _I_ItemOptiontemOptionFillIn : ItemOption
1950
+ this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _ItemOption : ItemOption
1949
1951
  this._ItemOptionFillIn = _ItemOptionFillIn && (_ItemOptionFillIn._superclass === ItemOptionFillIn._superclass) ? _ItemOptionFillIn : ItemOptionFillIn
1950
1952
  this._MerchandiseOption = _MerchandiseOption && (_MerchandiseOption._superclass === MerchandiseOption._superclass) ? _MerchandiseOption : MerchandiseOption
1951
1953
  this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
@@ -2282,11 +2284,20 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
2282
2284
  }
2283
2285
  getPreservedData() {
2284
2286
  return {
2287
+ allowEditQty: this.allowEditQty,
2288
+ allowEditUnitPrice: this.allowEditUnitPrice,
2289
+ defaultCurrency: this.defaultCurrency,
2290
+ description: this.description,
2291
+ merchandiseCategoryCodes: this.merchandiseCategoryCodes,
2285
2292
  merchandiseCode: this.merchandiseCode,
2293
+ merchandiseOptions: this.merchandiseOptions,
2286
2294
  merchandiseType: this.merchandiseType,
2287
2295
  metadata: this.metadata,
2288
2296
  name: this.name,
2297
+ priority: this.priority,
2289
2298
  productCodes: this.productCodes,
2299
+ sku: this.sku,
2300
+ stock: this.stock,
2290
2301
  tenantCode: this.tenantCode,
2291
2302
  }
2292
2303
  }
@@ -3913,10 +3924,10 @@ class StatusQStoreInvoice extends StatusQStore {
3913
3924
  return 'StatusQStoreInvoice'
3914
3925
  }
3915
3926
  get isClosed() {
3916
- return this.closed?.timestamp > Date.now()
3927
+ return this.closed?.timestamp > 0
3917
3928
  }
3918
3929
  get isOpen() {
3919
- return this.open?.timestamp > Date.now()
3930
+ return this.open?.timestamp > 0
3920
3931
  }
3921
3932
  get isValid() {
3922
3933
  return super.isValid
@@ -3929,6 +3940,64 @@ class StatusQStoreInvoice extends StatusQStore {
3929
3940
  }
3930
3941
  }
3931
3942
 
3943
+ ;// ./lib/models/statusQStore/statusQStoreOrder.js
3944
+
3945
+
3946
+ const statusQStoreOrder_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
3947
+ ]))
3948
+
3949
+ class StatusQStoreOrder extends StatusQStore {
3950
+ constructor(options) {
3951
+ options = options || {}
3952
+ super(options)
3953
+ this.closed = this._ActionRecord.init(options.closed)
3954
+ // this.expired = this._ActionRecord.init(options.expired)
3955
+ // this.fulfilled = this._ActionRecord.init(options.fulfilled)
3956
+ // this.invalid = this._ActionRecord.init(options.invalid)
3957
+ // this.posted = this._ActionRecord.init(options.posted)
3958
+ }
3959
+
3960
+ static get _classname() {
3961
+ return 'StatusQStoreOrder'
3962
+ }
3963
+ get _classname() {
3964
+ return 'StatusQStoreOrder'
3965
+ }
3966
+ get isClosed() {
3967
+ return this.closed?.timestamp > 0
3968
+ }
3969
+ // get isExpired() {
3970
+ // return this.expired?.timestamp < Date.now()
3971
+ // }
3972
+ // get isFulfilled() {
3973
+ // return this.fulfilled?.timestamp > 0
3974
+ // }
3975
+ // get isInvalid() {
3976
+ // return this.invalid?.timestamp < Date.now()
3977
+ // }
3978
+ // get isPosted() {
3979
+ // return this.posted?.timestamp > 0
3980
+ // }
3981
+ // get isValid() {
3982
+ // return super.isValid
3983
+ // }
3984
+ setClosed(value, actorCode) {
3985
+ return this.setValue(value, actorCode, 'closed')
3986
+ }
3987
+ // setExpired(value, actorCode) {
3988
+ // return this.setValue(value, actorCode, 'expired')
3989
+ // }
3990
+ // setFulfilled(value, actorCode) {
3991
+ // return this.setValue(value, actorCode, 'fulfilled')
3992
+ // }
3993
+ // setInvalid(value, actorCode) {
3994
+ // return this.setValue(value, actorCode, 'invalid')
3995
+ // }
3996
+ // setPosted(value, actorCode) {
3997
+ // return this.setValue(value, actorCode, 'posted')
3998
+ // }
3999
+ }
4000
+
3932
4001
  ;// ./lib/models/statusQStore/statusQStoreOrderLine.js
3933
4002
 
3934
4003
 
@@ -3941,7 +4010,9 @@ class StatusQStoreOrderLine extends StatusQStore {
3941
4010
  super(options)
3942
4011
 
3943
4012
  this.expired = this._ActionRecord.init(options.expired)
4013
+ this.fulfilled = this._ActionRecord.init(options.fulfilled)
3944
4014
  this.invalid = this._ActionRecord.init(options.invalid)
4015
+ this.posted = this._ActionRecord.init(options.posted)
3945
4016
  }
3946
4017
 
3947
4018
  static get _classname() {
@@ -3951,20 +4022,32 @@ class StatusQStoreOrderLine extends StatusQStore {
3951
4022
  return 'StatusQStoreOrderLine'
3952
4023
  }
3953
4024
  get isExpired() {
3954
- return this.expired?.timestamp > Date.now()
4025
+ return this.expired?.timestamp < Date.now()
4026
+ }
4027
+ get isFulfilled() {
4028
+ return this.fulfilled?.timestamp > 0
3955
4029
  }
3956
4030
  get isInvalid() {
3957
- return this.invalid?.timestamp > Date.now()
4031
+ return this.invalid?.timestamp < Date.now()
3958
4032
  }
3959
- get isValid() {
3960
- return super.isValid
4033
+ get isPosted() {
4034
+ return this.posted?.timestamp > 0
3961
4035
  }
4036
+ // get isValid() {
4037
+ // return super.isValid
4038
+ // }
3962
4039
  setExpired(value, actorCode) {
3963
4040
  return this.setValue(value, actorCode, 'expired')
3964
4041
  }
4042
+ setFulfilled(value, actorCode) {
4043
+ return this.setValue(value, actorCode, 'fulfilled')
4044
+ }
3965
4045
  setInvalid(value, actorCode) {
3966
4046
  return this.setValue(value, actorCode, 'invalid')
3967
4047
  }
4048
+ setPosted(value, actorCode) {
4049
+ return this.setValue(value, actorCode, 'posted')
4050
+ }
3968
4051
  // update(update) {
3969
4052
  // Object.keys(update).forEach((key) => {
3970
4053
  // if (!notUpdateAllowedProps.includes(key)) {
@@ -3982,6 +4065,7 @@ class StatusQStoreOrderLine extends StatusQStore {
3982
4065
 
3983
4066
 
3984
4067
 
4068
+
3985
4069
  ;// ./lib/models/paymentCharge/paymentCharge.js
3986
4070
 
3987
4071
 
@@ -4095,7 +4179,12 @@ function paymentCharge_setId(id) {
4095
4179
 
4096
4180
  const receiptLine_updateAllowedProps = [
4097
4181
  'additionalData',
4182
+ 'amount',
4183
+ 'paidAmount',
4184
+ 'paymentGatewayCode',
4185
+ 'receiptDate',
4098
4186
  'status',
4187
+ 'surcharge'
4099
4188
  ]
4100
4189
 
4101
4190
  class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
@@ -4204,6 +4293,8 @@ class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
4204
4293
  this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(obj[key])
4205
4294
  } else if (key === 'status') {
4206
4295
  this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
4296
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4297
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4207
4298
  } else {
4208
4299
  this[key] = obj[key]
4209
4300
  }
@@ -4234,7 +4325,12 @@ function receiptLine_setId(id) {
4234
4325
 
4235
4326
 
4236
4327
  const receipt_updateAllowedProps = [
4328
+ 'amount',
4329
+ 'paidAmount',
4330
+ 'receiptDate',
4331
+ 'revisionNumber',
4237
4332
  'status',
4333
+ 'surcharge'
4238
4334
  ]
4239
4335
 
4240
4336
  class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
@@ -4254,7 +4350,6 @@ class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
4254
4350
  this._type = options._type || 'Receipt'
4255
4351
  this.amount = this._Amount.init(options.amount)
4256
4352
  this.paidAmount = this._Amount.init(options.paidAmount)
4257
- this.paymentGatewayCode = options.paymentGatewayCode
4258
4353
  this.receiptCode = options.receiptCode
4259
4354
  this.receiptDate = options.receiptDate || (new Date()).valueOf()
4260
4355
  this.receiptNumber = options.receiptNumber
@@ -4339,6 +4434,8 @@ class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
4339
4434
  if (receipt_updateAllowedProps.includes(key)) {
4340
4435
  if (key === 'status') {
4341
4436
  this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
4437
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4438
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4342
4439
  } else {
4343
4440
  this[key] = obj[key]
4344
4441
  }
@@ -5772,17 +5869,53 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5772
5869
  return 'OrderLine'
5773
5870
  }
5774
5871
 
5872
+ get currentStatus() {
5873
+ if (this.isPosted) {
5874
+ return 'posted'
5875
+ } else if (this.isBillable) {
5876
+ return 'billable'
5877
+ } else if (this.isCancelled) {
5878
+ return 'cancelled'
5879
+ } else if (this.isInvalid) {
5880
+ return 'invalid'
5881
+ } else if (this.isExpired) {
5882
+ return 'expired'
5883
+ } else {
5884
+ return 'open'
5885
+ }
5886
+ }
5887
+ get isActive() {
5888
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid
5889
+ }
5890
+ get isBillable() {
5891
+ return this.isFulfilled && !this.isPosted && !this.isCancelled
5892
+ }
5893
+ get isOpen() {
5894
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid && !this.isFulfilled
5895
+ }
5896
+
5775
5897
  get isCompleted() {
5776
5898
  return this.status.isCompleted
5777
5899
  }
5778
-
5779
- get isProcessing() {
5780
- return this.status.isProcessing
5900
+ get isCancelled() {
5901
+ return this.status.isCancelled
5781
5902
  }
5782
-
5783
- get isTerminated() {
5784
- return this.status.isTerminated
5903
+ get isExpired() {
5904
+ return !this.isPosted && !this.isCancelled && this.status.isExpired
5785
5905
  }
5906
+ get isFulfilled() {
5907
+ return this.status.isFulfilled
5908
+ }
5909
+ get isInvalid() {
5910
+ return !this.isPosted && !this.isCancelled && this.status.isInvalid
5911
+ }
5912
+ get isPosted() {
5913
+ return this.status.isPosted
5914
+ }
5915
+
5916
+ // get isTerminated() {
5917
+ // return this.status.isTerminated
5918
+ // }
5786
5919
 
5787
5920
  get isValid() {
5788
5921
  return super.isValid && !!this.merchandiseCode
@@ -5826,6 +5959,7 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5826
5959
 
5827
5960
  getPreservedData() {
5828
5961
  return {
5962
+ created: this.created,
5829
5963
  orderCode: this.orderCode,
5830
5964
  orderLineCode: this.orderLineCode,
5831
5965
  orderLineType: this.orderLineType,
@@ -5850,11 +5984,31 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5850
5984
  return this.amount ? this.amount.getCurrencyCode() : null
5851
5985
  }
5852
5986
 
5987
+ setCancelled(value, actorCode) {
5988
+ this.status.setCancelled(value, actorCode)
5989
+ return this.setModified()
5990
+ }
5991
+
5853
5992
  setCompleted(value, actorCode) {
5854
5993
  this.status.setCompleted(value, actorCode)
5855
5994
  return this.setModified()
5856
5995
  }
5857
5996
 
5997
+ setFulfilled(value, actorCode) {
5998
+ this.status.setFulfilled(value, actorCode)
5999
+ return this.setModified()
6000
+ }
6001
+
6002
+ setInvalid(value, actorCode) {
6003
+ this.status.setInvalid(value, actorCode)
6004
+ return this.setModified()
6005
+ }
6006
+
6007
+ setPosted(value, actorCode) {
6008
+ this.status.setPosted(value, actorCode)
6009
+ return this.setModified()
6010
+ }
6011
+
5858
6012
  setQty(qty) {
5859
6013
  if (typeof qty === 'number' && qty > 0) {
5860
6014
  this.qty = qty
@@ -5863,42 +6017,20 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
5863
6017
  return this.qty
5864
6018
  }
5865
6019
 
5866
- settle(service) {
5867
- if (!service) {
5868
- return this
5869
- }
5870
-
5871
- if (service.end) {
5872
- this.setCompleted()
5873
- }
5874
-
5875
- return this
5876
- }
5877
-
5878
- // setCompleted() {
5879
- // this.status.setCompleted()
6020
+ // setProcessing() {
6021
+ // this.status.setProcessing()
5880
6022
  // return this.setModified()
5881
6023
  // }
5882
6024
 
5883
- setCancelled() {
5884
- this.status.setCancelled()
5885
- return this.setModified()
5886
- }
5887
-
5888
- setProcessing() {
5889
- this.status.setProcessing()
5890
- return this.setModified()
5891
- }
5892
-
5893
- setTerminated() {
5894
- this.status.setTerminated()
6025
+ setTerminated(value, actorCode) {
6026
+ this.status.setTerminated(value, actorCode)
5895
6027
  return this.setModified()
5896
6028
  }
5897
6029
 
5898
- setWaived() {
5899
- this.status.setWaived()
5900
- return this.setModified()
5901
- }
6030
+ // setWaived() {
6031
+ // this.status.setWaived()
6032
+ // return this.setModified()
6033
+ // }
5902
6034
 
5903
6035
  update(obj) {
5904
6036
  Object.keys(obj).forEach((key) => {
@@ -5965,7 +6097,7 @@ class Order extends q_utilities_namespaceObject.TenantAwareEntity {
5965
6097
  const { _Amount, _OrderLine, _Status } = options._constructor || {}
5966
6098
  this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
5967
6099
  this._OrderLine = _OrderLine && (_OrderLine._superclass === OrderLine._superclass) ? _OrderLine : OrderLine
5968
- this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
6100
+ this._Status = _Status && (_Status._superclass === StatusQStoreOrder._superclass) ? _Status : StatusQStoreOrder
5969
6101
 
5970
6102
  this._orderLines = options._orderLines
5971
6103
 
@@ -6032,6 +6164,11 @@ class Order extends q_utilities_namespaceObject.TenantAwareEntity {
6032
6164
  return this
6033
6165
  }
6034
6166
 
6167
+ setClosed(value, actorCode) {
6168
+ this.status.setClosed(value, actorCode)
6169
+ return this.setModified()
6170
+ }
6171
+
6035
6172
  setCompleted() {
6036
6173
  this.status.setCompleted()
6037
6174
  return this.setModified()
@@ -8830,6 +8967,7 @@ var __webpack_exports__ReceiptLine = __webpack_exports__.Hx;
8830
8967
  var __webpack_exports__Status = __webpack_exports__.nW;
8831
8968
  var __webpack_exports__StatusQStore = __webpack_exports__.TM;
8832
8969
  var __webpack_exports__StatusQStoreInvoice = __webpack_exports__.M;
8970
+ var __webpack_exports__StatusQStoreOrder = __webpack_exports__.z9;
8833
8971
  var __webpack_exports__StatusQStoreOrderLine = __webpack_exports__.Dy;
8834
8972
  var __webpack_exports__StoreItem = __webpack_exports__.vB;
8835
8973
  var __webpack_exports__Transaction = __webpack_exports__.ZX;
@@ -8855,4 +8993,4 @@ var __webpack_exports__objectComparator = __webpack_exports__.aL;
8855
8993
  var __webpack_exports__objectOrderInArrayComparator = __webpack_exports__.il;
8856
8994
  var __webpack_exports__setQuery = __webpack_exports__.NY;
8857
8995
  var __webpack_exports__stringHelper = __webpack_exports__.yO;
8858
- export { __webpack_exports__Amount as Amount, __webpack_exports__BillingAccount as BillingAccount, __webpack_exports__BillingProject as BillingProject, __webpack_exports__Cart as Cart, __webpack_exports__CartItem as CartItem, __webpack_exports__Category as Category, __webpack_exports__Chain as Chain, __webpack_exports__ChainManager as ChainManager, __webpack_exports__ChainManagerFactory as ChainManagerFactory, __webpack_exports__ChainTarget as ChainTarget, __webpack_exports__CouponManager as CouponManager, __webpack_exports__CreditNote as CreditNote, __webpack_exports__CreditNoteLine as CreditNoteLine, __webpack_exports__CreditNoteRepo as CreditNoteRepo, __webpack_exports__Currency as Currency, __webpack_exports__Invoice as Invoice, __webpack_exports__InvoiceLine as InvoiceLine, __webpack_exports__ItemOption as ItemOption, __webpack_exports__ItemOptionLocale as ItemOptionLocale, __webpack_exports__KeyValueObject as KeyValueObject, __webpack_exports__Merchandise as Merchandise, __webpack_exports__Order as Order, __webpack_exports__OrderLine as OrderLine, __webpack_exports__PaymentCharge as PaymentCharge, __webpack_exports__PaymentGateway as PaymentGateway, __webpack_exports__PaymentItem as PaymentItem, __webpack_exports__PaymentResult as PaymentResult, __webpack_exports__Price as Price, __webpack_exports__PriceStrategy as PriceStrategy, __webpack_exports__Product as Product, __webpack_exports__Receipt as Receipt, __webpack_exports__ReceiptLine as ReceiptLine, __webpack_exports__Status as Status, __webpack_exports__StatusQStore as StatusQStore, __webpack_exports__StatusQStoreInvoice as StatusQStoreInvoice, __webpack_exports__StatusQStoreOrderLine as StatusQStoreOrderLine, __webpack_exports__StoreItem as StoreItem, __webpack_exports__Transaction as Transaction, __webpack_exports__WalletItem as WalletItem, __webpack_exports__adminSettle as adminSettle, __webpack_exports__calculateByCoupon as calculateByCoupon, __webpack_exports__calculator as calculator, __webpack_exports__checkDuplicate as checkDuplicate, __webpack_exports__convertTimestampToString as convertTimestampToString, __webpack_exports__defaultComparator as defaultComparator, __webpack_exports__defaultSort as defaultSort, __webpack_exports__eleInArrayComparator as eleInArrayComparator, __webpack_exports__firstLetterToLower as firstLetterToLower, __webpack_exports__getFakeClass as getFakeClass, __webpack_exports__getSubClass as getSubClass, __webpack_exports__handlerOrderList as handlerOrderList, __webpack_exports__isAllEqual as isAllEqual, __webpack_exports__isDescendingOrder as isDescendingOrder, __webpack_exports__makeResponseHelper as makeResponseHelper, __webpack_exports__models as models, __webpack_exports__objectAllInArrayComparator as objectAllInArrayComparator, __webpack_exports__objectComparator as objectComparator, __webpack_exports__objectOrderInArrayComparator as objectOrderInArrayComparator, __webpack_exports__setQuery as setQuery, __webpack_exports__stringHelper as stringHelper };
8996
+ export { __webpack_exports__Amount as Amount, __webpack_exports__BillingAccount as BillingAccount, __webpack_exports__BillingProject as BillingProject, __webpack_exports__Cart as Cart, __webpack_exports__CartItem as CartItem, __webpack_exports__Category as Category, __webpack_exports__Chain as Chain, __webpack_exports__ChainManager as ChainManager, __webpack_exports__ChainManagerFactory as ChainManagerFactory, __webpack_exports__ChainTarget as ChainTarget, __webpack_exports__CouponManager as CouponManager, __webpack_exports__CreditNote as CreditNote, __webpack_exports__CreditNoteLine as CreditNoteLine, __webpack_exports__CreditNoteRepo as CreditNoteRepo, __webpack_exports__Currency as Currency, __webpack_exports__Invoice as Invoice, __webpack_exports__InvoiceLine as InvoiceLine, __webpack_exports__ItemOption as ItemOption, __webpack_exports__ItemOptionLocale as ItemOptionLocale, __webpack_exports__KeyValueObject as KeyValueObject, __webpack_exports__Merchandise as Merchandise, __webpack_exports__Order as Order, __webpack_exports__OrderLine as OrderLine, __webpack_exports__PaymentCharge as PaymentCharge, __webpack_exports__PaymentGateway as PaymentGateway, __webpack_exports__PaymentItem as PaymentItem, __webpack_exports__PaymentResult as PaymentResult, __webpack_exports__Price as Price, __webpack_exports__PriceStrategy as PriceStrategy, __webpack_exports__Product as Product, __webpack_exports__Receipt as Receipt, __webpack_exports__ReceiptLine as ReceiptLine, __webpack_exports__Status as Status, __webpack_exports__StatusQStore as StatusQStore, __webpack_exports__StatusQStoreInvoice as StatusQStoreInvoice, __webpack_exports__StatusQStoreOrder as StatusQStoreOrder, __webpack_exports__StatusQStoreOrderLine as StatusQStoreOrderLine, __webpack_exports__StoreItem as StoreItem, __webpack_exports__Transaction as Transaction, __webpack_exports__WalletItem as WalletItem, __webpack_exports__adminSettle as adminSettle, __webpack_exports__calculateByCoupon as calculateByCoupon, __webpack_exports__calculator as calculator, __webpack_exports__checkDuplicate as checkDuplicate, __webpack_exports__convertTimestampToString as convertTimestampToString, __webpack_exports__defaultComparator as defaultComparator, __webpack_exports__defaultSort as defaultSort, __webpack_exports__eleInArrayComparator as eleInArrayComparator, __webpack_exports__firstLetterToLower as firstLetterToLower, __webpack_exports__getFakeClass as getFakeClass, __webpack_exports__getSubClass as getSubClass, __webpack_exports__handlerOrderList as handlerOrderList, __webpack_exports__isAllEqual as isAllEqual, __webpack_exports__isDescendingOrder as isDescendingOrder, __webpack_exports__makeResponseHelper as makeResponseHelper, __webpack_exports__models as models, __webpack_exports__objectAllInArrayComparator as objectAllInArrayComparator, __webpack_exports__objectComparator as objectComparator, __webpack_exports__objectOrderInArrayComparator as objectOrderInArrayComparator, __webpack_exports__setQuery as setQuery, __webpack_exports__stringHelper as stringHelper };
@@ -122,6 +122,7 @@ __webpack_require__.d(__webpack_exports__, {
122
122
  Status: () => (/* reexport */ Status),
123
123
  StatusQStore: () => (/* reexport */ StatusQStore),
124
124
  StatusQStoreInvoice: () => (/* reexport */ StatusQStoreInvoice),
125
+ StatusQStoreOrder: () => (/* reexport */ StatusQStoreOrder),
125
126
  StatusQStoreOrderLine: () => (/* reexport */ StatusQStoreOrderLine),
126
127
  StoreItem: () => (/* reexport */ StoreItem),
127
128
  Transaction: () => (/* reexport */ Transaction),
@@ -183,6 +184,7 @@ __webpack_require__.d(models_namespaceObject, {
183
184
  Status: () => (Status),
184
185
  StatusQStore: () => (StatusQStore),
185
186
  StatusQStoreInvoice: () => (StatusQStoreInvoice),
187
+ StatusQStoreOrder: () => (StatusQStoreOrder),
186
188
  StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
187
189
  StoreItem: () => (StoreItem),
188
190
  Transaction: () => (Transaction),
@@ -1987,7 +1989,7 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
1987
1989
  super(options)
1988
1990
 
1989
1991
  const { _ItemOption, _ItemOptionFillIn, _MerchandiseOption, _Price, _Product } = options._constructor || {}
1990
- this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _I_ItemOptiontemOptionFillIn : ItemOption
1992
+ this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption._superclass) ? _ItemOption : ItemOption
1991
1993
  this._ItemOptionFillIn = _ItemOptionFillIn && (_ItemOptionFillIn._superclass === ItemOptionFillIn._superclass) ? _ItemOptionFillIn : ItemOptionFillIn
1992
1994
  this._MerchandiseOption = _MerchandiseOption && (_MerchandiseOption._superclass === MerchandiseOption._superclass) ? _MerchandiseOption : MerchandiseOption
1993
1995
  this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
@@ -2324,11 +2326,20 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
2324
2326
  }
2325
2327
  getPreservedData() {
2326
2328
  return {
2329
+ allowEditQty: this.allowEditQty,
2330
+ allowEditUnitPrice: this.allowEditUnitPrice,
2331
+ defaultCurrency: this.defaultCurrency,
2332
+ description: this.description,
2333
+ merchandiseCategoryCodes: this.merchandiseCategoryCodes,
2327
2334
  merchandiseCode: this.merchandiseCode,
2335
+ merchandiseOptions: this.merchandiseOptions,
2328
2336
  merchandiseType: this.merchandiseType,
2329
2337
  metadata: this.metadata,
2330
2338
  name: this.name,
2339
+ priority: this.priority,
2331
2340
  productCodes: this.productCodes,
2341
+ sku: this.sku,
2342
+ stock: this.stock,
2332
2343
  tenantCode: this.tenantCode,
2333
2344
  }
2334
2345
  }
@@ -3955,10 +3966,10 @@ class StatusQStoreInvoice extends StatusQStore {
3955
3966
  return 'StatusQStoreInvoice'
3956
3967
  }
3957
3968
  get isClosed() {
3958
- return this.closed?.timestamp > Date.now()
3969
+ return this.closed?.timestamp > 0
3959
3970
  }
3960
3971
  get isOpen() {
3961
- return this.open?.timestamp > Date.now()
3972
+ return this.open?.timestamp > 0
3962
3973
  }
3963
3974
  get isValid() {
3964
3975
  return super.isValid
@@ -3971,6 +3982,64 @@ class StatusQStoreInvoice extends StatusQStore {
3971
3982
  }
3972
3983
  }
3973
3984
 
3985
+ ;// ./lib/models/statusQStore/statusQStoreOrder.js
3986
+
3987
+
3988
+ const statusQStoreOrder_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
3989
+ ]))
3990
+
3991
+ class StatusQStoreOrder extends StatusQStore {
3992
+ constructor(options) {
3993
+ options = options || {}
3994
+ super(options)
3995
+ this.closed = this._ActionRecord.init(options.closed)
3996
+ // this.expired = this._ActionRecord.init(options.expired)
3997
+ // this.fulfilled = this._ActionRecord.init(options.fulfilled)
3998
+ // this.invalid = this._ActionRecord.init(options.invalid)
3999
+ // this.posted = this._ActionRecord.init(options.posted)
4000
+ }
4001
+
4002
+ static get _classname() {
4003
+ return 'StatusQStoreOrder'
4004
+ }
4005
+ get _classname() {
4006
+ return 'StatusQStoreOrder'
4007
+ }
4008
+ get isClosed() {
4009
+ return this.closed?.timestamp > 0
4010
+ }
4011
+ // get isExpired() {
4012
+ // return this.expired?.timestamp < Date.now()
4013
+ // }
4014
+ // get isFulfilled() {
4015
+ // return this.fulfilled?.timestamp > 0
4016
+ // }
4017
+ // get isInvalid() {
4018
+ // return this.invalid?.timestamp < Date.now()
4019
+ // }
4020
+ // get isPosted() {
4021
+ // return this.posted?.timestamp > 0
4022
+ // }
4023
+ // get isValid() {
4024
+ // return super.isValid
4025
+ // }
4026
+ setClosed(value, actorCode) {
4027
+ return this.setValue(value, actorCode, 'closed')
4028
+ }
4029
+ // setExpired(value, actorCode) {
4030
+ // return this.setValue(value, actorCode, 'expired')
4031
+ // }
4032
+ // setFulfilled(value, actorCode) {
4033
+ // return this.setValue(value, actorCode, 'fulfilled')
4034
+ // }
4035
+ // setInvalid(value, actorCode) {
4036
+ // return this.setValue(value, actorCode, 'invalid')
4037
+ // }
4038
+ // setPosted(value, actorCode) {
4039
+ // return this.setValue(value, actorCode, 'posted')
4040
+ // }
4041
+ }
4042
+
3974
4043
  ;// ./lib/models/statusQStore/statusQStoreOrderLine.js
3975
4044
 
3976
4045
 
@@ -3983,7 +4052,9 @@ class StatusQStoreOrderLine extends StatusQStore {
3983
4052
  super(options)
3984
4053
 
3985
4054
  this.expired = this._ActionRecord.init(options.expired)
4055
+ this.fulfilled = this._ActionRecord.init(options.fulfilled)
3986
4056
  this.invalid = this._ActionRecord.init(options.invalid)
4057
+ this.posted = this._ActionRecord.init(options.posted)
3987
4058
  }
3988
4059
 
3989
4060
  static get _classname() {
@@ -3993,20 +4064,32 @@ class StatusQStoreOrderLine extends StatusQStore {
3993
4064
  return 'StatusQStoreOrderLine'
3994
4065
  }
3995
4066
  get isExpired() {
3996
- return this.expired?.timestamp > Date.now()
4067
+ return this.expired?.timestamp < Date.now()
4068
+ }
4069
+ get isFulfilled() {
4070
+ return this.fulfilled?.timestamp > 0
3997
4071
  }
3998
4072
  get isInvalid() {
3999
- return this.invalid?.timestamp > Date.now()
4073
+ return this.invalid?.timestamp < Date.now()
4000
4074
  }
4001
- get isValid() {
4002
- return super.isValid
4075
+ get isPosted() {
4076
+ return this.posted?.timestamp > 0
4003
4077
  }
4078
+ // get isValid() {
4079
+ // return super.isValid
4080
+ // }
4004
4081
  setExpired(value, actorCode) {
4005
4082
  return this.setValue(value, actorCode, 'expired')
4006
4083
  }
4084
+ setFulfilled(value, actorCode) {
4085
+ return this.setValue(value, actorCode, 'fulfilled')
4086
+ }
4007
4087
  setInvalid(value, actorCode) {
4008
4088
  return this.setValue(value, actorCode, 'invalid')
4009
4089
  }
4090
+ setPosted(value, actorCode) {
4091
+ return this.setValue(value, actorCode, 'posted')
4092
+ }
4010
4093
  // update(update) {
4011
4094
  // Object.keys(update).forEach((key) => {
4012
4095
  // if (!notUpdateAllowedProps.includes(key)) {
@@ -4024,6 +4107,7 @@ class StatusQStoreOrderLine extends StatusQStore {
4024
4107
 
4025
4108
 
4026
4109
 
4110
+
4027
4111
  ;// ./lib/models/paymentCharge/paymentCharge.js
4028
4112
 
4029
4113
 
@@ -4137,7 +4221,12 @@ function paymentCharge_setId(id) {
4137
4221
 
4138
4222
  const receiptLine_updateAllowedProps = [
4139
4223
  'additionalData',
4224
+ 'amount',
4225
+ 'paidAmount',
4226
+ 'paymentGatewayCode',
4227
+ 'receiptDate',
4140
4228
  'status',
4229
+ 'surcharge'
4141
4230
  ]
4142
4231
 
4143
4232
  class ReceiptLine extends q_utilities_.TenantAwareEntity {
@@ -4246,6 +4335,8 @@ class ReceiptLine extends q_utilities_.TenantAwareEntity {
4246
4335
  this[key] = q_utilities_.KeyValueObject.initOnlyValidFromArray(obj[key])
4247
4336
  } else if (key === 'status') {
4248
4337
  this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
4338
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4339
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4249
4340
  } else {
4250
4341
  this[key] = obj[key]
4251
4342
  }
@@ -4276,7 +4367,12 @@ function receiptLine_setId(id) {
4276
4367
 
4277
4368
 
4278
4369
  const receipt_updateAllowedProps = [
4370
+ 'amount',
4371
+ 'paidAmount',
4372
+ 'receiptDate',
4373
+ 'revisionNumber',
4279
4374
  'status',
4375
+ 'surcharge'
4280
4376
  ]
4281
4377
 
4282
4378
  class Receipt extends q_utilities_.TenantAwareEntity {
@@ -4296,7 +4392,6 @@ class Receipt extends q_utilities_.TenantAwareEntity {
4296
4392
  this._type = options._type || 'Receipt'
4297
4393
  this.amount = this._Amount.init(options.amount)
4298
4394
  this.paidAmount = this._Amount.init(options.paidAmount)
4299
- this.paymentGatewayCode = options.paymentGatewayCode
4300
4395
  this.receiptCode = options.receiptCode
4301
4396
  this.receiptDate = options.receiptDate || (new Date()).valueOf()
4302
4397
  this.receiptNumber = options.receiptNumber
@@ -4381,6 +4476,8 @@ class Receipt extends q_utilities_.TenantAwareEntity {
4381
4476
  if (receipt_updateAllowedProps.includes(key)) {
4382
4477
  if (key === 'status') {
4383
4478
  this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
4479
+ } else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
4480
+ this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
4384
4481
  } else {
4385
4482
  this[key] = obj[key]
4386
4483
  }
@@ -5814,17 +5911,53 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
5814
5911
  return 'OrderLine'
5815
5912
  }
5816
5913
 
5914
+ get currentStatus() {
5915
+ if (this.isPosted) {
5916
+ return 'posted'
5917
+ } else if (this.isBillable) {
5918
+ return 'billable'
5919
+ } else if (this.isCancelled) {
5920
+ return 'cancelled'
5921
+ } else if (this.isInvalid) {
5922
+ return 'invalid'
5923
+ } else if (this.isExpired) {
5924
+ return 'expired'
5925
+ } else {
5926
+ return 'open'
5927
+ }
5928
+ }
5929
+ get isActive() {
5930
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid
5931
+ }
5932
+ get isBillable() {
5933
+ return this.isFulfilled && !this.isPosted && !this.isCancelled
5934
+ }
5935
+ get isOpen() {
5936
+ return !this.isPosted && !this.isCancelled && !this.isExpired && !this.isInvalid && !this.isFulfilled
5937
+ }
5938
+
5817
5939
  get isCompleted() {
5818
5940
  return this.status.isCompleted
5819
5941
  }
5820
-
5821
- get isProcessing() {
5822
- return this.status.isProcessing
5942
+ get isCancelled() {
5943
+ return this.status.isCancelled
5823
5944
  }
5824
-
5825
- get isTerminated() {
5826
- return this.status.isTerminated
5945
+ get isExpired() {
5946
+ return !this.isPosted && !this.isCancelled && this.status.isExpired
5827
5947
  }
5948
+ get isFulfilled() {
5949
+ return this.status.isFulfilled
5950
+ }
5951
+ get isInvalid() {
5952
+ return !this.isPosted && !this.isCancelled && this.status.isInvalid
5953
+ }
5954
+ get isPosted() {
5955
+ return this.status.isPosted
5956
+ }
5957
+
5958
+ // get isTerminated() {
5959
+ // return this.status.isTerminated
5960
+ // }
5828
5961
 
5829
5962
  get isValid() {
5830
5963
  return super.isValid && !!this.merchandiseCode
@@ -5868,6 +6001,7 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
5868
6001
 
5869
6002
  getPreservedData() {
5870
6003
  return {
6004
+ created: this.created,
5871
6005
  orderCode: this.orderCode,
5872
6006
  orderLineCode: this.orderLineCode,
5873
6007
  orderLineType: this.orderLineType,
@@ -5892,11 +6026,31 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
5892
6026
  return this.amount ? this.amount.getCurrencyCode() : null
5893
6027
  }
5894
6028
 
6029
+ setCancelled(value, actorCode) {
6030
+ this.status.setCancelled(value, actorCode)
6031
+ return this.setModified()
6032
+ }
6033
+
5895
6034
  setCompleted(value, actorCode) {
5896
6035
  this.status.setCompleted(value, actorCode)
5897
6036
  return this.setModified()
5898
6037
  }
5899
6038
 
6039
+ setFulfilled(value, actorCode) {
6040
+ this.status.setFulfilled(value, actorCode)
6041
+ return this.setModified()
6042
+ }
6043
+
6044
+ setInvalid(value, actorCode) {
6045
+ this.status.setInvalid(value, actorCode)
6046
+ return this.setModified()
6047
+ }
6048
+
6049
+ setPosted(value, actorCode) {
6050
+ this.status.setPosted(value, actorCode)
6051
+ return this.setModified()
6052
+ }
6053
+
5900
6054
  setQty(qty) {
5901
6055
  if (typeof qty === 'number' && qty > 0) {
5902
6056
  this.qty = qty
@@ -5905,42 +6059,20 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
5905
6059
  return this.qty
5906
6060
  }
5907
6061
 
5908
- settle(service) {
5909
- if (!service) {
5910
- return this
5911
- }
5912
-
5913
- if (service.end) {
5914
- this.setCompleted()
5915
- }
5916
-
5917
- return this
5918
- }
5919
-
5920
- // setCompleted() {
5921
- // this.status.setCompleted()
6062
+ // setProcessing() {
6063
+ // this.status.setProcessing()
5922
6064
  // return this.setModified()
5923
6065
  // }
5924
6066
 
5925
- setCancelled() {
5926
- this.status.setCancelled()
5927
- return this.setModified()
5928
- }
5929
-
5930
- setProcessing() {
5931
- this.status.setProcessing()
5932
- return this.setModified()
5933
- }
5934
-
5935
- setTerminated() {
5936
- this.status.setTerminated()
6067
+ setTerminated(value, actorCode) {
6068
+ this.status.setTerminated(value, actorCode)
5937
6069
  return this.setModified()
5938
6070
  }
5939
6071
 
5940
- setWaived() {
5941
- this.status.setWaived()
5942
- return this.setModified()
5943
- }
6072
+ // setWaived() {
6073
+ // this.status.setWaived()
6074
+ // return this.setModified()
6075
+ // }
5944
6076
 
5945
6077
  update(obj) {
5946
6078
  Object.keys(obj).forEach((key) => {
@@ -6007,7 +6139,7 @@ class Order extends q_utilities_.TenantAwareEntity {
6007
6139
  const { _Amount, _OrderLine, _Status } = options._constructor || {}
6008
6140
  this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
6009
6141
  this._OrderLine = _OrderLine && (_OrderLine._superclass === OrderLine._superclass) ? _OrderLine : OrderLine
6010
- this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
6142
+ this._Status = _Status && (_Status._superclass === StatusQStoreOrder._superclass) ? _Status : StatusQStoreOrder
6011
6143
 
6012
6144
  this._orderLines = options._orderLines
6013
6145
 
@@ -6074,6 +6206,11 @@ class Order extends q_utilities_.TenantAwareEntity {
6074
6206
  return this
6075
6207
  }
6076
6208
 
6209
+ setClosed(value, actorCode) {
6210
+ this.status.setClosed(value, actorCode)
6211
+ return this.setModified()
6212
+ }
6213
+
6077
6214
  setCompleted() {
6078
6215
  this.status.setCompleted()
6079
6216
  return this.setModified()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@questwork/q-store-model",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "Questwork QStore Model",
5
5
  "main": "dist/index.min.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@questwork/q-utilities": "^0.1.24",
27
+ "@questwork/q-utilities": "^0.1.30",
28
28
  "lodash": "^4.17.21"
29
29
  },
30
30
  "devDependencies": {