@things-factory/operato-hub 4.3.823 → 4.3.825

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.
@@ -2,12 +2,14 @@ import Router from 'koa-router'
2
2
  import { EntityManager, getConnection, getRepository, In, Not, SelectQueryBuilder } from 'typeorm'
3
3
  import { v4 as uuidv4 } from 'uuid'
4
4
 
5
+ import { User } from '@things-factory/auth-base'
5
6
  import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
6
7
  import { logger } from '@things-factory/env'
7
8
  import { generateId } from '@things-factory/id-rule-base'
8
9
  import {
9
10
  ACCOUNT_PLATFORM,
10
11
  ACCOUNT_SYNC_STATUS,
12
+ Account,
11
13
  AccountingAPI,
12
14
  AccountWebhookOrder,
13
15
  Xilnex
@@ -560,7 +562,8 @@ xilnexRouter.post('/webhook-xilnex-transfer-note', async (context, next) => {
560
562
  customerBizplace,
561
563
  warehouseDomain,
562
564
  context,
563
- tx
565
+ tx,
566
+ account.id
564
567
  )
565
568
  } else {
566
569
  const assignedOrderProducts = await assignToInventory(
@@ -918,7 +921,8 @@ xilnexRouter.post('/webhook-xilnex-stock-request', async (context, next) => {
918
921
  customerBizplace,
919
922
  warehouseDomain,
920
923
  context,
921
- tx
924
+ tx,
925
+ account.id
922
926
  )
923
927
  } else {
924
928
  const assignedOrderProducts = await assignToInventory(
@@ -1750,6 +1754,10 @@ async function createReleaseGood(
1750
1754
  status: ORDER_STATUS.PENDING_WORKSHEET,
1751
1755
  noOfItems: orderProducts.length,
1752
1756
  source: releaseGood?.source,
1757
+ // Stamp the integration platform so the Release Good list page's
1758
+ // Platform column displays "XILNEX" instead of blank/stale values.
1759
+ // Mirrors the platformCode set in createDraftReleaseGood.
1760
+ platformCode: ACCOUNT_PLATFORM.XILNEX,
1753
1761
  paidAmount: releaseGood?.paidAmount,
1754
1762
  discountAmount: releaseGood?.discountAmount,
1755
1763
  taxAmount: releaseGood?.taxAmount,
@@ -1819,9 +1827,24 @@ async function createDraftReleaseGood(
1819
1827
  bizplace: Bizplace,
1820
1828
  domain: Domain,
1821
1829
  context: any,
1822
- tx: EntityManager
1830
+ tx: EntityManager,
1831
+ accountId: string
1823
1832
  ): Promise<DraftReleaseGood> {
1824
- const { user }: { user: any } = context.state
1833
+ let { user }: { user: any } = context.state
1834
+
1835
+ // The Xilnex webhook routes are mounted on a public route with no auth
1836
+ // middleware, so context.state.user is undefined. Fall back to the user
1837
+ // who configured this Xilnex integration (Account.creator) so the
1838
+ // DraftReleaseGood and its OrderProduct rows have a meaningful
1839
+ // creator_id / updater_id for downstream UI (the Draft Release Good list
1840
+ // page filters/displays by creator and renders nothing when it's null).
1841
+ if (!user) {
1842
+ const account: Account = await tx.getRepository(Account).findOne({
1843
+ where: { id: accountId },
1844
+ relations: ['creator']
1845
+ })
1846
+ user = account?.creator || null
1847
+ }
1825
1848
 
1826
1849
  if (orderProducts.length <= 0) {
1827
1850
  throw new ValidationError({
@@ -1857,6 +1880,11 @@ async function createDraftReleaseGood(
1857
1880
  releaseDate: releaseGood.releaseDate,
1858
1881
  remark: releaseGood?.remark || null,
1859
1882
  source: releaseGood?.source,
1883
+ // Stamp the integration platform so the Draft Release Good list page
1884
+ // displays "XILNEX" in the Platform column. Without this, platformCode
1885
+ // is null and the UI either shows blank or carries over stale values
1886
+ // from other draft origins.
1887
+ platformCode: ACCOUNT_PLATFORM.XILNEX,
1860
1888
  status: DRAFT_RELEASE_ORDER_STATUS.DRAFT,
1861
1889
  creator: user,
1862
1890
  updater: user