Advertisement
MaximErofeev

Untitled

Mar 31st, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.22 KB | None | 0 0
  1. diff --git a/src/engine/combinedOrder/index.tsx b/src/engine/combinedOrder/index.tsx
  2. index f8eadc8..d5cc503 100644
  3. --- a/src/engine/combinedOrder/index.tsx
  4. +++ b/src/engine/combinedOrder/index.tsx
  5. @@ -3,6 +3,7 @@ type MasterType = {
  6. param?: any;
  7. Id?: number;
  8. VendorId?: number;
  9. + VendorDisplayName?: string;
  10. ItemNumber?: string;
  11. Description?: string;
  12. OrderQty?: number;
  13. @@ -20,6 +21,7 @@ type MasterType = {
  14. export default class Master implements MasterType {
  15. Id = 0;
  16. VendorId = 0;
  17. + VendorDisplayName = "";
  18. ItemNumber = "0";
  19. Description = "";
  20. OrderQty = 0;
  21. @@ -37,6 +39,7 @@ export default class Master implements MasterType {
  22. if (props.param) {
  23. this.Id = props.param.Id;
  24. this.VendorId = props.param.VendorId;
  25. + this.VendorDisplayName = props.param.VendorDisplayName;
  26. this.ItemNumber = props.param.ItemNumber;
  27. this.Description = props.param.Description;
  28. this.OrderQty = props.param.OrderQty;
  29. @@ -52,6 +55,9 @@ export default class Master implements MasterType {
  30. } else {
  31. this.Id = props.Id ? props.Id : 0;
  32. this.VendorId = props.VendorId ? props.VendorId : 0;
  33. + this.VendorDisplayName = props.VendorDisplayName
  34. + ? props.VendorDisplayName
  35. + : "";
  36. this.ItemNumber = props.ItemNumber ? props.ItemNumber : "";
  37. this.Description = props.Description ? props.Description : "";
  38. this.OrderQty = props.OrderQty ? props.OrderQty : 0;
  39. diff --git a/src/engine/combinedOrder/reducer.tsx b/src/engine/combinedOrder/reducer.tsx
  40. index aae70e6..4c4180e 100644
  41. --- a/src/engine/combinedOrder/reducer.tsx
  42. +++ b/src/engine/combinedOrder/reducer.tsx
  43. @@ -1,37 +1,37 @@
  44. -import React from 'react'
  45. -const Lodash = require('lodash')
  46. -import Master, { State, Action, ActionTypes } from '.'
  47. -import * as Api from '../helper/api'
  48. +import React from "react";
  49. +const Lodash = require("lodash");
  50. +import Master, { State, Action, ActionTypes } from ".";
  51. +import * as Api from "../helper/api";
  52.  
  53. const initialState: State = {
  54. - isLoading: false,
  55. - masters: []
  56. -}
  57. + isLoading: false,
  58. + masters: []
  59. +};
  60.  
  61. export default function masters(state: State = initialState, action: any) {
  62. - switch (action.type) {
  63. - case ActionTypes.LOAD: {
  64. - const newState: State = Lodash.cloneDeep(state)
  65. - newState.isLoading = true
  66. - return newState
  67. - }
  68. - case ActionTypes.SEARCH: {
  69. - const newState: State = Lodash.cloneDeep(state)
  70. - newState.isLoading = true
  71. - return newState
  72. - }
  73. - case Api.ActionType.MASTER_SUCCESS: {
  74. - const newState: State = Lodash.cloneDeep(state)
  75. - newState.isLoading = false
  76. - newState.masters = ((action as Api.Action).result as Master[])
  77. - return newState
  78. - }
  79. - case Api.ActionType.MASTER_FAILURE: {
  80. - const newState: State = Lodash.cloneDeep(state)
  81. - newState.isLoading = false
  82. - newState.masters = []
  83. - return newState
  84. - }
  85. - }
  86. - return state
  87. -}
  88. \ No newline at end of file
  89. + switch (action.type) {
  90. + case ActionTypes.LOAD: {
  91. + const newState: State = Lodash.cloneDeep(state);
  92. + newState.isLoading = true;
  93. + return newState;
  94. + }
  95. + case ActionTypes.SEARCH: {
  96. + const newState: State = Lodash.cloneDeep(state);
  97. + newState.isLoading = true;
  98. + return newState;
  99. + }
  100. + case Api.ActionType.MASTER_SUCCESS: {
  101. + const newState: State = Lodash.cloneDeep(state);
  102. + newState.isLoading = false;
  103. + newState.masters = (action as Api.Action).result as Master[];
  104. + return newState;
  105. + }
  106. + case Api.ActionType.MASTER_FAILURE: {
  107. + const newState: State = Lodash.cloneDeep(state);
  108. + newState.isLoading = false;
  109. + newState.masters = [];
  110. + return newState;
  111. + }
  112. + }
  113. + return state;
  114. +}
  115. diff --git a/src/engine/combinedOrder/saga.tsx b/src/engine/combinedOrder/saga.tsx
  116. index 7fff665..3ca2fd5 100644
  117. --- a/src/engine/combinedOrder/saga.tsx
  118. +++ b/src/engine/combinedOrder/saga.tsx
  119. @@ -5,16 +5,16 @@ import * as Api from "../helper/api";
  120. import { connectSqlServer, executeQuery } from "../sqlserver";
  121.  
  122. function* fetchLoad(action: Action) {
  123. -// const d = new Date(new Date());
  124. -// const day = d.getDay();
  125. -// const diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
  126. -// console.log(new Date(d.setDate(diff)));
  127. + // const d = new Date(new Date());
  128. + // const day = d.getDay();
  129. + // const diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
  130. + // console.log(new Date(d.setDate(diff)));
  131. try {
  132. const MSSQL = yield call(connectSqlServer);
  133. -
  134. +
  135. // let queryMaster = `SELECT MasterList.Id, MasterList.VendorId, MasterList.ItemNumber, MasterList.Description, MasterList.CasePack, MasterList.Cost, SUM(OrderList.OrderQty), OrderList.StoreId, MasterList.ItemInventoryCount, MasterList.LocalChina, MasterList.CreatedBy, MasterList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM MasterList JOIN Vendor ON (MasterList.VendorId = Vendor.Id) LEFT JOIN OrderList ON (MasterList.ItemNumber = OrderList.ItemNumber) GROUP BY MasterList.ItemNumber ORDER BY Id OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY`;
  136.  
  137. - let queryMaster = `SELECT MasterList.Id, MasterList.VendorId, MasterList.ItemNumber, MasterList.Description, MasterList.CasePack, MasterList.Cost, OrderList.OrderQty, OrderList.StoreId, MasterList.ItemInventoryCount, MasterList.LocalChina, MasterList.CreatedBy, MasterList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM MasterList JOIN Vendor ON (MasterList.VendorId = Vendor.Id) LEFT JOIN OrderList ON (MasterList.VendorId = OrderList.VendorId AND MasterList.ItemNumber = OrderList.ItemNumber AND MasterList.Description = OrderList.Description) WHERE OrderList.StoreId is NULL or OrderList.StoreId = 2 ORDER BY MasterList.Id OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY`;
  138. + let queryMaster = `SELECT MasterList.Id, MasterList.VendorId, MasterList.ItemNumber, MasterList.Description, MasterList.CasePack, MasterList.Cost, OrderList.OrderQty, OrderList.StoreId, MasterList.ItemInventoryCount, MasterList.LocalChina, MasterList.CreatedBy, MasterList.ModifiedBy, Vendor.Name, Vendor.DisplayName as VendorDisplayName FROM MasterList JOIN Vendor ON (MasterList.VendorId = Vendor.Id) LEFT JOIN OrderList ON (MasterList.VendorId = OrderList.VendorId AND MasterList.ItemNumber = OrderList.ItemNumber AND MasterList.Description = OrderList.Description) WHERE OrderList.StoreId is NULL or OrderList.StoreId = 2 ORDER BY MasterList.Id OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY`;
  139.  
  140. // AND OrderList.CreatedOn > cast('${monday()}' as datetime2(7))
  141. console.log("combinedOrder order query:...." + queryMaster);
  142. @@ -34,7 +34,6 @@ function* fetchLoad(action: Action) {
  143.  
  144. function* fetchSearchLoad(action: Action) {
  145. try {
  146. -
  147. const MSSQL = yield call(connectSqlServer);
  148. // let queryMaster = `SELECT * FROM MasterList WHERE ItemNumber LIKE \'%${action.searchObj.txtItem}%' AND Description LIKE \'%${action.searchObj.txtDesc}%\' AND VendorId LIKE \'%${action.searchObj.txtVendor}%\' ORDER BY Id OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY`;
  149.  
  150. @@ -49,15 +48,11 @@ function* fetchSearchLoad(action: Action) {
  151. result.push(new Master({ param: queryResult[i] }));
  152. }
  153. yield put(Api.onMasterSuccess(result));
  154. -
  155. } catch (error) {
  156. yield put(Api.onMasterFailure(error.response));
  157. }
  158. }
  159.  
  160. -
  161. -
  162. -
  163. function today() {
  164. const d = new Date();
  165.  
  166. @@ -100,7 +95,6 @@ function monday() {
  167. return monday;
  168. }
  169.  
  170. -
  171. export function* watchLoad() {
  172. yield takeLatest(ActionTypes.LOAD, fetchLoad);
  173. }
  174. diff --git a/src/engine/master/index.tsx b/src/engine/master/index.tsx
  175. index 45145e7..1fc0934 100644
  176. --- a/src/engine/master/index.tsx
  177. +++ b/src/engine/master/index.tsx
  178. @@ -3,6 +3,7 @@ type MasterType = {
  179. param?: any;
  180. Id?: number;
  181. VendorId?: number;
  182. + VendorDisplayName?: string;
  183. ItemNumber?: string;
  184. Description?: string;
  185. OrderQty?: number;
  186. @@ -21,6 +22,7 @@ type MasterType = {
  187. export default class Master implements MasterType {
  188. Id = 0;
  189. VendorId = 0;
  190. + VendorDisplayName = "";
  191. ItemNumber = "0";
  192. Description = "";
  193. OrderQty = 0;
  194. @@ -40,6 +42,7 @@ export default class Master implements MasterType {
  195. if (props.param) {
  196. this.Id = props.param.Id;
  197. this.VendorId = props.param.VendorId;
  198. + this.VendorDisplayName = props.param.VendorDisplayName;
  199. this.ItemNumber = props.param.ItemNumber;
  200. this.Description = props.param.Description;
  201. this.OrderQty = props.param.OrderQty;
  202. @@ -56,6 +59,9 @@ export default class Master implements MasterType {
  203. } else {
  204. this.Id = props.Id ? props.Id : 0;
  205. this.VendorId = props.VendorId ? props.VendorId : 0;
  206. + this.VendorDisplayName = props.VendorDisplayName
  207. + ? props.VendorDisplayName
  208. + : "";
  209. this.ItemNumber = props.ItemNumber ? props.ItemNumber : "";
  210. this.Description = props.Description ? props.Description : "";
  211. this.OrderQty = props.OrderQty ? props.OrderQty : 0;
  212. diff --git a/src/engine/master/reducer.tsx b/src/engine/master/reducer.tsx
  213. index aae70e6..4c4180e 100644
  214. --- a/src/engine/master/reducer.tsx
  215. +++ b/src/engine/master/reducer.tsx
  216. @@ -1,37 +1,37 @@
  217. -import React from 'react'
  218. -const Lodash = require('lodash')
  219. -import Master, { State, Action, ActionTypes } from '.'
  220. -import * as Api from '../helper/api'
  221. +import React from "react";
  222. +const Lodash = require("lodash");
  223. +import Master, { State, Action, ActionTypes } from ".";
  224. +import * as Api from "../helper/api";
  225.  
  226. const initialState: State = {
  227. - isLoading: false,
  228. - masters: []
  229. -}
  230. + isLoading: false,
  231. + masters: []
  232. +};
  233.  
  234. export default function masters(state: State = initialState, action: any) {
  235. - switch (action.type) {
  236. - case ActionTypes.LOAD: {
  237. - const newState: State = Lodash.cloneDeep(state)
  238. - newState.isLoading = true
  239. - return newState
  240. - }
  241. - case ActionTypes.SEARCH: {
  242. - const newState: State = Lodash.cloneDeep(state)
  243. - newState.isLoading = true
  244. - return newState
  245. - }
  246. - case Api.ActionType.MASTER_SUCCESS: {
  247. - const newState: State = Lodash.cloneDeep(state)
  248. - newState.isLoading = false
  249. - newState.masters = ((action as Api.Action).result as Master[])
  250. - return newState
  251. - }
  252. - case Api.ActionType.MASTER_FAILURE: {
  253. - const newState: State = Lodash.cloneDeep(state)
  254. - newState.isLoading = false
  255. - newState.masters = []
  256. - return newState
  257. - }
  258. - }
  259. - return state
  260. -}
  261. \ No newline at end of file
  262. + switch (action.type) {
  263. + case ActionTypes.LOAD: {
  264. + const newState: State = Lodash.cloneDeep(state);
  265. + newState.isLoading = true;
  266. + return newState;
  267. + }
  268. + case ActionTypes.SEARCH: {
  269. + const newState: State = Lodash.cloneDeep(state);
  270. + newState.isLoading = true;
  271. + return newState;
  272. + }
  273. + case Api.ActionType.MASTER_SUCCESS: {
  274. + const newState: State = Lodash.cloneDeep(state);
  275. + newState.isLoading = false;
  276. + newState.masters = (action as Api.Action).result as Master[];
  277. + return newState;
  278. + }
  279. + case Api.ActionType.MASTER_FAILURE: {
  280. + const newState: State = Lodash.cloneDeep(state);
  281. + newState.isLoading = false;
  282. + newState.masters = [];
  283. + return newState;
  284. + }
  285. + }
  286. + return state;
  287. +}
  288. diff --git a/src/engine/master/saga.tsx b/src/engine/master/saga.tsx
  289. index 1353eff..1aab300 100644
  290. --- a/src/engine/master/saga.tsx
  291. +++ b/src/engine/master/saga.tsx
  292. @@ -16,10 +16,10 @@ function* fetchLoad(action: Action) {
  293. // [20-03-25 by Polina...] orderlist query
  294. if (action.roleId == 1) {
  295. // var query = "SELECT * FROM OrderList"
  296. - var queryOrder = `SELECT OrderList.Id, OrderList.VendorId, OrderList.ItemNumber, OrderList.Description, OrderList.CasePack, OrderList.Cost, OrderList.OrderQty, OrderList.StoreId, OrderList.LocalChina, OrderList.CreatedBy, OrderList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM OrderList JOIN Vendor ON (OrderList.VendorId = Vendor.Id)`;
  297. + var queryOrder = `SELECT OrderList.Id, OrderList.VendorId, OrderList.ItemNumber, OrderList.Description, OrderList.CasePack, OrderList.Cost, OrderList.OrderQty, OrderList.StoreId, OrderList.LocalChina, OrderList.CreatedBy, OrderList.ModifiedBy, Vendor.Name, Vendor.DisplayName as VendorDisplayName FROM OrderList JOIN Vendor ON (OrderList.VendorId = Vendor.Id)`;
  298. } else {
  299. // var query = `SELECT * FROM OrderList WHERE CreatedBy = ${action.userId}`
  300. - var queryOrder = `SELECT OrderList.Id, OrderList.VendorId, OrderList.ItemNumber, OrderList.Description, OrderList.CasePack, OrderList.Cost, OrderList.OrderQty, OrderList.StoreId, OrderList.LocalChina, OrderList.CreatedBy, OrderList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM OrderList JOIN Vendor ON (OrderList.VendorId = Vendor.Id) WHERE OrderList.CreatedBy = ${action.userId} `;
  301. + var queryOrder = `SELECT OrderList.Id, OrderList.VendorId, OrderList.ItemNumber, OrderList.Description, OrderList.CasePack, OrderList.Cost, OrderList.OrderQty, OrderList.StoreId, OrderList.LocalChina, OrderList.CreatedBy, OrderList.ModifiedBy, Vendor.Name, Vendor.DisplayName as VendorDisplayName FROM OrderList JOIN Vendor ON (OrderList.VendorId = Vendor.Id) WHERE OrderList.CreatedBy = ${action.userId} `;
  302. }
  303.  
  304. console.log("master query:...." + query);
  305. @@ -43,12 +43,12 @@ function* fetchSearchLoad(action: Action) {
  306. try {
  307. const MSSQL = yield call(connectSqlServer);
  308. //let query = `SELECT * FROM MasterList WHERE ItemNumber LIKE \'%${action.searchObj.txtItem}%' AND Description LIKE \'%${action.searchObj.txtDesc}%\' AND VendorId LIKE \'%${action.searchObj.txtVendor}%\'`;
  309. - let query = `SELECT MasterList.Id, MasterList.VendorId, MasterList.ItemNumber, MasterList.Description, MasterList.CasePack, MasterList.Cost, MasterList.OrderQty, MasterList.ItemIn ventoryCount, MasterList.LocalChina, MasterList.CreatedBy, MasterList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM MasterList JOIN Vendor ON (MasterList.VendorId = Vendor.Id) WHERE Ma sterList.ItemNumber LIKE \'%${action.searchObj.txtItem}%' AND MasterList.Description LIKE \'%${action.searchObj.txtDesc}%\' AND Vendor.DisplayName LIKE \'%${action.searchObj.txtVendor}%\'`;
  310. + let query = `SELECT MasterList.Id, MasterList.VendorId, MasterList.ItemNumber, MasterList.Description, MasterList.CasePack, MasterList.Cost, MasterList.OrderQty, MasterList.ItemIn ventoryCount, MasterList.LocalChina, MasterList.CreatedBy, MasterList.ModifiedBy, Vendor.Name, Vendor.DisplayName FROM MasterList JOIN Vendor ON (MasterList.VendorId = Vendor.Id) WHERE Ma sterList.ItemNumber LIKE \'%${action.searchObj.txtItem}%' AND MasterList.Description LIKE \'%${action.searchObj.txtDesc}%\' AND Vendor.DisplayName LIKE \'%${action.searchObj.txtVendor}%\'`;
  311. console.log(query);
  312. const queryResult = yield call(MSSQL.executeQuery, query);
  313. //const result: Master[] = [];
  314. //for (let i = 0; i < queryResult.length; i++) {
  315. - //result.push(new Master({ param: queryResult[i] }));
  316. + //result.push(new Master({ param: queryResult[i] }));
  317. //}
  318. yield put(Api.onMasterSuccess(queryResult));
  319. } catch (error) {
  320. diff --git a/src/ui/combinedOrderList.tsx b/src/ui/combinedOrderList.tsx
  321. index 33cd62e..523e9ca 100644
  322. --- a/src/ui/combinedOrderList.tsx
  323. +++ b/src/ui/combinedOrderList.tsx
  324. @@ -98,7 +98,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  325. orders: this.props.orders,
  326. orderedQtyInputs: [],
  327. saveOrderedList: [],
  328. - orderListTemp: [],
  329. + orderListTemp: [],
  330. isLoading: false,
  331. userId: this.props.userDetail[0].UserId,
  332. roleId: this.props.userDetail[0].RoleId
  333. @@ -122,7 +122,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  334. }
  335. return { isLoading: true, orderedQtyInputs: orderedQtyInputs };
  336. }
  337. - return null;
  338. + return null;
  339. }
  340.  
  341. componentDidMount() {
  342. @@ -167,11 +167,10 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  343. console.log(
  344. "ordered quantity - initial : " +
  345. JSON.stringify(this.state.orderedQtyInputs)
  346. - );
  347. + );
  348. };
  349. // save orderedCount
  350. saveOrder = () => {
  351. -
  352. console.log("tab saveOrder Button");
  353.  
  354. let { orderListTemp, saveOrderedList } = this.state;
  355. @@ -205,8 +204,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  356. this.props.userDetail[0].RoleId
  357. );
  358. this.props.navigation.goBack();
  359. - }
  360. -
  361. + }
  362. };
  363.  
  364. onMasterListItemPressed = (item: Master) => {
  365. @@ -313,7 +311,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  366. this.setState({
  367. orderedQtyInputs,
  368. saveOrderedList: [],
  369. - orderListTemp: []
  370. + orderListTemp: []
  371. });
  372. }
  373. };
  374. @@ -487,7 +485,9 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  375. }}
  376. >
  377. <View testID="masters" style={masterListItemStyle.container}>
  378. - <Text style={masterListItemStyle.vender}>{item.VendorId}</Text>
  379. + <Text style={masterListItemStyle.vender}>
  380. + {item.VendorDisplayName}
  381. + </Text>
  382. <Text style={masterListItemStyle.item}>{item.ItemNumber}</Text>
  383. <Text style={masterListItemStyle.description}>
  384. {item.Description}
  385. @@ -510,8 +510,9 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
  386. {!this.state.orderedQtyInputs[index].isOrderedQtyPressed ? (
  387. <Text
  388. testID="productOrderedThisWeekQuantity"
  389. - style={masterListItemStyle.orderQuantityText}>
  390. - { this.state.orderedQtyInputs[index].OrderQty
  391. + style={masterListItemStyle.orderQuantityText}
  392. + >
  393. + {this.state.orderedQtyInputs[index].OrderQty
  394. ? this.state.orderedQtyInputs[index].OrderQty
  395. : 0}
  396. </Text>
  397. @@ -701,7 +702,7 @@ const masterListItemStyle = StyleSheet.create({
  398.  
  399. const mapStateToProps = (state: {
  400. masters: MasterState;
  401. - orders: {
  402. + orders: {
  403. addOrderList: [];
  404. addOrder: [];
  405. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement