Subversion Repositories SmartDukaan

Rev

Rev 24352 | Rev 24365 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24352 Rev 24356
Line 5... Line 5...
5
import java.time.DayOfWeek;
5
import java.time.DayOfWeek;
6
import java.time.LocalDate;
6
import java.time.LocalDate;
7
import java.time.LocalDateTime;
7
import java.time.LocalDateTime;
8
import java.time.temporal.TemporalAdjusters;
8
import java.time.temporal.TemporalAdjusters;
9
import java.util.ArrayList;
9
import java.util.ArrayList;
10
import java.util.Arrays;
-
 
11
import java.util.List;
10
import java.util.List;
12
 
11
 
13
import javax.servlet.http.HttpServletRequest;
12
import javax.servlet.http.HttpServletRequest;
14
 
13
 
15
import org.apache.logging.log4j.LogManager;
14
import org.apache.logging.log4j.LogManager;
Line 28... Line 27...
28
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
27
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
29
import com.spice.profitmandi.common.model.ProfitMandiConstants;
28
import com.spice.profitmandi.common.model.ProfitMandiConstants;
30
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
29
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
31
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
30
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
32
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
31
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
33
import com.spice.profitmandi.dao.entity.transaction.Order;
-
 
34
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
32
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
35
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
33
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
36
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
34
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
37
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
35
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
38
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
36
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
Line 119... Line 117...
119
			fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
117
			fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
120
		} catch (ProfitMandiBusinessException e) {
118
		} catch (ProfitMandiBusinessException e) {
121
			LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
119
			LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
122
		}
120
		}
123
 
121
 
124
		float walletAmount = 0;
-
 
125
		float inStockAmount = 0;
-
 
126
		float unbilledStockAmount = 0;
-
 
127
		float grnPendingStockAmount = 0;
-
 
128
		float shortPercentage = 100;
-
 
129
		float totalInvestedAmount = 0;
-
 
130
		float minimumInvestment = 0;
-
 
131
		float returnedStockInTransit = 0;
-
 
132
		float sale = 0;
122
		float sale = 0;
133
		if (roleManager.isAdmin(loginDetails.getRoleIds())) {
123
		if (roleManager.isAdmin(loginDetails.getRoleIds())) {
134
			model.addAttribute("showAlert", false);
124
			model.addAttribute("showAlert", false);
135
			model.addAttribute("sale", sale);
125
			model.addAttribute("sale", sale);
136
			List<NotificationData> notificationData = null;
126
			List<NotificationData> notificationData = null;
Line 169... Line 159...
169
				model.addAttribute("size", size);
159
				model.addAttribute("size", size);
170
				LOGGER.info("sizeOriginal {}", size);
160
				LOGGER.info("sizeOriginal {}", size);
171
 
161
 
172
			}
162
			}
173
		} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
163
		} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
174
			walletAmount = walletService.getUserWallet(loginDetails.getFofoId()).getAmount();
-
 
175
			inStockAmount = inventoryService.getTotalAmountInStock(loginDetails.getFofoId());
-
 
176
 
164
 
177
			List<Order> unbilledOrders = transactionService.getInTransitOrders(loginDetails.getFofoId());
-
 
178
			for (Order unBilledOrder : unbilledOrders) {
-
 
179
				unbilledStockAmount += unBilledOrder.getTotalAmount();
-
 
180
			}
-
 
181
 
-
 
182
			List<Order> grnPendingOrders = orderRepository.selectPendingGrnOrders(loginDetails.getFofoId());
-
 
183
			for (Order grnPendingOrder : grnPendingOrders) {
-
 
184
				grnPendingStockAmount += grnPendingOrder.getTotalAmount();
-
 
185
			}
-
 
186
			boolean isInvestmentOK = partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30);
-
 
187
			PartnerDailyInvestment pdi = partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 0);
-
 
188
			LOGGER.info("isInvestmentOK {}", isInvestmentOK);
-
 
189
			LOGGER.info("PartnerDailyInvestment {}", pdi);
-
 
190
			totalInvestedAmount = walletAmount + inStockAmount + unbilledStockAmount + grnPendingStockAmount + sale;
-
 
191
			shortPercentage = ((fofoStore.getMinimumInvestment() - totalInvestedAmount)
-
 
192
					/ fofoStore.getMinimumInvestment()) * 100;
-
 
193
			model.addAttribute("showAlert", shortPercentage > 10);
-
 
194
			minimumInvestment = fofoStore.getMinimumInvestment();
-
 
195
 
-
 
196
			// debitNoteRepository.se
-
 
197
			List<NotificationData> notificationData = null;
165
			List<NotificationData> notificationData = null;
198
			long size = 0;
166
			long size = 0;
199
 
167
 
200
			notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
168
			notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
201
			size = notificationPanelRepository.selectCountByActiveFlag(true);
169
			size = notificationPanelRepository.selectCountByActiveFlag(true);
Line 229... Line 197...
229
				model.addAttribute("notificationData", notificationData);
197
				model.addAttribute("notificationData", notificationData);
230
				model.addAttribute("size", size);
198
				model.addAttribute("size", size);
231
				LOGGER.info("sizeOriginal {}", size);
199
				LOGGER.info("sizeOriginal {}", size);
232
 
200
 
233
			}
201
			}
-
 
202
			boolean isInvestmentOK = partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30);
-
 
203
			if(!isInvestmentOK) {
-
 
204
				model.addAttribute("showAlert", true);
-
 
205
			}
234
		}
206
		}
235
		LocalDate endDate = LocalDate.now().minusDays(1);
207
		LocalDate endDate = LocalDate.now().minusDays(1);
236
		LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
208
		LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
237
		LocalDate startDate = weekStartDate.minusWeeks(2);
209
		LocalDate startDate = weekStartDate.minusWeeks(2);
238
		List<PartnerDailyInvestment> partnerInvestments = new ArrayList<>();
210
		List<PartnerDailyInvestment> partnerInvestments = new ArrayList<>();
239
		partnerInvestments.add(partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 0));
211
		PartnerDailyInvestment pdi = partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 0);
-
 
212
		partnerInvestments.add(pdi);
240
		partnerInvestments.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
213
		partnerInvestments.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
241
 
214
 
-
 
215
		model.addAttribute("partnerInvestment", pdi);
242
		model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
216
		model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
243
		model.addAttribute("sale", sale);
217
		model.addAttribute("fofoStore", fofoStore);
244
		model.addAttribute("walletAmount", walletAmount);
-
 
245
		model.addAttribute("inStockAmount", inStockAmount);
-
 
246
		model.addAttribute("unbilledStockAmount", unbilledStockAmount);
-
 
247
		model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
-
 
248
		model.addAttribute("shortPercentage", shortPercentage);
-
 
249
		model.addAttribute("totalInvestedAmount", totalInvestedAmount);
-
 
250
		model.addAttribute("minimumInvestmentAmount", minimumInvestment);
-
 
251
		model.addAttribute("returnedStockInTransit", returnedStockInTransit);
-
 
252
 
-
 
253
		model.addAttribute("fofoStore", fofoStore);
218
		model.addAttribute("fofoStore", fofoStore);
254
		model.addAttribute("walletAmount");
219
		model.addAttribute("walletAmount");
255
		model.addAttribute("appContextPath", request.getContextPath());
220
		model.addAttribute("appContextPath", request.getContextPath());
256
		model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
221
		model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
257
		model.addAttribute("webApiHost", webApiHost);
222
		model.addAttribute("webApiHost", webApiHost);