@things-factory/operato-mms 5.0.0-alpha.5 → 5.0.0-alpha.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-mms",
3
- "version": "5.0.0-alpha.5",
3
+ "version": "5.0.0-alpha.50",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -41,69 +41,67 @@
41
41
  "@material/mwc-formfield": "^0.25.3",
42
42
  "@material/mwc-linear-progress": "^0.25.3",
43
43
  "@material/mwc-radio": "^0.25.3",
44
- "@operato/ghost-print": "1.0.0-alpha.4",
45
- "@operato/scene-chartjs": "^0.1.5",
46
- "@operato/scene-clock": "^0.1.5",
47
- "@operato/scene-clone": "^0.1.5",
48
- "@operato/scene-compass": "^0.1.5",
49
- "@operato/scene-gauge": "^0.1.5",
50
- "@operato/scene-grist": "^0.1.5",
51
- "@operato/scene-half-roundrect": "^0.1.5",
52
- "@operato/scene-indoor-map": "^0.1.5",
53
- "@operato/scene-integration": "^0.1.5",
54
- "@operato/scene-legend": "^0.1.5",
55
- "@operato/scene-news-ticker": "^0.1.5",
56
- "@operato/scene-progressbar": "^0.1.5",
57
- "@operato/scene-random": "^0.1.5",
58
- "@operato/scene-switch": "^0.1.5",
59
- "@operato/scene-tab": "^0.1.5",
60
- "@operato/scene-table": "^0.1.5",
61
- "@operato/scene-timer": "^0.1.5",
62
- "@operato/scene-wheel-sorter": "^0.1.5",
63
- "@things-factory/apptool-ui": "^5.0.0-alpha.5",
64
- "@things-factory/attachment-base": "^5.0.0-alpha.5",
65
- "@things-factory/auth-ui": "^5.0.0-alpha.5",
66
- "@things-factory/biz-base": "^5.0.0-alpha.5",
67
- "@things-factory/board-service": "^5.0.0-alpha.5",
68
- "@things-factory/board-ui": "^5.0.0-alpha.5",
69
- "@things-factory/code-ui": "^5.0.0-alpha.5",
70
- "@things-factory/context-ui": "^5.0.0-alpha.5",
71
- "@things-factory/dashboard": "^5.0.0-alpha.5",
72
- "@things-factory/export-ui": "^5.0.0-alpha.5",
73
- "@things-factory/export-ui-csv": "^5.0.0-alpha.5",
74
- "@things-factory/export-ui-excel": "^5.0.0-alpha.5",
75
- "@things-factory/geography": "^5.0.0-alpha.5",
76
- "@things-factory/grist-ui": "^5.0.0-alpha.5",
77
- "@things-factory/help": "^5.0.0-alpha.5",
78
- "@things-factory/i18n-base": "^5.0.0-alpha.5",
79
- "@things-factory/integration-fulfillment": "^5.0.0-alpha.5",
80
- "@things-factory/integration-lmd": "^5.0.0-alpha.5",
81
- "@things-factory/lite-menu": "^5.0.0-alpha.5",
82
- "@things-factory/marketplace-base": "^5.0.0-alpha.5",
83
- "@things-factory/more-ui": "^5.0.0-alpha.5",
84
- "@things-factory/notification": "^5.0.0-alpha.5",
85
- "@things-factory/oauth2-client": "^5.0.0-alpha.5",
86
- "@things-factory/pdf": "^5.0.0-alpha.5",
87
- "@things-factory/product-base": "^5.0.0-alpha.5",
88
- "@things-factory/resource-ui": "^5.0.0-alpha.5",
89
- "@things-factory/scene-data-transform": "^5.0.0-alpha.5",
90
- "@things-factory/scene-excel": "^5.0.0-alpha.5",
91
- "@things-factory/scene-firebase": "^5.0.0-alpha.5",
92
- "@things-factory/scene-form": "^5.0.0-alpha.5",
93
- "@things-factory/scene-google-map": "^5.0.0-alpha.5",
94
- "@things-factory/scene-graphql": "^5.0.0-alpha.5",
95
- "@things-factory/scene-label": "^5.0.0-alpha.5",
96
- "@things-factory/scene-marker": "^5.0.0-alpha.5",
97
- "@things-factory/scene-mqtt": "^5.0.0-alpha.5",
98
- "@things-factory/scene-restful": "^5.0.0-alpha.5",
99
- "@things-factory/scene-visualizer": "^5.0.0-alpha.5",
100
- "@things-factory/setting-ui": "^5.0.0-alpha.5",
101
- "@things-factory/system-ui": "^5.0.0-alpha.5",
102
- "@things-factory/warehouse-base": "^5.0.0-alpha.5"
44
+ "@operato/ghost-print": "1.0.0-beta.20",
45
+ "@operato/scene-chartjs": "^1.0.0-alpha.18",
46
+ "@operato/scene-clock": "^1.0.0-alpha.18",
47
+ "@operato/scene-clone": "^1.0.0-alpha.18",
48
+ "@operato/scene-compass": "^1.0.0-alpha.18",
49
+ "@operato/scene-data-transform": "^1.0.0-alpha.18",
50
+ "@operato/scene-excel": "^1.0.0-alpha.18",
51
+ "@operato/scene-form": "^1.0.0-alpha.18",
52
+ "@operato/scene-gauge": "^1.0.0-alpha.18",
53
+ "@operato/scene-graphql": "^1.0.0-alpha.18",
54
+ "@operato/scene-grist": "^1.0.0-alpha.18",
55
+ "@operato/scene-half-roundrect": "^1.0.0-alpha.18",
56
+ "@operato/scene-indoor-map": "^1.0.0-alpha.18",
57
+ "@operato/scene-integration": "^1.0.0-alpha.18",
58
+ "@operato/scene-label": "^1.0.0-alpha.18",
59
+ "@operato/scene-legend": "^1.0.0-alpha.18",
60
+ "@operato/scene-marker": "^1.0.0-alpha.18",
61
+ "@operato/scene-news-ticker": "^1.0.0-alpha.18",
62
+ "@operato/scene-progressbar": "^1.0.0-alpha.18",
63
+ "@operato/scene-random": "^1.0.0-alpha.18",
64
+ "@operato/scene-restful": "^1.0.0-alpha.18",
65
+ "@operato/scene-switch": "^1.0.0-alpha.18",
66
+ "@operato/scene-tab": "^1.0.0-alpha.18",
67
+ "@operato/scene-table": "^1.0.0-alpha.18",
68
+ "@operato/scene-timer": "^1.0.0-alpha.18",
69
+ "@operato/scene-wheel-sorter": "^1.0.0-alpha.18",
70
+ "@things-factory/apptool-ui": "^5.0.0-alpha.50",
71
+ "@things-factory/attachment-base": "^5.0.0-alpha.50",
72
+ "@things-factory/auth-ui": "^5.0.0-alpha.50",
73
+ "@things-factory/biz-base": "^5.0.0-alpha.50",
74
+ "@things-factory/board-service": "^5.0.0-alpha.50",
75
+ "@things-factory/board-ui": "^5.0.0-alpha.50",
76
+ "@things-factory/code-ui": "^5.0.0-alpha.50",
77
+ "@things-factory/context-ui": "^5.0.0-alpha.50",
78
+ "@things-factory/dashboard": "^5.0.0-alpha.50",
79
+ "@things-factory/export-ui": "^5.0.0-alpha.50",
80
+ "@things-factory/export-ui-csv": "^5.0.0-alpha.50",
81
+ "@things-factory/export-ui-excel": "^5.0.0-alpha.50",
82
+ "@things-factory/geography": "^5.0.0-alpha.50",
83
+ "@things-factory/grist-ui": "^5.0.0-alpha.50",
84
+ "@things-factory/help": "^5.0.0-alpha.50",
85
+ "@things-factory/i18n-base": "^5.0.0-alpha.50",
86
+ "@things-factory/integration-fulfillment": "^5.0.0-alpha.50",
87
+ "@things-factory/integration-lmd": "^5.0.0-alpha.50",
88
+ "@things-factory/lite-menu": "^5.0.0-alpha.50",
89
+ "@things-factory/marketplace-base": "^5.0.0-alpha.50",
90
+ "@things-factory/more-ui": "^5.0.0-alpha.50",
91
+ "@things-factory/notification": "^5.0.0-alpha.50",
92
+ "@things-factory/oauth2-client": "^5.0.0-alpha.50",
93
+ "@things-factory/pdf": "^5.0.0-alpha.50",
94
+ "@things-factory/product-base": "^5.0.0-alpha.50",
95
+ "@things-factory/resource-ui": "^5.0.0-alpha.50",
96
+ "@things-factory/scene-google-map": "^5.0.0-alpha.50",
97
+ "@things-factory/scene-visualizer": "^5.0.0-alpha.50",
98
+ "@things-factory/setting-ui": "^5.0.0-alpha.50",
99
+ "@things-factory/system-ui": "^5.0.0-alpha.50",
100
+ "@things-factory/warehouse-base": "^5.0.0-alpha.50"
103
101
  },
104
102
  "devDependencies": {
105
- "@things-factory/builder": "^5.0.0-alpha.5",
103
+ "@things-factory/builder": "^5.0.0-alpha.50",
106
104
  "@types/node-fetch": "^2.5.7"
107
105
  },
108
- "gitHead": "379449b7be7b3d8220f1cac9ab684b812117edfd"
106
+ "gitHead": "ba819c6d9ddf60319283f620b80c9737e7486a91"
109
107
  }
@@ -42,6 +42,8 @@ export const addReleaseOrderResolver = {
42
42
  ]
43
43
  })
44
44
 
45
+ const marketplaceOrderItems: MarketplaceOrderItem[] = marketplaceOrder.marketplaceOrderItems
46
+
45
47
  let marketplaceOrderShippings: MarketplaceOrderShipping[] = await getRepository(MarketplaceOrderShipping).find({
46
48
  where: { orderNoRef: marketplaceOrder.orderNo, domain },
47
49
  order: { subOrderNoRef: 'ASC' },
@@ -64,7 +66,7 @@ export const addReleaseOrderResolver = {
64
66
  .toString()
65
67
  .padStart(2, '0')}`
66
68
 
67
- const newReleaseOrder: any = {
69
+ var newReleaseOrder: any = {
68
70
  releaseDate,
69
71
  type: 'b2c',
70
72
  transporter: marketplaceOrder.shippingProvider,
@@ -122,86 +124,82 @@ export const addReleaseOrderResolver = {
122
124
  await getRepository(MarketplaceOrder).save(marketplaceOrder)
123
125
  }
124
126
  } catch (e) {}
127
+ }
128
+ }
125
129
 
126
- var invoiceProducts = await Promise.all(
127
- newReleaseOrder.orderInventories.map(async oi => {
128
- let product: Product = await getRepository(Product).findOne({
129
- where: { domain, sku: oi.product.sku }
130
- })
131
-
132
- if (!product) {
133
- product = await getRepository(ProductBundle).findOne({
134
- where: { domain, sku: oi.product.sku }
135
- })
136
- }
137
-
138
- let mosis: MarketplaceOrderShippingItem[] = marketplaceOrderShippingItems.filter(
139
- mosi => mosi.product.sku === product.sku
140
- )
141
-
142
- let moi: MarketplaceOrderItem = mosis[0].marketplaceOrderItem
130
+ var invoiceProducts = await Promise.all(
131
+ marketplaceOrderItems.map(async mi => {
132
+ let product: Product = await getRepository(Product).findOne({
133
+ where: { domain, sku: mi.marketplaceProductVariation.sku }
134
+ })
143
135
 
144
- return {
145
- sku: product.sku,
146
- name: product.name,
147
- description: product.description,
148
- product: { sku: product.sku },
149
- qty: oi.releaseQty,
150
- unitPrice: (moi?.originalPrice || 0) / moi.qty,
151
- paidPrice: (moi?.paidPrice || 0) / moi.qty
152
- }
136
+ let productBundle: ProductBundle
137
+ if (!product) {
138
+ productBundle = await getRepository(ProductBundle).findOne({
139
+ where: { domain, sku: mi.marketplaceProductVariation.sku }
153
140
  })
154
- )
155
-
156
- let newInvoice = {
157
- invoiceProducts,
158
- releaseGood: { id: releaseOrder.id, name: releaseOrder.name },
159
- refNo1: newReleaseOrder.refNo.toString(),
160
- refNo2: newReleaseOrder.refNo2.toString(),
161
- issuedOn: new Date(),
162
- from: marketplaceOrder.marketplaceStore.storeName,
163
- fromContactPhone: '-',
164
- fromAddress1: '-',
165
- fromAddress2: null,
166
- fromAddress3: null,
167
- fromAddress4: null,
168
- fromAddress5: null,
169
- fromPostcode: null,
170
- fromCity: null,
171
- fromState: null,
172
- fromCountry: null,
173
- deliverTo: newReleaseOrder.deliverTo.attentionTo || '-',
174
- deliverToPhone: newReleaseOrder.deliverTo.phone1 || '-',
175
- deliveryAddress1: newReleaseOrder.deliverTo.deliveryAddress1 || '-',
176
- deliveryAddress2: newReleaseOrder.deliverTo.deliveryAddress2,
177
- deliveryAddress3: newReleaseOrder.deliverTo.deliveryAddress3,
178
- deliveryAddress4: newReleaseOrder.deliverTo.deliveryAddress4,
179
- deliveryAddress5: newReleaseOrder.deliverTo.deliveryAddress5,
180
- deliveryPostcode: newReleaseOrder.deliverTo.postalCode || '-',
181
- deliveryCity: newReleaseOrder.deliverTo.city || '-',
182
- deliveryState: newReleaseOrder.deliverTo.state || '-',
183
- deliveryCountry: newReleaseOrder.deliverTo.country || '-',
184
- billTo: newReleaseOrder.deliverTo.attentionTo || '-',
185
- billToPhone: newReleaseOrder.deliverTo.phone1 || '-',
186
- billingAddress1: releaseOrder.billingAddress || newReleaseOrder.deliverTo.deliveryAddress1 || '-',
187
- billingAddress2: null,
188
- billingAddress3: null,
189
- billingAddress4: null,
190
- billingAddress5: null,
191
- billingPostcode: '-',
192
- billingCity: '-',
193
- billingState: '-',
194
- billingCountry: '-'
195
141
  }
196
142
 
197
- try {
198
- await FulfillmentAPI.createSalesInvoice(fulfilmentCenter, {
199
- customerBizplaceId,
200
- invoice: newInvoice
201
- })
202
- } catch (e) {}
203
- }
143
+ return {
144
+ sku: product ? product.sku : productBundle.sku,
145
+ name: product ? product.name : productBundle.name,
146
+ description: product ? product.description : productBundle.description,
147
+ qty: mi.qty,
148
+ unitPrice: (mi?.originalPrice || 0) / mi.qty,
149
+ paidPrice: (mi?.paidPrice || 0) / mi.qty,
150
+ discount: mi?.discount || 0,
151
+ shippingFeePaidByCustomer: mi?.shippingFeePaidByCustomer || 0
152
+ }
153
+ })
154
+ )
155
+
156
+ let newInvoice = {
157
+ invoiceProducts,
158
+ name: '-',
159
+ refNo1: newReleaseOrder.refNo.toString(),
160
+ refNo2: newReleaseOrder.refNo2.toString(),
161
+ issuedOn: new Date(),
162
+ from: marketplaceOrder.marketplaceStore.storeName,
163
+ fromContactPhone: '-',
164
+ fromAddress1: '-',
165
+ fromAddress2: null,
166
+ fromAddress3: null,
167
+ fromAddress4: null,
168
+ fromAddress5: null,
169
+ fromPostcode: null,
170
+ fromCity: null,
171
+ fromState: null,
172
+ fromCountry: null,
173
+ deliverTo: newReleaseOrder.deliverTo.attentionTo || '-',
174
+ deliverToPhone: newReleaseOrder.deliverTo.phone1 || '-',
175
+ deliveryAddress1: newReleaseOrder.deliverTo.deliveryAddress1 || '-',
176
+ deliveryAddress2: newReleaseOrder.deliverTo.deliveryAddress2,
177
+ deliveryAddress3: newReleaseOrder.deliverTo.deliveryAddress3,
178
+ deliveryAddress4: newReleaseOrder.deliverTo.deliveryAddress4,
179
+ deliveryAddress5: newReleaseOrder.deliverTo.deliveryAddress5,
180
+ deliveryPostcode: newReleaseOrder.deliverTo.postalCode || '-',
181
+ deliveryCity: newReleaseOrder.deliverTo.city || '-',
182
+ deliveryState: newReleaseOrder.deliverTo.state || '-',
183
+ deliveryCountry: newReleaseOrder.deliverTo.country || '-',
184
+ billTo: newReleaseOrder.deliverTo.attentionTo || '-',
185
+ billToPhone: newReleaseOrder.deliverTo.phone1 || '-',
186
+ billingAddress1: newReleaseOrder.deliverTo.billingAddress || newReleaseOrder.deliverTo.deliveryAddress1 || '-',
187
+ billingAddress2: null,
188
+ billingAddress3: null,
189
+ billingAddress4: null,
190
+ billingAddress5: null,
191
+ billingPostcode: '-',
192
+ billingCity: '-',
193
+ billingState: '-',
194
+ billingCountry: '-'
204
195
  }
196
+
197
+ try {
198
+ await FulfillmentAPI.createSalesInvoice(fulfilmentCenter, {
199
+ customerBizplaceId,
200
+ invoice: newInvoice
201
+ })
202
+ } catch (e) {}
205
203
  }
206
204
  }
207
205
  }
@@ -42,6 +42,8 @@ export const autoAddReleaseOrderResolver = {
42
42
  for (var i = 0; i < marketplaceOrders.length; i++) {
43
43
  const marketplaceOrder = marketplaceOrders[i]
44
44
 
45
+ const marketplaceOrderItems: MarketplaceOrderItem[] = marketplaceOrder.marketplaceOrderItems
46
+
45
47
  const marketplaceOrderShippings: MarketplaceOrderShipping[] = await getRepository(MarketplaceOrderShipping).find({
46
48
  where: { orderNoRef: marketplaceOrder.orderNo, domain },
47
49
  order: { subOrderNoRef: 'ASC' },
@@ -64,7 +66,7 @@ export const autoAddReleaseOrderResolver = {
64
66
  .toString()
65
67
  .padStart(2, '0')}`
66
68
 
67
- const newReleaseOrder: any = {
69
+ var newReleaseOrder: any = {
68
70
  releaseDate,
69
71
  type: 'b2c',
70
72
  transporter: marketplaceOrder.shippingProvider,
@@ -122,86 +124,82 @@ export const autoAddReleaseOrderResolver = {
122
124
  await getRepository(MarketplaceOrder).save(marketplaceOrder)
123
125
  }
124
126
  } catch (e) {}
127
+ }
128
+ }
125
129
 
126
- var invoiceProducts = await Promise.all(
127
- newReleaseOrder.orderInventories.map(async oi => {
128
- let product: Product = await getRepository(Product).findOne({
129
- where: { domain, sku: oi.product.sku }
130
- })
131
-
132
- if (!product) {
133
- product = await getRepository(ProductBundle).findOne({
134
- where: { domain, sku: oi.product.sku }
135
- })
136
- }
137
-
138
- let mosis: MarketplaceOrderShippingItem[] = marketplaceOrderShippingItems.filter(
139
- mosi => mosi.product.sku === product.sku
140
- )
141
-
142
- let moi: MarketplaceOrderItem = mosis[0].marketplaceOrderItem
130
+ var invoiceProducts = await Promise.all(
131
+ marketplaceOrderItems.map(async mi => {
132
+ let product: Product = await getRepository(Product).findOne({
133
+ where: { domain, sku: mi.marketplaceProductVariation.sku }
134
+ })
143
135
 
144
- return {
145
- sku: product.sku,
146
- name: product.name,
147
- description: product.description,
148
- product: { sku: product.sku },
149
- qty: oi.releaseQty,
150
- unitPrice: (moi?.originalPrice || 0) / moi.qty,
151
- paidPrice: (moi?.paidPrice || 0) / moi.qty
152
- }
136
+ let productBundle: ProductBundle
137
+ if (!product) {
138
+ productBundle = await getRepository(ProductBundle).findOne({
139
+ where: { domain, sku: mi.marketplaceProductVariation.sku }
153
140
  })
154
- )
155
-
156
- let newInvoice = {
157
- invoiceProducts,
158
- releaseGood: { id: releaseOrder.id, name: releaseOrder.name },
159
- refNo1: newReleaseOrder.refNo.toString(),
160
- refNo2: newReleaseOrder.refNo2.toString(),
161
- issuedOn: new Date(),
162
- from: marketplaceOrder.marketplaceStore.storeName,
163
- fromContactPhone: '-',
164
- fromAddress1: '-',
165
- fromAddress2: null,
166
- fromAddress3: null,
167
- fromAddress4: null,
168
- fromAddress5: null,
169
- fromPostcode: null,
170
- fromCity: null,
171
- fromState: null,
172
- fromCountry: null,
173
- deliverTo: newReleaseOrder.deliverTo.attentionTo || '-',
174
- deliverToPhone: newReleaseOrder.deliverTo.phone1 || '-',
175
- deliveryAddress1: newReleaseOrder.deliverTo.deliveryAddress1 || '-',
176
- deliveryAddress2: newReleaseOrder.deliverTo.deliveryAddress2,
177
- deliveryAddress3: newReleaseOrder.deliverTo.deliveryAddress3,
178
- deliveryAddress4: newReleaseOrder.deliverTo.deliveryAddress4,
179
- deliveryAddress5: newReleaseOrder.deliverTo.deliveryAddress5,
180
- deliveryPostcode: newReleaseOrder.deliverTo.postalCode || '-',
181
- deliveryCity: newReleaseOrder.deliverTo.city || '-',
182
- deliveryState: newReleaseOrder.deliverTo.state || '-',
183
- deliveryCountry: newReleaseOrder.deliverTo.country || '-',
184
- billTo: newReleaseOrder.deliverTo.attentionTo || '-',
185
- billToPhone: newReleaseOrder.deliverTo.phone1 || '-',
186
- billingAddress1: releaseOrder.billingAddress || newReleaseOrder.deliverTo.deliveryAddress1 || '-',
187
- billingAddress2: null,
188
- billingAddress3: null,
189
- billingAddress4: null,
190
- billingAddress5: null,
191
- billingPostcode: '-',
192
- billingCity: '-',
193
- billingState: '-',
194
- billingCountry: '-'
195
141
  }
196
142
 
197
- try {
198
- await FulfillmentAPI.createSalesInvoice(fulfilmentCenter, {
199
- customerBizplaceId,
200
- invoice: newInvoice
201
- })
202
- } catch (e) {}
203
- }
143
+ return {
144
+ sku: product ? product.sku : productBundle.sku,
145
+ name: product ? product.name : productBundle.name,
146
+ description: product ? product.description : productBundle.description,
147
+ qty: mi.qty,
148
+ unitPrice: (mi?.originalPrice || 0) / mi.qty,
149
+ paidPrice: (mi?.paidPrice || 0) / mi.qty,
150
+ discount: mi?.discount || 0,
151
+ shippingFeePaidByCustomer: mi?.shippingFeePaidByCustomer || 0
152
+ }
153
+ })
154
+ )
155
+
156
+ let newInvoice = {
157
+ invoiceProducts,
158
+ name: '-',
159
+ refNo1: newReleaseOrder.refNo.toString(),
160
+ refNo2: newReleaseOrder.refNo2.toString(),
161
+ issuedOn: new Date(),
162
+ from: marketplaceOrder.marketplaceStore.storeName,
163
+ fromContactPhone: '-',
164
+ fromAddress1: '-',
165
+ fromAddress2: null,
166
+ fromAddress3: null,
167
+ fromAddress4: null,
168
+ fromAddress5: null,
169
+ fromPostcode: null,
170
+ fromCity: null,
171
+ fromState: null,
172
+ fromCountry: null,
173
+ deliverTo: newReleaseOrder.deliverTo.attentionTo || '-',
174
+ deliverToPhone: newReleaseOrder.deliverTo.phone1 || '-',
175
+ deliveryAddress1: newReleaseOrder.deliverTo.deliveryAddress1 || '-',
176
+ deliveryAddress2: newReleaseOrder.deliverTo.deliveryAddress2,
177
+ deliveryAddress3: newReleaseOrder.deliverTo.deliveryAddress3,
178
+ deliveryAddress4: newReleaseOrder.deliverTo.deliveryAddress4,
179
+ deliveryAddress5: newReleaseOrder.deliverTo.deliveryAddress5,
180
+ deliveryPostcode: newReleaseOrder.deliverTo.postalCode || '-',
181
+ deliveryCity: newReleaseOrder.deliverTo.city || '-',
182
+ deliveryState: newReleaseOrder.deliverTo.state || '-',
183
+ deliveryCountry: newReleaseOrder.deliverTo.country || '-',
184
+ billTo: newReleaseOrder.deliverTo.attentionTo || '-',
185
+ billToPhone: newReleaseOrder.deliverTo.phone1 || '-',
186
+ billingAddress1: newReleaseOrder.deliverTo.billingAddress || newReleaseOrder.deliverTo.deliveryAddress1 || '-',
187
+ billingAddress2: null,
188
+ billingAddress3: null,
189
+ billingAddress4: null,
190
+ billingAddress5: null,
191
+ billingPostcode: '-',
192
+ billingCity: '-',
193
+ billingState: '-',
194
+ billingCountry: '-'
204
195
  }
196
+
197
+ try {
198
+ await FulfillmentAPI.createSalesInvoice(fulfilmentCenter, {
199
+ customerBizplaceId,
200
+ invoice: newInvoice
201
+ })
202
+ } catch (e) {}
205
203
  }
206
204
  }
207
205
  }
@@ -67,25 +67,8 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
67
67
 
68
68
  await tx.query(
69
69
  `
70
- CREATE TEMP TABLE "temp_inventory" ON COMMIT DROP AS (
71
- select "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
72
- "i2"."product_id", SUM(greatest(coalesce("locked_qty",0),0) + greatest(coalesce(oi.release_qty,0),0)) as "inventory_locked_qty", sum(coalesce("qty",0)) as "inventory_qty",
73
- "i2"."domain_id"
74
- from inventories "i2"
75
- inner join warehouses "w" on "w"."id" = "i2"."warehouse_id"
76
- inner join domains "d2" on "d2"."id" = "w"."domain_id" and "d2"."ext_type" ='warehouse'
77
- inner join fulfillment_centers "fc" ON "fc"."center_id" = "d2"."subdomain"
78
- inner join (
79
- select "Product"."product_id" from (
80
- select case when "Product"."type" = 'PRODUCT' then "Product"."product_id" else "pbs"."product_id" end as "product_id"
81
- from temp_products "Product"
82
- left join product_bundles "pb" on "pb"."id" = "Product"."product_id"
83
- left join product_bundle_settings "pbs" on "pbs"."product_bundle_id" = "pb"."id"
84
- ) "Product"
85
- group by "Product"."product_id"
86
- ) "Product" on "Product"."product_id" = "i2"."product_id"
87
- left join (
88
- SELECT
70
+ CREATE TEMP TABLE "temp_order_inventories" ON COMMIT DROP AS (
71
+ SELECT
89
72
  SUM(oi.release_qty) AS release_qty, SUM(oi.release_uom_value) AS release_uom_value, oi.batch_id, oi.batch_id_ref,
90
73
  oi.product_id, p.product_name, oi.packing_type, oi.packing_size, oi.uom
91
74
  FROM
@@ -103,10 +86,39 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
103
86
  GROUP BY
104
87
  oi.batch_id, oi.batch_id_ref, oi.product_id, oi.packing_type,
105
88
  oi.packing_size, oi.uom, p.product_name
106
- )"oi" ON "i2".batch_id = "oi".batch_id AND "Product"."product_id" = "oi".product_id AND "i2".packing_type = "oi".packing_type AND "i2".packing_size = oi.packing_size AND "i2".uom = oi.uom
107
- where "fc"."domain_id" = $1
108
- and "i2"."status" = 'STORED'
109
- group by "i2"."domain_id", "fc"."id", "fc"."name", "i2"."product_id"
89
+ );
90
+ `,
91
+ [domain.id]
92
+ )
93
+
94
+ await tx.query(
95
+ `
96
+ CREATE TEMP TABLE "temp_inventory" ON COMMIT DROP AS (
97
+ select "i2".*, coalesce("oi".release_qty,0) + coalesce("i2".locked_qty,0) as "inventory_locked_qty" from (
98
+ select "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
99
+ "i2"."product_id", sum(coalesce("locked_qty",0)) as "locked_qty", sum(coalesce("qty",0)) as "inventory_qty",
100
+ "i2"."domain_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
101
+ from inventories "i2"
102
+ inner join warehouses "w" on "w"."id" = "i2"."warehouse_id"
103
+ inner join domains "d2" on "d2"."id" = "w"."domain_id" and "d2"."ext_type" ='warehouse'
104
+ inner join fulfillment_centers "fc" ON "fc"."center_id" = "d2"."subdomain"
105
+ inner join (
106
+ select "Product"."product_id" from (
107
+ select case when "Product"."type" = 'PRODUCT' then "Product"."product_id" else "pbs"."product_id" end as "product_id"
108
+ from temp_products "Product"
109
+ left join product_bundles "pb" on "pb"."id" = "Product"."product_id"
110
+ left join product_bundle_settings "pbs" on "pbs"."product_bundle_id" = "pb"."id"
111
+ ) "Product"
112
+ group by "Product"."product_id"
113
+ ) "Product" on "Product"."product_id" = "i2"."product_id"
114
+ where "fc"."domain_id" = $1
115
+ and "i2"."status" = 'STORED'
116
+ group by "i2"."domain_id", "fc"."id", "fc"."name", "i2"."product_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
117
+ ) as "i2"
118
+ left join temp_order_inventories "oi" on "i2"."product_id" = "oi"."product_id"
119
+ AND "i2"."packing_type" = "oi"."packing_type"
120
+ AND "i2"."packing_size" = "oi"."packing_size"
121
+ AND "i2"."uom" = "oi"."uom"
110
122
  )
111
123
  `,
112
124
  [domain.id]
@@ -141,7 +153,7 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
141
153
  max("bundledInv"."inventory_locked_qty") as "inventory_locked_qty", min("bundledInv"."inventory_qty") as "inventory_qty" from (
142
154
  select "Product"."product_id", fc.domain_id, "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
143
155
  "pbs"."bundle_qty",
144
- case when "pbs"."bundle_qty" <= 0 then 0 else ceil(greatest("i2"."inventory_locked_qty",0)/ "pbs"."bundle_qty") end AS "inventory_locked_qty",
156
+ case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty")- floor((greatest("i2"."inventory_qty", 0) - greatest("i2"."inventory_locked_qty",0)) / "pbs"."bundle_qty") end AS "inventory_locked_qty",
145
157
  case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty") end AS "inventory_qty"
146
158
  from temp_products "Product"
147
159
  inner join product_bundle_settings pbs ON pbs.product_bundle_id = "Product"."product_id"