@things-factory/sales-base 4.1.3 → 4.1.8

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.
Files changed (22) hide show
  1. package/dist-server/controllers/ecommerce/sellercraft-controller.js +9 -1
  2. package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
  3. package/dist-server/service/arrival-notice/arrival-notice-mutation.js +10 -6
  4. package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
  5. package/dist-server/service/order-product/order-product-mutation.js +18 -0
  6. package/dist-server/service/order-product/order-product-mutation.js.map +1 -1
  7. package/dist-server/service/release-good/release-good-mutation.js +14 -7
  8. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  9. package/dist-server/service/release-good/release-good-types.js +4 -0
  10. package/dist-server/service/release-good/release-good-types.js.map +1 -1
  11. package/dist-server/service/return-order/return-order-mutation.js +8 -4
  12. package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
  13. package/dist-server/service/vas-order/vas-order-mutation.js +6 -4
  14. package/dist-server/service/vas-order/vas-order-mutation.js.map +1 -1
  15. package/package.json +13 -12
  16. package/server/controllers/ecommerce/sellercraft-controller.ts +12 -1
  17. package/server/service/arrival-notice/arrival-notice-mutation.ts +5 -5
  18. package/server/service/order-product/order-product-mutation.ts +20 -1
  19. package/server/service/release-good/release-good-mutation.ts +11 -5
  20. package/server/service/release-good/release-good-types.ts +3 -0
  21. package/server/service/return-order/return-order-mutation.ts +4 -4
  22. package/server/service/vas-order/vas-order-mutation.ts +6 -4
@@ -172,7 +172,7 @@ export class ArrivalNoticeMutation {
172
172
  const users: any[] = await getDomainUsers(arrivalNotice?.bizplace, tx)
173
173
  debug('users', users)
174
174
 
175
- if (users?.length) {
175
+ if (users?.length && context.header?.referer) {
176
176
  const receivers: any[] = users.map(user => user.id)
177
177
  const msg = {
178
178
  title: `Products are added/edited for ${arrivalNotice.name}`,
@@ -599,7 +599,7 @@ export async function confirmArrivalNoticeFunction(
599
599
  .getRawMany()
600
600
 
601
601
  // send notification to Office Admin Users
602
- if (users?.length) {
602
+ if (users?.length && context.header?.referer) {
603
603
  const receivers: any[] = users.map(user => user.id)
604
604
  const msg = {
605
605
  title: `New Arrival Notice from ${customerBizplace.name}`,
@@ -671,7 +671,7 @@ export async function receiveArrivalNoticeFunction(_: any, name: String, context
671
671
  const users: any[] = await getDomainUsers(foundArrivalNotice?.bizplace, tx)
672
672
 
673
673
  // send notification to Customer Users
674
- if (users?.length) {
674
+ if (users?.length && context.header?.referer) {
675
675
  const receivers: any[] = users.map(user => user.id)
676
676
  const msg = {
677
677
  title: `Latest status for ${foundArrivalNotice.name}`,
@@ -761,7 +761,7 @@ export async function checkArrivedNoticeFunction(
761
761
  // notification logics
762
762
  const users: any[] = await getDomainUsers(foundArrivalNotice?.bizplace, tx)
763
763
 
764
- if (users?.length) {
764
+ if (users?.length && context.header?.referer) {
765
765
  const receivers: any[] = users.map(user => user.id)
766
766
  const msg = {
767
767
  title: `Latest status for ${foundArrivalNotice.name}`,
@@ -838,7 +838,7 @@ export async function rejectArrivalNotice(
838
838
  const users: any[] = await getDomainUsers(foundArrivalNotice?.bizplace, tx)
839
839
 
840
840
  // send notification to Customer Users
841
- if (users?.length) {
841
+ if (users?.length && context.header?.referer) {
842
842
  const receivers: any[] = users.map(user => user.id)
843
843
  const msg = {
844
844
  title: `Latest status for ${foundArrivalNotice.name}`,
@@ -1,10 +1,29 @@
1
- import { Domain } from '@things-factory/shell'
2
1
  import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
3
2
  import { EntityManager, In } from 'typeorm'
3
+
4
+ import { Domain } from '@things-factory/shell'
5
+
4
6
  import { OrderProduct } from './order-product'
7
+ import { OrderProductPatch } from './order-product-types'
5
8
 
6
9
  @Resolver(OrderProduct)
7
10
  export class OrderProductMutation {
11
+ @Directive('@transaction')
12
+ @Mutation(returns => OrderProduct)
13
+ async updateOrderProduct(
14
+ @Ctx() context: any,
15
+ @Arg('name') name: string,
16
+ @Arg('patch', type => OrderProductPatch) patch: OrderProductPatch
17
+ ): Promise<OrderProduct> {
18
+ const { tx, domain, user } = context.state
19
+
20
+ let foundOP: OrderProduct = await tx.getRepository(OrderProduct).findOne({
21
+ where: { domain, name }
22
+ })
23
+
24
+ return await tx.getRepository(OrderProduct).save({ ...foundOP, ...patch, updater: user })
25
+ }
26
+
8
27
  @Directive('@transaction')
9
28
  @Mutation(returns => Boolean)
10
29
  async deleteOrderProduct(@Arg('name') name: string, @Ctx() context: any): Promise<boolean> {
@@ -14,6 +14,7 @@ import {
14
14
  import { generateId } from '@things-factory/id-rule-base'
15
15
  import { MarketplaceStore } from '@things-factory/integration-marketplace'
16
16
  import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
17
+ import { Sftp } from '@things-factory/integration-sftp'
17
18
  import { MarketplaceOrder, MarketplaceProductVariation } from '@things-factory/marketplace-base'
18
19
  import { sendNotification } from '@things-factory/notification'
19
20
  import { Product, ProductBundleSetting } from '@things-factory/product-base'
@@ -133,7 +134,7 @@ export class ReleaseGoodMutation {
133
134
  context,
134
135
  tx
135
136
  )
136
- } catch (error) { }
137
+ } catch (error) {}
137
138
 
138
139
  if (errorsCaught.length)
139
140
  throw new ValidationError({
@@ -451,9 +452,14 @@ export async function generateReleaseGoodFunction(
451
452
  .getRepository(Sellercraft)
452
453
  .findOne({ domain: bizplace.domain, status: SellercraftStatus.ACTIVE })
453
454
 
455
+ let customerAvailableSftp: Sftp = await tx.getRepository(Sftp).findOne({
456
+ where: { domain: bizplace.domain }
457
+ })
458
+
454
459
  if (sellercraft) {
455
460
  const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
456
461
  await sellercraftCtrl.checkExistingReleaseGood(sellercraft, releaseGood)
462
+ } else if (customerAvailableSftp) {
457
463
  } else {
458
464
  const refNo: string = releaseGood.refNo
459
465
  const foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
@@ -890,7 +896,7 @@ export async function confirmReleaseGood(name: string, context: any, tx?: Entity
890
896
  .getRawMany()
891
897
 
892
898
  // send notification to Office Admin Users
893
- if (users?.length) {
899
+ if (users?.length && context.header?.referer) {
894
900
  const receivers: any[] = users.map(user => user.id)
895
901
  const msg = {
896
902
  title: `New Release Order from ${customerBizplace.name}`,
@@ -972,7 +978,7 @@ export async function receiveReleaseGood(name: string, context: any, tx: EntityM
972
978
  .getRawMany()
973
979
 
974
980
  // send notification to Office Admin Users
975
- if (users?.length) {
981
+ if (users?.length && context.header?.referer) {
976
982
  const receivers: any[] = users.map(user => user.id)
977
983
  const msg = {
978
984
  title: `New Release Order from ${customerBizplace.name}`,
@@ -1095,7 +1101,7 @@ export async function rejectReleaseGood(
1095
1101
  // notification logics
1096
1102
  const users: any[] = await getDomainUsers(releaseGood?.bizplace, tx)
1097
1103
 
1098
- if (users?.length) {
1104
+ if (users?.length && context.header?.referer) {
1099
1105
  const receivers: any[] = users.map(user => user.id)
1100
1106
  const msg = {
1101
1107
  title: `Latest status for ${releaseGood.name}`,
@@ -1290,7 +1296,7 @@ export async function bulkConfirmReleaseGoods(
1290
1296
  .getRawMany()
1291
1297
 
1292
1298
  // send notification to Office Admin Users
1293
- if (users?.length) {
1299
+ if (users?.length && context.header?.referer) {
1294
1300
  const receivers: any[] = users.map(user => user.id)
1295
1301
  const message = {
1296
1302
  title: `New Release Order from ${customerBizplace.name}`,
@@ -342,6 +342,9 @@ export class NewReleaseGood {
342
342
  @Field({ nullable: true })
343
343
  remainUomValue: number
344
344
 
345
+ @Field({ nullable: true })
346
+ remark: string
347
+
345
348
  @Field({ nullable: true })
346
349
  errorMsg: string
347
350
  }
@@ -276,7 +276,7 @@ export async function confirmReturnOrder(tx: EntityManager, name: string, contex
276
276
  .getRawMany()
277
277
 
278
278
  // send notification to Office Admin Users
279
- if (users?.length) {
279
+ if (users?.length && context.header?.referer) {
280
280
  const receivers: any[] = users.map(user => user.id)
281
281
  const msg = {
282
282
  title: `New Return Order from ${customerBizplace.name}`,
@@ -340,7 +340,7 @@ export async function receiveReturnOrder(tx: EntityManager, name: string, contex
340
340
  // notification logics
341
341
  const users: any[] = await getDomainUsers(foundReturnOrder?.bizplace, tx)
342
342
 
343
- if (users?.length) {
343
+ if (users?.length && context.header?.referer) {
344
344
  const receivers: any[] = users.map(user => user.id)
345
345
  const msg = {
346
346
  title: `Latest status for ${foundReturnOrder.name}`,
@@ -407,7 +407,7 @@ export async function rejectReturnOrder(
407
407
  // notification logics
408
408
  const users: any[] = await getDomainUsers(foundReturnOrder?.bizplace, tx)
409
409
 
410
- if (users?.length) {
410
+ if (users?.length && context.header?.referer) {
411
411
  const receivers: any[] = users.map(user => user.id)
412
412
  const msg = {
413
413
  title: `Latest status for ${foundReturnOrder.name}`,
@@ -467,7 +467,7 @@ export async function checkReturnOrder(tx: EntityManager, name: string, context:
467
467
  // notification logics
468
468
  const users: any[] = await getDomainUsers(foundReturnOrder?.bizplace, tx)
469
469
 
470
- if (users?.length) {
470
+ if (users?.length && context.header?.referer) {
471
471
  const receivers: any[] = users.map(user => user.id)
472
472
  const msg = {
473
473
  title: `Latest status for ${foundReturnOrder.name}`,
@@ -1,10 +1,12 @@
1
+ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
+ import { EntityManager, In } from 'typeorm'
3
+
1
4
  import { Role, User } from '@things-factory/auth-base'
2
5
  import { Bizplace } from '@things-factory/biz-base'
3
6
  import { sendNotification } from '@things-factory/notification'
4
7
  import { Product } from '@things-factory/product-base'
5
8
  import { Domain } from '@things-factory/shell'
6
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
7
- import { EntityManager, In } from 'typeorm'
9
+
8
10
  import { NewOrderVas, NewVasOrder, OrderVas, Vas, VasOrderPatch } from '../'
9
11
  import { ORDER_STATUS, ORDER_TYPES, ORDER_VAS_STATUS } from '../../constants'
10
12
  import { OrderNoGenerator } from '../../utils'
@@ -154,7 +156,7 @@ export class VasOrderMutation {
154
156
  .getRawMany()
155
157
 
156
158
  // send notification to Office Admin Users
157
- if (users?.length) {
159
+ if (users?.length && context.header?.referer) {
158
160
  const receivers: any[] = users.map(user => user.id)
159
161
  const msg = {
160
162
  title: `New VAS Order from ${customerBizplace.name}`,
@@ -224,7 +226,7 @@ export class VasOrderMutation {
224
226
  .getRawMany()
225
227
 
226
228
  // send notification to Customer Users
227
- if (users?.length) {
229
+ if (users?.length && context.header?.referer) {
228
230
  const receivers: any[] = users.map(user => user.id)
229
231
  const msg = {
230
232
  title: `Latest status for ${vasOrder.name}`,