@things-factory/sales-base 4.3.576 → 4.3.579
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.
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js +44 -2
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +101 -19
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +8 -0
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
- package/dist-server/service/invoice/invoice.js +15 -0
- package/dist-server/service/invoice/invoice.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +8 -0
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-product/order-product.js +5 -0
- package/dist-server/service/order-product/order-product.js.map +1 -1
- package/dist-server/service/others/other-query.js +3 -0
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +4 -0
- package/dist-server/service/others/other-types.js.map +1 -1
- package/package.json +2 -2
- package/server/service/arrival-notice/arrival-notice-mutation.ts +48 -3
- package/server/service/arrival-notice/arrival-notice-query.ts +107 -21
- package/server/service/arrival-notice/arrival-notice-types.ts +8 -0
- package/server/service/invoice/invoice.ts +12 -0
- package/server/service/order-product/order-product-types.ts +6 -0
- package/server/service/order-product/order-product.ts +4 -0
- package/server/service/others/other-query.ts +3 -0
- package/server/service/others/other-types.ts +3 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { EntityManager, getRepository, In, SelectQueryBuilder } from 'typeorm'
|
|
2
|
+
import { EntityManager, getRepository, In, Raw, SelectQueryBuilder } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { Attachment } from '@things-factory/attachment-base'
|
|
5
5
|
import { checkUserBelongsDomain, User } from '@things-factory/auth-base'
|
|
6
6
|
import { Bizplace, getCompanyBizplace, getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
7
|
-
import { ProductDetail } from '@things-factory/product-base'
|
|
8
7
|
import { buildQuery, Domain, ListParam } from '@things-factory/shell'
|
|
9
8
|
|
|
10
9
|
import { ArrivalNoticeList, NewArrivalNotice, RawArrivalNotice } from '../'
|
|
11
10
|
import { ATTACHMENT_TYPE, ORDER_STATUS } from '../../constants'
|
|
12
11
|
import { OrderInventory, OrderProduct } from '../../service'
|
|
13
12
|
import { ArrivalNotice } from './arrival-notice'
|
|
13
|
+
import { Setting } from '@things-factory/setting-base'
|
|
14
14
|
|
|
15
15
|
@Resolver(ArrivalNotice)
|
|
16
16
|
export class ArrivalNoticeQuery {
|
|
@@ -365,11 +365,39 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
365
365
|
uom: raw.uom || null,
|
|
366
366
|
pack_qty: raw.packQty || null,
|
|
367
367
|
pallet_qty: raw.palletQty || null,
|
|
368
|
+
pallet_id: raw.palletId || null,
|
|
368
369
|
unit_price: raw.unitPrice === undefined ? (isNaN(raw.unitPrice) ? '' : null) : raw.unitPrice,
|
|
369
370
|
manufacture_date: raw.manufactureDate || null
|
|
370
371
|
}
|
|
371
372
|
})
|
|
372
373
|
)
|
|
374
|
+
|
|
375
|
+
const enableLotIdInput: Setting = await trxMgr.getRepository(Setting).findOne({
|
|
376
|
+
where: { domain, category: 'id-rule', name: 'enable-lot-id-input' }
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
//check if palletId is entered but enablelotidinput setting is false
|
|
380
|
+
let lotIdInputSettingChecker = ''
|
|
381
|
+
if (rawArrivalNotices.some(record => record.palletId) && enableLotIdInput.value == 'false') {
|
|
382
|
+
lotIdInputSettingChecker = 'Please enable the setting to create orders with a custom Lot ID';
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// uncomment this to show error message as popup
|
|
386
|
+
|
|
387
|
+
// for (let item of rawArrivalNotices) {
|
|
388
|
+
// if (item.palletId) {
|
|
389
|
+
// const foundOrderProductsPallet = await trxMgr.getRepository(OrderProduct).findOne({
|
|
390
|
+
// where: {
|
|
391
|
+
// domain,
|
|
392
|
+
// palletId: item.palletId
|
|
393
|
+
// }
|
|
394
|
+
// })
|
|
395
|
+
|
|
396
|
+
// if (foundOrderProductsPallet) {
|
|
397
|
+
// throw new Error(('Lot ID is already in used. Please enter new Lot ID.'))
|
|
398
|
+
// }
|
|
399
|
+
// }
|
|
400
|
+
// }
|
|
373
401
|
|
|
374
402
|
await trxMgr.query(
|
|
375
403
|
`
|
|
@@ -393,6 +421,7 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
393
421
|
uom VARCHAR(10),
|
|
394
422
|
pack_qty INT,
|
|
395
423
|
pallet_qty INT,
|
|
424
|
+
pallet_id VARCHAR(50),
|
|
396
425
|
unit_price VARCHAR(50),
|
|
397
426
|
manufacture_date DATE
|
|
398
427
|
);
|
|
@@ -431,7 +460,7 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
431
460
|
SELECT
|
|
432
461
|
js.ref_no, js.ref_no_2, js.ref_no_3, js.eta_date, js.truck_no, js.own_transport, js.container,
|
|
433
462
|
js.container_no, js.container_size, js.import_cargo, js.loose_item, js.sku, js.batch_id,
|
|
434
|
-
js.batch_id_ref, js.packing_type, js.packing_size, js.uom, js.pack_qty, js.pallet_qty,
|
|
463
|
+
js.batch_id_ref, js.packing_type, js.packing_size, js.uom, js.pack_qty, js.pallet_qty, js.pallet_id,
|
|
435
464
|
js.unit_price, js.manufacture_date
|
|
436
465
|
FROM
|
|
437
466
|
JSON_POPULATE_RECORDSET(NULL:: raw_arrival_notices, $1) js;
|
|
@@ -470,6 +499,7 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
470
499
|
pd.packing_size,
|
|
471
500
|
pd.cost_price,
|
|
472
501
|
sum(raw.pack_qty) AS pack_qty,
|
|
502
|
+
raw.pallet_id,
|
|
473
503
|
sum(pd.uom_value) AS uom_value,
|
|
474
504
|
pd.uom,
|
|
475
505
|
sum(raw.pallet_qty) AS pallet_qty,
|
|
@@ -499,25 +529,80 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
499
529
|
END
|
|
500
530
|
WHERE pr.bizplace_id = $1
|
|
501
531
|
GROUP BY raw.ref_no, raw.ref_no_2, raw.ref_no_3, raw.eta_date, raw.truck_no, raw.own_transport, raw.container, raw.container_no, raw.container_size, raw.import_cargo, raw.loose_item,
|
|
502
|
-
pr.id, pd.id, raw.sku, pr.name, pr.description, raw.batch_id, raw.batch_id_ref, raw.packing_type, raw.packing_size, raw.uom, raw.unit_price, raw.manufacture_date, an.ref_no, an.name
|
|
503
|
-
)
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
532
|
+
pr.id, pd.id, raw.sku, pr.name, pr.description, raw.batch_id, raw.batch_id_ref, raw.packing_type, raw.pallet_id, raw.packing_size, raw.uom, raw.unit_price, raw.manufacture_date, an.ref_no, an.name
|
|
533
|
+
), foo_duplicates AS (
|
|
534
|
+
SELECT
|
|
535
|
+
pallet_id,
|
|
536
|
+
COUNT(*) AS duplicate_count
|
|
537
|
+
FROM foo
|
|
538
|
+
GROUP BY pallet_id
|
|
539
|
+
)
|
|
540
|
+
SELECT foo.*,
|
|
541
|
+
CONCAT(COALESCE(ROUND(foo.uom_value:: numeric, 2), 0) * COALESCE(foo.pack_qty, 0), ' ', foo.uom) AS total_uom_value,
|
|
542
|
+
TRIM(
|
|
543
|
+
BOTH ',' FROM (
|
|
544
|
+
CASE
|
|
545
|
+
WHEN foo.gan_ref_no IS NOT NULL THEN 'order duplicated with ' || foo.gan_name || ','
|
|
546
|
+
ELSE ''
|
|
547
|
+
END ||
|
|
548
|
+
CASE
|
|
549
|
+
WHEN foo.manufacture_date > current_date THEN 'invalid manufacture date,'
|
|
550
|
+
ELSE ''
|
|
551
|
+
END ||
|
|
552
|
+
CASE
|
|
553
|
+
WHEN foo.product_id IS NULL OR foo.product_detail_id IS NULL OR foo.sku IS NULL THEN 'product not found,'
|
|
554
|
+
ELSE ''
|
|
555
|
+
END ||
|
|
556
|
+
CASE
|
|
557
|
+
WHEN foo.pack_qty IS NULL OR foo.pack_qty <= 0 THEN 'invalid pack qty,'
|
|
558
|
+
ELSE ''
|
|
559
|
+
END ||
|
|
560
|
+
CASE
|
|
561
|
+
WHEN foo.batch_id IS NULL THEN 'batch no. is required,'
|
|
562
|
+
ELSE ''
|
|
563
|
+
END ||
|
|
564
|
+
CASE
|
|
565
|
+
WHEN foo.ref_no IS NULL OR foo.ref_no = '' THEN 'ref no. is required,'
|
|
566
|
+
ELSE ''
|
|
567
|
+
END ||
|
|
568
|
+
CASE
|
|
569
|
+
WHEN foo.eta_date IS NULL THEN 'eta date is required,'
|
|
570
|
+
ELSE ''
|
|
571
|
+
END ||
|
|
572
|
+
CASE
|
|
573
|
+
WHEN foo.unit_price IS NULL THEN 'invalid unit price (not a number),'
|
|
574
|
+
ELSE ''
|
|
575
|
+
END ||
|
|
576
|
+
CASE
|
|
577
|
+
WHEN foo.unit_price::FLOAT < 0 THEN 'invalid unit price (negative value),'
|
|
578
|
+
ELSE ''
|
|
579
|
+
END ||
|
|
580
|
+
CASE
|
|
581
|
+
WHEN (foo.container_no IS NOT NULL AND foo.container_size IS NULL) OR (foo.container_no IS NULL AND foo.container_size IS NOT NULL) THEN 'incomplete container information,'
|
|
582
|
+
ELSE ''
|
|
583
|
+
END ||
|
|
584
|
+
CASE
|
|
585
|
+
WHEN foo.pallet_qty < 0 THEN 'invalid pallet qty,'
|
|
586
|
+
ELSE ''
|
|
587
|
+
END ||
|
|
588
|
+
CASE
|
|
589
|
+
WHEN (SELECT duplicate_count FROM foo_duplicates WHERE foo_duplicates.pallet_id = foo.pallet_id) > 1 THEN 'duplicate Lot ID within current data,'
|
|
590
|
+
ELSE ''
|
|
591
|
+
END ||
|
|
592
|
+
CASE
|
|
593
|
+
WHEN EXISTS (
|
|
594
|
+
SELECT *
|
|
595
|
+
FROM order_products op
|
|
596
|
+
WHERE op.domain_id = $2 AND op.pallet_id = foo.pallet_id
|
|
597
|
+
) THEN 'Lot ID is already in use. Please enter new Lot ID,'
|
|
598
|
+
ELSE ''
|
|
599
|
+
END
|
|
600
|
+
)
|
|
601
|
+
) AS error_msg
|
|
602
|
+
FROM foo
|
|
518
603
|
ORDER BY foo.ref_no, foo.ref_no_2, foo.ref_no_3, foo.sku
|
|
519
604
|
`,
|
|
520
|
-
[companyBizplace.id]
|
|
605
|
+
[companyBizplace.id,domain.id]
|
|
521
606
|
)
|
|
522
607
|
|
|
523
608
|
await trxMgr.query('DROP TABLE raw_arrival_notices, temp_gan')
|
|
@@ -548,9 +633,10 @@ export async function validateBulkArrivalNoticesFunction(
|
|
|
548
633
|
uomValue: item.uom_value,
|
|
549
634
|
totalUomValue: item.total_uom_value,
|
|
550
635
|
palletQty: item.pallet_qty,
|
|
636
|
+
palletId: item.pallet_id,
|
|
551
637
|
unitPrice: item.unit_price,
|
|
552
638
|
manufactureDate: item.manufacture_date,
|
|
553
|
-
errorMsg: item.error_msg
|
|
639
|
+
errorMsg: lotIdInputSettingChecker ? lotIdInputSettingChecker + (item.error_msg ? ',' + item.error_msg : '') : item.error_msg
|
|
554
640
|
}
|
|
555
641
|
})
|
|
556
642
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
+
import { OneToMany } from 'typeorm'
|
|
2
3
|
|
|
3
4
|
import { ObjectRef } from '@things-factory/shell'
|
|
4
5
|
|
|
5
6
|
import { NewOrderProduct } from '../order-product/order-product-types'
|
|
7
|
+
import { OrderProduct } from '../order-product/order-product'
|
|
6
8
|
import { NewOrderVas } from '../order-vas/order-vas-types'
|
|
7
9
|
import { ArrivalNotice } from './arrival-notice'
|
|
8
10
|
|
|
@@ -122,6 +124,9 @@ export class NewArrivalNotice {
|
|
|
122
124
|
@Field(type => Int, { nullable: true })
|
|
123
125
|
palletQty?: number
|
|
124
126
|
|
|
127
|
+
@Field({ nullable: true })
|
|
128
|
+
palletId?: string
|
|
129
|
+
|
|
125
130
|
@Field(type => Float, { nullable: true })
|
|
126
131
|
unitPrice?: number
|
|
127
132
|
|
|
@@ -302,6 +307,9 @@ export class RawArrivalNotice {
|
|
|
302
307
|
@Field(type => Int, { nullable: true })
|
|
303
308
|
palletQty?: number
|
|
304
309
|
|
|
310
|
+
@Field({ nullable: true })
|
|
311
|
+
palletId?: string
|
|
312
|
+
|
|
305
313
|
@Field(type => Float, { nullable: true })
|
|
306
314
|
unitPrice?: number
|
|
307
315
|
|
|
@@ -226,4 +226,16 @@ export class Invoice {
|
|
|
226
226
|
|
|
227
227
|
@RelationId((invoice: Invoice) => invoice.updater)
|
|
228
228
|
updaterId: string
|
|
229
|
+
|
|
230
|
+
@Column('float', { default: 0 })
|
|
231
|
+
@Field({ nullable: true })
|
|
232
|
+
sellerVoucherAmount: number
|
|
233
|
+
|
|
234
|
+
@Column('float', { default: 0 })
|
|
235
|
+
@Field({ nullable: true })
|
|
236
|
+
platformVoucherAmount: number
|
|
237
|
+
|
|
238
|
+
@Column('float', { default: 0 })
|
|
239
|
+
@Field({ nullable: true })
|
|
240
|
+
platformCoins: number
|
|
229
241
|
}
|
|
@@ -156,6 +156,9 @@ export class OrderProductPatch {
|
|
|
156
156
|
@Field({ nullable: true })
|
|
157
157
|
adjustedTotalUomValue: string
|
|
158
158
|
|
|
159
|
+
@Field({ nullable: true })
|
|
160
|
+
palletId: string
|
|
161
|
+
|
|
159
162
|
@Field({ nullable: true })
|
|
160
163
|
totalUomValue: string
|
|
161
164
|
|
|
@@ -300,6 +303,9 @@ export class NewOrderProduct {
|
|
|
300
303
|
@Field(type => Int, { nullable: true })
|
|
301
304
|
adjustedPalletQty: number
|
|
302
305
|
|
|
306
|
+
@Field({ nullable: true })
|
|
307
|
+
palletId: string
|
|
308
|
+
|
|
303
309
|
@Field({ nullable: true })
|
|
304
310
|
adjustedTotalUomValue: string
|
|
305
311
|
|
|
@@ -314,6 +314,10 @@ export class OrderProduct {
|
|
|
314
314
|
@Field({ nullable: true })
|
|
315
315
|
actualPalletQty: number
|
|
316
316
|
|
|
317
|
+
@Column({ nullable: true })
|
|
318
|
+
@Field({ nullable: true })
|
|
319
|
+
palletId: string
|
|
320
|
+
|
|
317
321
|
@Column({ nullable: true })
|
|
318
322
|
@Field({ nullable: true })
|
|
319
323
|
totalUomValue: string
|
|
@@ -341,6 +341,7 @@ export class OtherQuery {
|
|
|
341
341
|
packing_type: orderProduct.packingType,
|
|
342
342
|
pack_qty: orderProduct.packQty,
|
|
343
343
|
pallet_qty: orderProduct.palletQty,
|
|
344
|
+
pallet_id: orderProduct.palletId,
|
|
344
345
|
unit_price: orderProduct.unitPrice,
|
|
345
346
|
batch_id: orderProduct.batchId,
|
|
346
347
|
uom: orderProduct.uom,
|
|
@@ -359,6 +360,7 @@ export class OtherQuery {
|
|
|
359
360
|
packing_type VARCHAR(50),
|
|
360
361
|
pack_qty FLOAT,
|
|
361
362
|
pallet_qty FLOAT,
|
|
363
|
+
pallet_id VARCHAR(50),
|
|
362
364
|
unit_price FLOAT,
|
|
363
365
|
batch_id VARCHAR(50),
|
|
364
366
|
uom VARCHAR(10),
|
|
@@ -405,6 +407,7 @@ export class OtherQuery {
|
|
|
405
407
|
js.sku,
|
|
406
408
|
js.pack_qty as "packQty",
|
|
407
409
|
js.pallet_qty as "palletQty",
|
|
410
|
+
js.pallet_id as "palletId",
|
|
408
411
|
js.unit_price as "unitPrice",
|
|
409
412
|
js.batch_id as "batchId",
|
|
410
413
|
js.manufacture_date as "manufactureDate",
|