Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/engine/combinedOrder/index.tsx b/src/engine/combinedOrder/index.tsx
- index f8eadc8..d5cc503 100644
- --- a/src/engine/combinedOrder/index.tsx
- +++ b/src/engine/combinedOrder/index.tsx
- @@ -3,6 +3,7 @@ type MasterType = {
- param?: any;
- Id?: number;
- VendorId?: number;
- + VendorDisplayName?: string;
- ItemNumber?: string;
- Description?: string;
- OrderQty?: number;
- @@ -20,6 +21,7 @@ type MasterType = {
- export default class Master implements MasterType {
- Id = 0;
- VendorId = 0;
- + VendorDisplayName = "";
- ItemNumber = "0";
- Description = "";
- OrderQty = 0;
- @@ -37,6 +39,7 @@ export default class Master implements MasterType {
- if (props.param) {
- this.Id = props.param.Id;
- this.VendorId = props.param.VendorId;
- + this.VendorDisplayName = props.param.VendorDisplayName;
- this.ItemNumber = props.param.ItemNumber;
- this.Description = props.param.Description;
- this.OrderQty = props.param.OrderQty;
- @@ -52,6 +55,9 @@ export default class Master implements MasterType {
- } else {
- this.Id = props.Id ? props.Id : 0;
- this.VendorId = props.VendorId ? props.VendorId : 0;
- + this.VendorDisplayName = props.VendorDisplayName
- + ? props.VendorDisplayName
- + : "";
- this.ItemNumber = props.ItemNumber ? props.ItemNumber : "";
- this.Description = props.Description ? props.Description : "";
- this.OrderQty = props.OrderQty ? props.OrderQty : 0;
- diff --git a/src/engine/combinedOrder/reducer.tsx b/src/engine/combinedOrder/reducer.tsx
- index aae70e6..4c4180e 100644
- --- a/src/engine/combinedOrder/reducer.tsx
- +++ b/src/engine/combinedOrder/reducer.tsx
- @@ -1,37 +1,37 @@
- -import React from 'react'
- -const Lodash = require('lodash')
- -import Master, { State, Action, ActionTypes } from '.'
- -import * as Api from '../helper/api'
- +import React from "react";
- +const Lodash = require("lodash");
- +import Master, { State, Action, ActionTypes } from ".";
- +import * as Api from "../helper/api";
- const initialState: State = {
- - isLoading: false,
- - masters: []
- -}
- + isLoading: false,
- + masters: []
- +};
- export default function masters(state: State = initialState, action: any) {
- - switch (action.type) {
- - case ActionTypes.LOAD: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = true
- - return newState
- - }
- - case ActionTypes.SEARCH: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = true
- - return newState
- - }
- - case Api.ActionType.MASTER_SUCCESS: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = false
- - newState.masters = ((action as Api.Action).result as Master[])
- - return newState
- - }
- - case Api.ActionType.MASTER_FAILURE: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = false
- - newState.masters = []
- - return newState
- - }
- - }
- - return state
- -}
- \ No newline at end of file
- + switch (action.type) {
- + case ActionTypes.LOAD: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = true;
- + return newState;
- + }
- + case ActionTypes.SEARCH: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = true;
- + return newState;
- + }
- + case Api.ActionType.MASTER_SUCCESS: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = false;
- + newState.masters = (action as Api.Action).result as Master[];
- + return newState;
- + }
- + case Api.ActionType.MASTER_FAILURE: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = false;
- + newState.masters = [];
- + return newState;
- + }
- + }
- + return state;
- +}
- diff --git a/src/engine/combinedOrder/saga.tsx b/src/engine/combinedOrder/saga.tsx
- index 7fff665..3ca2fd5 100644
- --- a/src/engine/combinedOrder/saga.tsx
- +++ b/src/engine/combinedOrder/saga.tsx
- @@ -5,16 +5,16 @@ import * as Api from "../helper/api";
- import { connectSqlServer, executeQuery } from "../sqlserver";
- function* fetchLoad(action: Action) {
- -// const d = new Date(new Date());
- -// const day = d.getDay();
- -// const diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
- -// console.log(new Date(d.setDate(diff)));
- + // const d = new Date(new Date());
- + // const day = d.getDay();
- + // const diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
- + // console.log(new Date(d.setDate(diff)));
- try {
- const MSSQL = yield call(connectSqlServer);
- -
- +
- // 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`;
- - 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`;
- + 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`;
- // AND OrderList.CreatedOn > cast('${monday()}' as datetime2(7))
- console.log("combinedOrder order query:...." + queryMaster);
- @@ -34,7 +34,6 @@ function* fetchLoad(action: Action) {
- function* fetchSearchLoad(action: Action) {
- try {
- -
- const MSSQL = yield call(connectSqlServer);
- // 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`;
- @@ -49,15 +48,11 @@ function* fetchSearchLoad(action: Action) {
- result.push(new Master({ param: queryResult[i] }));
- }
- yield put(Api.onMasterSuccess(result));
- -
- } catch (error) {
- yield put(Api.onMasterFailure(error.response));
- }
- }
- -
- -
- -
- function today() {
- const d = new Date();
- @@ -100,7 +95,6 @@ function monday() {
- return monday;
- }
- -
- export function* watchLoad() {
- yield takeLatest(ActionTypes.LOAD, fetchLoad);
- }
- diff --git a/src/engine/master/index.tsx b/src/engine/master/index.tsx
- index 45145e7..1fc0934 100644
- --- a/src/engine/master/index.tsx
- +++ b/src/engine/master/index.tsx
- @@ -3,6 +3,7 @@ type MasterType = {
- param?: any;
- Id?: number;
- VendorId?: number;
- + VendorDisplayName?: string;
- ItemNumber?: string;
- Description?: string;
- OrderQty?: number;
- @@ -21,6 +22,7 @@ type MasterType = {
- export default class Master implements MasterType {
- Id = 0;
- VendorId = 0;
- + VendorDisplayName = "";
- ItemNumber = "0";
- Description = "";
- OrderQty = 0;
- @@ -40,6 +42,7 @@ export default class Master implements MasterType {
- if (props.param) {
- this.Id = props.param.Id;
- this.VendorId = props.param.VendorId;
- + this.VendorDisplayName = props.param.VendorDisplayName;
- this.ItemNumber = props.param.ItemNumber;
- this.Description = props.param.Description;
- this.OrderQty = props.param.OrderQty;
- @@ -56,6 +59,9 @@ export default class Master implements MasterType {
- } else {
- this.Id = props.Id ? props.Id : 0;
- this.VendorId = props.VendorId ? props.VendorId : 0;
- + this.VendorDisplayName = props.VendorDisplayName
- + ? props.VendorDisplayName
- + : "";
- this.ItemNumber = props.ItemNumber ? props.ItemNumber : "";
- this.Description = props.Description ? props.Description : "";
- this.OrderQty = props.OrderQty ? props.OrderQty : 0;
- diff --git a/src/engine/master/reducer.tsx b/src/engine/master/reducer.tsx
- index aae70e6..4c4180e 100644
- --- a/src/engine/master/reducer.tsx
- +++ b/src/engine/master/reducer.tsx
- @@ -1,37 +1,37 @@
- -import React from 'react'
- -const Lodash = require('lodash')
- -import Master, { State, Action, ActionTypes } from '.'
- -import * as Api from '../helper/api'
- +import React from "react";
- +const Lodash = require("lodash");
- +import Master, { State, Action, ActionTypes } from ".";
- +import * as Api from "../helper/api";
- const initialState: State = {
- - isLoading: false,
- - masters: []
- -}
- + isLoading: false,
- + masters: []
- +};
- export default function masters(state: State = initialState, action: any) {
- - switch (action.type) {
- - case ActionTypes.LOAD: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = true
- - return newState
- - }
- - case ActionTypes.SEARCH: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = true
- - return newState
- - }
- - case Api.ActionType.MASTER_SUCCESS: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = false
- - newState.masters = ((action as Api.Action).result as Master[])
- - return newState
- - }
- - case Api.ActionType.MASTER_FAILURE: {
- - const newState: State = Lodash.cloneDeep(state)
- - newState.isLoading = false
- - newState.masters = []
- - return newState
- - }
- - }
- - return state
- -}
- \ No newline at end of file
- + switch (action.type) {
- + case ActionTypes.LOAD: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = true;
- + return newState;
- + }
- + case ActionTypes.SEARCH: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = true;
- + return newState;
- + }
- + case Api.ActionType.MASTER_SUCCESS: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = false;
- + newState.masters = (action as Api.Action).result as Master[];
- + return newState;
- + }
- + case Api.ActionType.MASTER_FAILURE: {
- + const newState: State = Lodash.cloneDeep(state);
- + newState.isLoading = false;
- + newState.masters = [];
- + return newState;
- + }
- + }
- + return state;
- +}
- diff --git a/src/engine/master/saga.tsx b/src/engine/master/saga.tsx
- index 1353eff..1aab300 100644
- --- a/src/engine/master/saga.tsx
- +++ b/src/engine/master/saga.tsx
- @@ -16,10 +16,10 @@ function* fetchLoad(action: Action) {
- // [20-03-25 by Polina...] orderlist query
- if (action.roleId == 1) {
- // var query = "SELECT * FROM OrderList"
- - 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)`;
- + 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)`;
- } else {
- // var query = `SELECT * FROM OrderList WHERE CreatedBy = ${action.userId}`
- - 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} `;
- + 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} `;
- }
- console.log("master query:...." + query);
- @@ -43,12 +43,12 @@ function* fetchSearchLoad(action: Action) {
- try {
- const MSSQL = yield call(connectSqlServer);
- //let query = `SELECT * FROM MasterList WHERE ItemNumber LIKE \'%${action.searchObj.txtItem}%' AND Description LIKE \'%${action.searchObj.txtDesc}%\' AND VendorId LIKE \'%${action.searchObj.txtVendor}%\'`;
- - 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}%\'`;
- + 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}%\'`;
- console.log(query);
- const queryResult = yield call(MSSQL.executeQuery, query);
- //const result: Master[] = [];
- //for (let i = 0; i < queryResult.length; i++) {
- - //result.push(new Master({ param: queryResult[i] }));
- + //result.push(new Master({ param: queryResult[i] }));
- //}
- yield put(Api.onMasterSuccess(queryResult));
- } catch (error) {
- diff --git a/src/ui/combinedOrderList.tsx b/src/ui/combinedOrderList.tsx
- index 33cd62e..523e9ca 100644
- --- a/src/ui/combinedOrderList.tsx
- +++ b/src/ui/combinedOrderList.tsx
- @@ -98,7 +98,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- orders: this.props.orders,
- orderedQtyInputs: [],
- saveOrderedList: [],
- - orderListTemp: [],
- + orderListTemp: [],
- isLoading: false,
- userId: this.props.userDetail[0].UserId,
- roleId: this.props.userDetail[0].RoleId
- @@ -122,7 +122,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- }
- return { isLoading: true, orderedQtyInputs: orderedQtyInputs };
- }
- - return null;
- + return null;
- }
- componentDidMount() {
- @@ -167,11 +167,10 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- console.log(
- "ordered quantity - initial : " +
- JSON.stringify(this.state.orderedQtyInputs)
- - );
- + );
- };
- // save orderedCount
- saveOrder = () => {
- -
- console.log("tab saveOrder Button");
- let { orderListTemp, saveOrderedList } = this.state;
- @@ -205,8 +204,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- this.props.userDetail[0].RoleId
- );
- this.props.navigation.goBack();
- - }
- -
- + }
- };
- onMasterListItemPressed = (item: Master) => {
- @@ -313,7 +311,7 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- this.setState({
- orderedQtyInputs,
- saveOrderedList: [],
- - orderListTemp: []
- + orderListTemp: []
- });
- }
- };
- @@ -487,7 +485,9 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- }}
- >
- <View testID="masters" style={masterListItemStyle.container}>
- - <Text style={masterListItemStyle.vender}>{item.VendorId}</Text>
- + <Text style={masterListItemStyle.vender}>
- + {item.VendorDisplayName}
- + </Text>
- <Text style={masterListItemStyle.item}>{item.ItemNumber}</Text>
- <Text style={masterListItemStyle.description}>
- {item.Description}
- @@ -510,8 +510,9 @@ export class CombinedOrderListScreen extends React.Component<Props, State> {
- {!this.state.orderedQtyInputs[index].isOrderedQtyPressed ? (
- <Text
- testID="productOrderedThisWeekQuantity"
- - style={masterListItemStyle.orderQuantityText}>
- - { this.state.orderedQtyInputs[index].OrderQty
- + style={masterListItemStyle.orderQuantityText}
- + >
- + {this.state.orderedQtyInputs[index].OrderQty
- ? this.state.orderedQtyInputs[index].OrderQty
- : 0}
- </Text>
- @@ -701,7 +702,7 @@ const masterListItemStyle = StyleSheet.create({
- const mapStateToProps = (state: {
- masters: MasterState;
- - orders: {
- + orders: {
- addOrderList: [];
- addOrder: [];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement