Merge pull request 'fixed null pointer Exception' (#16) from print-job-card into main

Reviewed-on: http://git.utopiadeals.com:8080/UIND/cut-to-pack-service/pulls/16
main
saif.haq 2025-03-07 05:21:23 +00:00
commit 229be993d5
1 changed files with 4 additions and 3 deletions

View File

@ -346,12 +346,13 @@ public class InventoryService {
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity())); .collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
for (Bundle subBundle : wrapper.getBundles()) { for (Bundle subBundle : wrapper.getBundles()) {
long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId(); long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId();
if(subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0){ if(subBundle.getCurrentProduction() != null && subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0){
Bundle bundle = bundleDAO.find(subBundle.getId()); Bundle bundle = bundleDAO.find(subBundle.getId());
jobCard = jobCardDAO.find(subBundle.getJobCardId()); jobCard = jobCardDAO.find(subBundle.getJobCardId());
long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue() ; long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue() ;
long wrapQuantity = bundle.getWrapQuantity().longValue(); long wrapQuantity = bundle.getWrapQuantity().longValue();
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(),subBundle.getItemId()); JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(),subBundle.getItemId());
BigDecimal previousTotalProduction = jobCardItem.getTotalProduction() == null ? BigDecimal.ZERO : jobCardItem.getTotalProduction();
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(subBundle.getId(), null); InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(subBundle.getId(), null);
@ -367,10 +368,10 @@ public class InventoryService {
// create IN Transactions of Finished Items into account // create IN Transactions of Finished Items into account
createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name()); createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name());
jobCardItem.setTotalProduction(jobCardItem.getTotalProduction().add(subBundle.getCurrentProduction())); jobCardItem.setTotalProduction(previousTotalProduction.add(subBundle.getCurrentProduction()));
jobCardItem.setJobCardId(jobCard.getId()); jobCardItem.setJobCardId(jobCard.getId());
updatedItems.add(jobCardItem); updatedItems.add(jobCardItem);
BigDecimal pro = subBundle.getCurrentProduction(); BigDecimal pro = BigDecimal.valueOf(production + subBundle.getCurrentProduction().longValue());
bundle.setProduction(pro); bundle.setProduction(pro);
bundleDAO.save(bundle); bundleDAO.save(bundle);
} }