Subversion Repositories SmartDukaan

Rev

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

Rev 24730 Rev 24731
Line 243... Line 243...
243
								List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
243
								List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
244
								for (ScanRecord scanRecord : scanRecords) {
244
								for (ScanRecord scanRecord : scanRecords) {
245
									if (scanRecord.getType().equals(ScanType.PURCHASE)) {
245
									if (scanRecord.getType().equals(ScanType.PURCHASE)) {
246
										CurrentInventorySnapshot cis = currentInventorySnapshotRepository
246
										CurrentInventorySnapshot cis = currentInventorySnapshotRepository
247
												.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
247
												.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
248
										if (cis.getAvailability() - quantityToReduce >= 0) {
248
										if (cis.getAvailability() - quantityToReduce >= 0 && scanRecord.getQuantity() >= quantityToReduce) {
249
											scanRecord.setQuantity(scanRecord.getQuantity() - quantityToReduce);
249
											scanRecord.setQuantity(scanRecord.getQuantity() - ii.getGoodQuantity());
250
											ii.setInitialQuantity(ii.getInitialQuantity() - quantityToReduce);
250
											ii.setInitialQuantity(ii.getInitialQuantity() - ii.getBadQuantity());
251
											ii.setGoodQuantity(ii.getGoodQuantity() - quantityToReduce);
251
											ii.setGoodQuantity(0);
252
											cis.setAvailability(cis.getAvailability() - quantityToReduce);
252
											cis.setAvailability(cis.getAvailability() - ii.getGoodQuantity());
253
											purchase.setUnfullfilledNonSerializedQuantity(
253
											purchase.setUnfullfilledNonSerializedQuantity(
254
													purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
254
													purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
255
											LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
255
											LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
256
													purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
256
													purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
257
													ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
257
													ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
258
													quantityToReduce);
258
													quantityToReduce);
259
											quantityToReduce = 0;
259
											quantityToReduce = quantityToReduce - ii.getGoodQuantity();
260
											break;
260
											break;
261
										}
261
										}
262
									}
262
									}
263
								}
263
								}
264
							}
264
							}