| 33172 |
tejus.loha |
1 |
package com.spice.profitmandi.service.order;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
import com.spice.profitmandi.common.model.BulkOrderModel;
|
| 33341 |
tejus.loha |
5 |
import com.spice.profitmandi.common.model.LineItemModel;
|
| 33547 |
tejus.loha |
6 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 33341 |
tejus.loha |
7 |
import com.spice.profitmandi.common.model.TransactionApprovalModel;
|
| 33172 |
tejus.loha |
8 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
|
|
9 |
import com.spice.profitmandi.dao.cart.CartService;
|
| 33341 |
tejus.loha |
10 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 34443 |
vikas.jang |
11 |
import com.spice.profitmandi.dao.entity.catalog.Bid;
|
| 33172 |
tejus.loha |
12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 34566 |
ranu |
13 |
import com.spice.profitmandi.dao.entity.fofo.LoanTransaction;
|
| 34312 |
ranu |
14 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
| 33213 |
tejus.loha |
15 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionApprovalStatus;
|
| 33172 |
tejus.loha |
16 |
import com.spice.profitmandi.dao.model.CartItem;
|
|
|
17 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 33341 |
tejus.loha |
18 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 34468 |
vikas.jang |
19 |
import com.spice.profitmandi.dao.repository.catalog.BidRepository;
|
|
|
20 |
import com.spice.profitmandi.dao.repository.catalog.LiquidationRepository;
|
| 33172 |
tejus.loha |
21 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 34443 |
vikas.jang |
22 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 33172 |
tejus.loha |
23 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 34566 |
ranu |
24 |
import com.spice.profitmandi.dao.repository.fofo.LoanTransactionRepository;
|
| 33341 |
tejus.loha |
25 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 33338 |
amit.gupta |
26 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
| 33213 |
tejus.loha |
27 |
import com.spice.profitmandi.dao.repository.transaction.TransactionApprovalRepository;
|
|
|
28 |
import com.spice.profitmandi.dao.repository.transaction.TransactionRepository;
|
|
|
29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 34468 |
vikas.jang |
30 |
import com.spice.profitmandi.dao.service.BidService;
|
| 33338 |
amit.gupta |
31 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 33172 |
tejus.loha |
32 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
33 |
import com.spice.profitmandi.service.wallet.CommonPaymentService;
|
|
|
34 |
import com.spice.profitmandi.service.wallet.WalletService;
|
|
|
35 |
import org.apache.logging.log4j.LogManager;
|
|
|
36 |
import org.apache.logging.log4j.Logger;
|
| 33213 |
tejus.loha |
37 |
import org.apache.poi.ss.usermodel.Cell;
|
| 33172 |
tejus.loha |
38 |
import org.apache.poi.ss.usermodel.Row;
|
|
|
39 |
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
40 |
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
41 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
42 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 33213 |
tejus.loha |
43 |
import org.springframework.stereotype.Service;
|
|
|
44 |
import org.springframework.transaction.annotation.Transactional;
|
| 33172 |
tejus.loha |
45 |
import org.springframework.web.multipart.MultipartFile;
|
|
|
46 |
|
| 33338 |
amit.gupta |
47 |
import java.math.BigDecimal;
|
| 33172 |
tejus.loha |
48 |
import java.util.ArrayList;
|
|
|
49 |
import java.util.List;
|
|
|
50 |
import java.util.Map;
|
|
|
51 |
import java.util.stream.Collectors;
|
|
|
52 |
|
| 33213 |
tejus.loha |
53 |
@Service
|
|
|
54 |
@Transactional(rollbackFor = Throwable.class)
|
| 33172 |
tejus.loha |
55 |
public class BulkOrderService {
|
|
|
56 |
private static final Logger LOGGER = LogManager.getLogger(BulkOrderService.class);
|
|
|
57 |
@Autowired
|
|
|
58 |
CartService cartService;
|
|
|
59 |
@Autowired
|
|
|
60 |
TransactionService transactionService;
|
|
|
61 |
@Autowired
|
|
|
62 |
CommonPaymentService commonPaymentService;
|
|
|
63 |
@Autowired
|
|
|
64 |
TagListingRepository tagListingRepository;
|
|
|
65 |
@Autowired
|
|
|
66 |
WalletService walletService;
|
|
|
67 |
@Autowired
|
|
|
68 |
UserRepository userRepository;
|
| 33213 |
tejus.loha |
69 |
@Autowired
|
|
|
70 |
TransactionRepository transactionRepository;
|
|
|
71 |
@Autowired
|
|
|
72 |
TransactionApprovalRepository transactionApprovalRepository;
|
|
|
73 |
@Autowired
|
|
|
74 |
AddressRepository addressRepository;
|
| 33341 |
tejus.loha |
75 |
@Autowired
|
|
|
76 |
OrderRepository orderRepository;
|
| 34443 |
vikas.jang |
77 |
//TODO:Tejus need to check
|
| 33341 |
tejus.loha |
78 |
@Autowired
|
|
|
79 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
| 33338 |
amit.gupta |
80 |
@Autowired
|
|
|
81 |
SDCreditService sdCreditService;
|
| 34443 |
vikas.jang |
82 |
@Autowired
|
|
|
83 |
private CsService csService;
|
|
|
84 |
@Autowired
|
| 34468 |
vikas.jang |
85 |
private AuthRepository authRepository;
|
| 34443 |
vikas.jang |
86 |
@Autowired
|
| 34468 |
vikas.jang |
87 |
private BidRepository bidRepository;
|
|
|
88 |
@Autowired
|
|
|
89 |
private BidService bidService;
|
| 34566 |
ranu |
90 |
|
| 34468 |
vikas.jang |
91 |
@Autowired
|
| 34566 |
ranu |
92 |
private LoanTransactionRepository loanTransactionRepository;
|
|
|
93 |
|
|
|
94 |
@Autowired
|
| 34468 |
vikas.jang |
95 |
private LiquidationRepository liquidationRepository;
|
| 33338 |
amit.gupta |
96 |
|
|
|
97 |
|
| 34468 |
vikas.jang |
98 |
public void parseBulkOrders(MultipartFile file, int creatorId) throws Exception {
|
| 33172 |
tejus.loha |
99 |
XSSFWorkbook myWorkBook = new XSSFWorkbook(file.getInputStream());
|
|
|
100 |
|
|
|
101 |
myWorkBook.setMissingCellPolicy(Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
|
|
102 |
// Return first sheet from the XLSX workbook
|
|
|
103 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
|
|
104 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
|
|
105 |
List<BulkOrderModel> bulkOrderModels = new ArrayList<>();
|
| 33547 |
tejus.loha |
106 |
LOGGER.info("mySheet.getLastRowNum() - {}", mySheet.getLastRowNum());
|
| 33172 |
tejus.loha |
107 |
for (int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
|
|
|
108 |
XSSFRow row = mySheet.getRow(rowNumber);
|
| 33547 |
tejus.loha |
109 |
LOGGER.info("Row - {}", row);
|
|
|
110 |
if (row != null) {
|
|
|
111 |
BulkOrderModel bulkOrderModel = this.createBulkModel(row);
|
|
|
112 |
bulkOrderModels.add(bulkOrderModel);
|
|
|
113 |
} else {
|
|
|
114 |
break;
|
|
|
115 |
}
|
| 33172 |
tejus.loha |
116 |
}
|
| 34468 |
vikas.jang |
117 |
this.generatePurchaseOrder(bulkOrderModels, creatorId, ProfitMandiConstants.PO_TYPE.MANUAL, ProfitMandiConstants.BID_CRON_ENUM.TODAY);
|
| 34443 |
vikas.jang |
118 |
}
|
|
|
119 |
|
| 34468 |
vikas.jang |
120 |
public void generatePurchaseOrder(List<BulkOrderModel> bulkOrderModels, int creatorId, ProfitMandiConstants.PO_TYPE type, ProfitMandiConstants.BID_CRON_ENUM scheduleType) throws Exception {
|
| 33172 |
tejus.loha |
121 |
Map<Integer, List<BulkOrderModel>> fofoBulkOrdersMap = bulkOrderModels.stream().collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| 34443 |
vikas.jang |
122 |
boolean approvalRequired = false;
|
| 33172 |
tejus.loha |
123 |
for (Map.Entry<Integer, List<BulkOrderModel>> fofoBulkOrderEntry : fofoBulkOrdersMap.entrySet()) {
|
|
|
124 |
int fofoId = fofoBulkOrderEntry.getKey();
|
|
|
125 |
List<BulkOrderModel> fofoBulkOrderModels = fofoBulkOrderEntry.getValue();
|
|
|
126 |
Map<Integer, Long> orderItemCountMap = fofoBulkOrderModels.stream().collect(Collectors.groupingBy(x -> x.getItemId(), Collectors.counting()));
|
|
|
127 |
|
|
|
128 |
if (orderItemCountMap.entrySet().stream().filter(x -> x.getValue() > 1).count() > 0) {
|
|
|
129 |
throw new ProfitMandiBusinessException("Fofo ID", fofoId, "Duplicate in items");
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
boolean hasZeroQuantity = fofoBulkOrderModels.stream().filter(x -> x.getQuantity() <= 0).count() > 0;
|
|
|
133 |
if (hasZeroQuantity) {
|
|
|
134 |
throw new ProfitMandiBusinessException("Item Quantity", "", "Should be greater than 0");
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
List<CartItem> cartItems = new ArrayList<>();
|
| 33338 |
amit.gupta |
138 |
double totalPayableAmount = 0;
|
| 33172 |
tejus.loha |
139 |
for (BulkOrderModel fofoBulkOrderModel : fofoBulkOrderModels) {
|
|
|
140 |
CartItem cartItem = new CartItem();
|
|
|
141 |
cartItem.setQuantity(fofoBulkOrderModel.getQuantity());
|
|
|
142 |
cartItem.setItemId(fofoBulkOrderModel.getItemId());
|
|
|
143 |
TagListing tagListing = tagListingRepository.selectByItemId(fofoBulkOrderModel.getItemId());
|
| 33556 |
amit.gupta |
144 |
if (tagListing == null) {
|
|
|
145 |
String message = "Pricing Does not exist for " + fofoBulkOrderModel.getItemId() + "(" + fofoBulkOrderModel.getDescription() + ")";
|
|
|
146 |
throw new ProfitMandiBusinessException(message, message, message);
|
|
|
147 |
}
|
| 33213 |
tejus.loha |
148 |
double itemSellingPrice = tagListing.getSellingPrice();
|
| 33597 |
tejus.loha |
149 |
boolean isActualPrice = fofoBulkOrderModel.getItemPrice() == itemSellingPrice;
|
|
|
150 |
boolean isPriceZero = fofoBulkOrderModel.getItemPrice() == 0d;
|
| 33213 |
tejus.loha |
151 |
double customSellingPrice = fofoBulkOrderModel.getItemPrice();
|
|
|
152 |
int itemId = cartItem.getItemId();
|
| 33597 |
tejus.loha |
153 |
if (isPriceZero || isActualPrice) {
|
| 33213 |
tejus.loha |
154 |
cartItem.setSellingPrice(itemSellingPrice);
|
|
|
155 |
} else {
|
| 33216 |
tejus.loha |
156 |
if (customSellingPrice <= tagListing.getMrp() || customSellingPrice <= tagListing.getMop()) {
|
| 33213 |
tejus.loha |
157 |
cartItem.setSellingPrice(customSellingPrice);
|
| 34443 |
vikas.jang |
158 |
approvalRequired = true;
|
| 33213 |
tejus.loha |
159 |
|
|
|
160 |
} else {
|
|
|
161 |
throw new ProfitMandiBusinessException("Given price is greater than selling price for item Id - ", itemId, " it should be less or equal of DP");
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
}
|
| 33338 |
amit.gupta |
165 |
totalPayableAmount += cartItem.getSellingPrice() * cartItem.getQuantity();
|
| 33172 |
tejus.loha |
166 |
cartItems.add(cartItem);
|
|
|
167 |
}
|
| 34501 |
vikas.jang |
168 |
Bid bid = null;
|
| 34573 |
vikas.jang |
169 |
ProfitMandiConstants.BID_ENUM finalBidStatus = ProfitMandiConstants.BID_ENUM.CLOSED;
|
| 34501 |
vikas.jang |
170 |
if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
|
|
|
171 |
bid = bidRepository.selectById(fofoBulkOrderModels.get(0).getRowIndex());
|
|
|
172 |
}
|
| 33338 |
amit.gupta |
173 |
LOGGER.info("totalAmount of item " + totalPayableAmount);
|
| 33172 |
tejus.loha |
174 |
double walletAmount = walletService.getWalletAmount(fofoId);
|
| 33338 |
amit.gupta |
175 |
|
|
|
176 |
BigDecimal creditAvailability = sdCreditService.getAvailableAmount(fofoId);
|
|
|
177 |
|
|
|
178 |
double netAmountInHand = creditAvailability.doubleValue() + walletAmount;
|
| 33442 |
tejus.loha |
179 |
LOGGER.info("netAmountInHand - " + netAmountInHand);
|
| 33547 |
tejus.loha |
180 |
if (totalPayableAmount > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE && netAmountInHand < totalPayableAmount) {
|
| 34468 |
vikas.jang |
181 |
if (type.equals(ProfitMandiConstants.PO_TYPE.MANUAL)) {
|
| 34443 |
vikas.jang |
182 |
throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Check wallet Balance once");
|
|
|
183 |
} else {
|
| 34468 |
vikas.jang |
184 |
if (scheduleType.equals(ProfitMandiConstants.BID_CRON_ENUM.TODAY)) {
|
|
|
185 |
bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
|
| 34573 |
vikas.jang |
186 |
finalBidStatus = ProfitMandiConstants.BID_ENUM.PROCESSING;
|
| 34572 |
vikas.jang |
187 |
LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Sending mail to RBM");
|
|
|
188 |
//throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Sending mail to RBM");
|
| 34468 |
vikas.jang |
189 |
} else {
|
| 34492 |
vikas.jang |
190 |
bidService.cancelYesterdayProcessBid(bid);
|
| 34572 |
vikas.jang |
191 |
LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
|
| 34573 |
vikas.jang |
192 |
finalBidStatus = ProfitMandiConstants.BID_ENUM.CANCELLED;
|
| 34572 |
vikas.jang |
193 |
//throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Cancelling the BID");
|
| 34468 |
vikas.jang |
194 |
}
|
| 34443 |
vikas.jang |
195 |
}
|
| 33172 |
tejus.loha |
196 |
}
|
|
|
197 |
UserCart userCart = cartService.setCartItems(fofoId, cartItems);
|
| 33213 |
tejus.loha |
198 |
// createtransactionInternally set the value in transaction table
|
| 33338 |
amit.gupta |
199 |
|
| 33351 |
amit.gupta |
200 |
double creditAmountRequired = totalPayableAmount - walletAmount;
|
| 34312 |
ranu |
201 |
int loanId = 0;
|
| 34492 |
vikas.jang |
202 |
try {
|
|
|
203 |
if (creditAmountRequired > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE) {
|
| 34568 |
vikas.jang |
204 |
Loan loan = sdCreditService.createLoan(userCart.getUserId(), creditAmountRequired, 0, "Credit limit assigned via SD Credit");
|
| 34492 |
vikas.jang |
205 |
loanId = loan.getId();
|
|
|
206 |
}
|
|
|
207 |
} catch (Exception exception){
|
| 34501 |
vikas.jang |
208 |
if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
|
|
|
209 |
bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
|
| 34573 |
vikas.jang |
210 |
finalBidStatus = ProfitMandiConstants.BID_ENUM.PROCESSING;
|
| 34572 |
vikas.jang |
211 |
LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
|
|
|
212 |
//throw new ProfitMandiBusinessException("Skipping order unable to create load for id - ", fofoId, " ,Sending mail to RBM");
|
| 34501 |
vikas.jang |
213 |
}
|
| 33338 |
amit.gupta |
214 |
}
|
| 34443 |
vikas.jang |
215 |
|
| 34573 |
vikas.jang |
216 |
if (finalBidStatus.equals(ProfitMandiConstants.BID_ENUM.CLOSED)) {
|
|
|
217 |
|
|
|
218 |
int transactionId = transactionService.createTransactionInternally(userCart, totalPayableAmount, 0);
|
|
|
219 |
//Set here created by
|
|
|
220 |
Transaction transaction = transactionRepository.selectById(transactionId);
|
|
|
221 |
transaction.setCreatedBy(creatorId);
|
|
|
222 |
LOGGER.info("transaction created by {}", transaction.getCreatedBy());
|
|
|
223 |
commonPaymentService.payThroughWallet(transactionId);
|
|
|
224 |
if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
|
|
|
225 |
bid.setStatus(finalBidStatus);
|
| 34566 |
ranu |
226 |
}
|
| 34573 |
vikas.jang |
227 |
if (approvalRequired) {
|
|
|
228 |
this.createApproval(transactionId);
|
|
|
229 |
if (loanId > 0) {
|
|
|
230 |
LoanTransaction loanTransaction = new LoanTransaction();
|
|
|
231 |
loanTransaction.setLoanId(loanId);
|
|
|
232 |
loanTransaction.setTransactionId(transactionId);
|
|
|
233 |
loanTransactionRepository.persist(loanTransaction);
|
|
|
234 |
}
|
|
|
235 |
} else {
|
|
|
236 |
transactionService.processTransaction(transactionId, loanId);
|
|
|
237 |
}
|
| 33213 |
tejus.loha |
238 |
}
|
|
|
239 |
|
| 33172 |
tejus.loha |
240 |
}
|
|
|
241 |
}
|
|
|
242 |
|
| 33213 |
tejus.loha |
243 |
public void createApproval(int transactionId) {
|
|
|
244 |
TransactionApproval transactionApproval = new TransactionApproval();
|
|
|
245 |
transactionApproval.setId(transactionId);
|
|
|
246 |
transactionApproval.setStatus(TransactionApprovalStatus.PENDING);
|
|
|
247 |
transactionApprovalRepository.persist(transactionApproval);
|
|
|
248 |
}
|
|
|
249 |
|
| 33172 |
tejus.loha |
250 |
private BulkOrderModel createBulkModel(XSSFRow row) throws ProfitMandiBusinessException {
|
|
|
251 |
BulkOrderModel bulkOrderModel = new BulkOrderModel();
|
|
|
252 |
int i = 0;
|
|
|
253 |
bulkOrderModel.setRowIndex(row.getRowNum());
|
|
|
254 |
try {
|
| 33696 |
amit.gupta |
255 |
Cell partnerName = row.getCell(i++);
|
|
|
256 |
if (partnerName == null)
|
| 33213 |
tejus.loha |
257 |
bulkOrderModel.setPartnerName("");
|
|
|
258 |
else
|
| 33696 |
amit.gupta |
259 |
bulkOrderModel.setPartnerName(partnerName.getStringCellValue().trim());
|
| 33213 |
tejus.loha |
260 |
Cell description = row.getCell(i++);
|
|
|
261 |
if (description == null)
|
|
|
262 |
bulkOrderModel.setDescription("");
|
|
|
263 |
else
|
|
|
264 |
bulkOrderModel.setDescription(description.getStringCellValue().trim());
|
|
|
265 |
|
| 33172 |
tejus.loha |
266 |
bulkOrderModel.setFofoId((int) row.getCell(i++).getNumericCellValue());
|
|
|
267 |
bulkOrderModel.setItemId((int) row.getCell(i++).getNumericCellValue());
|
| 33213 |
tejus.loha |
268 |
bulkOrderModel.setItemPrice(row.getCell(i++).getNumericCellValue());
|
| 33172 |
tejus.loha |
269 |
bulkOrderModel.setQuantity((int) row.getCell(i++).getNumericCellValue());
|
|
|
270 |
} catch (Throwable e) {
|
|
|
271 |
LOGGER.info(e.getCause());
|
| 33213 |
tejus.loha |
272 |
throw new ProfitMandiBusinessException("Field", "Field at row - " + row.getRowNum() + ", column - " + (i - 1), "Invalid field value at - " + ExcelUtils.toAlphabet(i - 1) + (row.getRowNum() + 1) + ", " + ExcelUtils.getCellValue(row.getCell(i - 1)));
|
| 33172 |
tejus.loha |
273 |
}
|
|
|
274 |
LOGGER.info(bulkOrderModel);
|
|
|
275 |
return bulkOrderModel;
|
|
|
276 |
}
|
|
|
277 |
|
| 33341 |
tejus.loha |
278 |
// create model for transaction Approval so that finance team see all order and approve
|
|
|
279 |
public List<TransactionApprovalModel> getAllPendingTransactionApproval() throws ProfitMandiBusinessException {
|
|
|
280 |
List<TransactionApproval> transactionApprovals = transactionApprovalRepository.selectAllPending();
|
|
|
281 |
LOGGER.info("list of Approval transaction Id " + transactionApprovals);
|
|
|
282 |
List<TransactionApprovalModel> approvalModelList = new ArrayList<>();
|
|
|
283 |
for (TransactionApproval transactionApproval : transactionApprovals) {
|
|
|
284 |
List<Order> orderList = orderRepository.selectAllByTransactionId(transactionApproval.getId());
|
|
|
285 |
Transaction transaction = transactionRepository.selectById(transactionApproval.getId());
|
|
|
286 |
List<LineItemModel> lineItemModelList = new ArrayList<>();
|
|
|
287 |
for (Order order : orderList) {
|
|
|
288 |
LineItem lineItem = order.getLineItem();
|
|
|
289 |
LineItemModel lineItemModel = new LineItemModel();
|
|
|
290 |
lineItemModel.setItemId(lineItem.getItemId());
|
|
|
291 |
lineItemModel.setItemName(lineItem.getItem().getItemDescription());
|
|
|
292 |
lineItemModel.setItemQuantity(lineItem.getQuantity());
|
|
|
293 |
lineItemModel.setSellingPrice(lineItem.getUnitPrice());
|
|
|
294 |
lineItemModel.setDp(tagListingRepository.selectByItemId(lineItem.getItemId()).getSellingPrice());
|
|
|
295 |
lineItemModelList.add(lineItemModel);
|
|
|
296 |
}
|
|
|
297 |
AuthUser authUser = authRepository.selectById(transaction.getCreatedBy());
|
|
|
298 |
TransactionApprovalModel transactionApprovalModel = new TransactionApprovalModel();
|
|
|
299 |
String retailerName = " ";
|
|
|
300 |
retailerName = orderList.get(0).getRetailerName();
|
|
|
301 |
transactionApprovalModel.setRetailerName(retailerName);
|
| 34573 |
vikas.jang |
302 |
if (authUser == null) {
|
|
|
303 |
transactionApprovalModel.setCreatedBy(retailerName);
|
|
|
304 |
} else {
|
|
|
305 |
transactionApprovalModel.setCreatedBy(authUser.getFullName());
|
|
|
306 |
}
|
| 33341 |
tejus.loha |
307 |
transactionApprovalModel.setCreatedOn(transaction.getCreateTimestamp());
|
|
|
308 |
transactionApprovalModel.setTransactionId(transactionApproval.getId());
|
|
|
309 |
transactionApprovalModel.setLineItemModels(lineItemModelList);
|
|
|
310 |
approvalModelList.add(transactionApprovalModel);
|
| 33172 |
tejus.loha |
311 |
|
| 33341 |
tejus.loha |
312 |
}
|
|
|
313 |
return approvalModelList;
|
|
|
314 |
}
|
|
|
315 |
|
| 33172 |
tejus.loha |
316 |
}
|