Merge pull request 'po-store-category-items' (#29) from po-store-category-items into main

Reviewed-on: http://git.utopiadeals.com:8080/UIND/cut-to-pack-service/pulls/29
fix-po-pdf-layout^2
saif.haq 2025-06-12 11:00:51 +00:00
commit 3d3f8c4c1e
28 changed files with 672 additions and 153 deletions

View File

@ -0,0 +1,56 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.PurchaseOrderCTPRole;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.service.PurchaseOrderService;
import com.utopiaindustries.service.ReportingService;
import com.utopiaindustries.service.SummaryInventoryReportService;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/po-status")
@PurchaseOrderCTPRole
public class POStatusController {
private final ReportingService reportingService;
private final PurchaseOrderService purchaseOrderService;
public POStatusController(ReportingService reportingService, PurchaseOrderService purchaseOrderService) {
this.reportingService = reportingService;
this.purchaseOrderService = purchaseOrderService;
}
@GetMapping
public String homePage( Model model ){
return "redirect:/po-status/all-pos";
}
@GetMapping( "/all-pos")
public String poReport(@RequestParam(value = "poName", required = false) String poName, Model model){
model.addAttribute("allPOs", reportingService.getAllPOs(poName));
return "/reporting/po-report";
}
@GetMapping( value = "/po-report-view/{poId}" )
public String showJobCardDetail(@PathVariable("poId") long poId, @RequestParam(value = "select-date", required = false) String selectDate ,
Model model ){
model.addAttribute("allJobCard", reportingService.getAllPoJobCards(poId, selectDate));
return "/reporting/po-job-card-report";
}
@GetMapping(value = "/generate-po-pdf", produces = MediaType.APPLICATION_PDF_VALUE)
public ResponseEntity<InputStreamResource> sendPoAndReturnPdf(@ModelAttribute POsDetails pOsDetails,
@RequestParam(required = false, defaultValue = "true") boolean includeJobCard,
@RequestParam(required = false, defaultValue = "true") boolean includeStoreDetails,
Model model) throws Exception{
return purchaseOrderService.generatePOPdf(pOsDetails, model, includeJobCard, includeStoreDetails);
}
}

View File

@ -5,6 +5,7 @@ import com.utopiaindustries.model.ctp.JobCard;
import com.utopiaindustries.model.ctp.PurchaseOrderCTP;
import com.utopiaindustries.service.PurchaseOrderCTPService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@ -85,6 +86,11 @@ public class PurchaseOrderCTPController {
return "redirect:/purchase-order";
}
@GetMapping( "/store-items/{id}" )
public String getPOStoreItems( @PathVariable("id") long poId,
Model model ){
model.addAttribute("storeItems", purchaseOrderCTPService.getStoreItemsByPoId( poId ));
return "/reporting/po-store-items-table";
}
}

View File

@ -1,17 +1,19 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.ReportingRole;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.model.ctp.SummaryInventoryReport;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.service.PurchaseOrderService;
import com.utopiaindustries.service.ReportingService;
import com.utopiaindustries.service.SummaryInventoryReportService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.time.LocalDate;
@ -26,17 +28,19 @@ public class ReportingController {
private final ReportingService reportingService;
private final SummaryInventoryReportService summaryInventoryReportService;
private final InventoryAccountService inventoryAccountService;
private final PurchaseOrderService purchaseOrderService;
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2, ReportingService reportingService, InventoryAccountService inventoryAccountService) {
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2, ReportingService reportingService, InventoryAccountService inventoryAccountService, PurchaseOrderService purchaseOrderService) {
this.summaryInventoryReportService = summaryInventoryReportService2;
this.reportingService = reportingService;
this.inventoryAccountService = inventoryAccountService;
this.purchaseOrderService = purchaseOrderService;
}
@GetMapping
public String homePage( Model model ){
return "redirect:/reporting/po-report";
return "redirect:/reporting/job-card-report";
}
@GetMapping( "/summary")
@ -73,20 +77,6 @@ public class ReportingController {
return "/reporting/job-card-report";
}
@GetMapping( "/po-report")
public String poReport(@RequestParam(value = "poName", required = false) String poName, Model model){
model.addAttribute("allPOs", reportingService.getAllPOs(poName));
return "/reporting/po-report";
}
@GetMapping( value = "/po-report-view/{poNo}" )
public String showJobCardDetail( @PathVariable("poNo") String poNo, @RequestParam(value = "select-date", required = false) String selectDate ,
Model model ){
model.addAttribute("allJobCard", reportingService.getAllPoJobCards(poNo, selectDate));
return "/reporting/po-job-card-report";
}
@GetMapping( value = "/cutting-report" )
public String cuttingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
@ -129,7 +119,6 @@ public class ReportingController {
return "/reporting/accounts-transaction-table";
}
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
ArrayList<LocalDate> localDates = new ArrayList<>();
while (start.isBefore(end)) {

View File

@ -32,7 +32,7 @@ public class FinishedItemDAO {
private final String SELECT_BY_TERM_FOR_PACKAGING = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated AND qa_status = :qa_status AND is_packed = FALSE AND is_store = FALSE ORDER BY ID DESC", TABLE_NAME);
private final String SELECT_BY_STITCHED_ITEM_ID = String.format("SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id AND is_packed = FALSE", TABLE_NAME);
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format("SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_segregated IS TRUE ", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_qa = TRUE AND (is_segregated IS TRUE OR is_store = TRUE) ", TABLE_NAME);
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME);
private final String SELECT_BY_DATE_QA_STATUS = String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR operation_date >= :start_date) AND operation_date <= :end_date AND qa_status = :qa_status AND id in (:ids) AND is_packed = FALSE AND is_qa = TRUE", TABLE_NAME );

View File

@ -21,7 +21,7 @@ public class JobCardDAO {
private final String TABLE_NAME = "cut_to_pack.job_card";
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
private final String SELECT_ALL_QUERY_WITH_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC limit :limit", TABLE_NAME );
private final String SELECT_ALL_BY_PO_ID = String.format( "SELECT * FROM %s WHERE purchase_order_id = :purchase_order_id", TABLE_NAME );
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, code, job_order_id, created_at, created_by, status, inventory_status, customer, lot_number, purchase_order_id, location_site_id, description, poQuantity, articleName) VALUES (:id, :code, :job_order_id, :created_at, :created_by, :status, :inventory_status, :customer, :lot_number, :purchase_order_id, :location_site_id, :description, :poQuantity, :articleName) ON DUPLICATE KEY UPDATE code = VALUES(code), job_order_id = VALUES(job_order_id), created_at = VALUES(created_at), created_by = VALUES(created_by), status = VALUES(status), inventory_status = VALUES(inventory_status), customer = VALUES(customer), lot_number = VALUES(lot_number), purchase_order_id = VALUES(purchase_order_id), location_site_id = VALUES(location_site_id), description = VALUES(description), poQuantity = VALUES(poQuantity), articleName = VALUES(articleName) ", TABLE_NAME );
private final String SELECT_BY_LIKE_CODE_AND_INV_STATUS_AND_STATUS = String.format( "SELECT * FROM %s WHERE code like :code AND status = :status AND inventory_status = :inventory_status", TABLE_NAME );
@ -114,9 +114,9 @@ public class JobCardDAO {
return namedParameterJdbcTemplate.query( query, new JobCardRowMapper() );
}
public List<JobCard> findByAllWithLimit(Long limit){
public List<JobCard> findByPoId(long poId){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("limit", limit.intValue());
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY_WITH_LIMIT, params, new JobCardRowMapper() );
params.addValue("purchase_order_id", poId);
return namedParameterJdbcTemplate.query( SELECT_ALL_BY_PO_ID, params, new JobCardRowMapper() );
}
}

View File

@ -23,8 +23,8 @@ public class PurchaseOrderCTPDao {
private final String TABLE_NAME = "cut_to_pack.purchase_order";
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
private final String SELECT_ALL_QUERY_WITH_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC limit :limit", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ", TABLE_NAME );
private final String SELECT_BY_PO_CODE = String.format( "SELECT * FROM %s WHERE purchase_order_code = :purchase_order_code", TABLE_NAME );
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
private final String INSERT_QUERY = String.format(
"INSERT INTO %s (id, purchase_order_code, purchase_order_quantity, purchase_order_quantity_required, article_name, created_by, status) " +
@ -107,10 +107,10 @@ public class PurchaseOrderCTPDao {
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT, params, new PurchaseOrderCTPRowMapper() );
}
public List<PurchaseOrderCTP> findByAllWithLimit(Long limit){
public List<PurchaseOrderCTP> findByPoCode(String poCode){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("limit", limit.intValue());
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY_WITH_LIMIT, params, new PurchaseOrderCTPRowMapper() );
params.addValue("purchase_order_code", poCode);
return namedParameterJdbcTemplate.query( SELECT_BY_PO_CODE, params, new PurchaseOrderCTPRowMapper() );
}
/*

View File

@ -1,6 +1,5 @@
package com.utopiaindustries.dao.ctp;
import com.utopiaindustries.model.ctp.PackagingItems;
import com.utopiaindustries.model.ctp.StoreItem;
import com.utopiaindustries.util.KeyHolderFunctions;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@ -10,7 +9,9 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class StoreItemDao {
@ -23,25 +24,24 @@ public class StoreItemDao {
private static final String SELECT_ALL = String.format("SELECT * FROM %s ORDER BY id DESC", TABLE_NAME);
private static final String DELETE_BY_ID = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
private static final String SELECT_BY_JOB_CARD_ID = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME);
private static final String INSERT_QUERY = String.format(
"INSERT INTO %s (" +
"id, item_id, sku, barcode, job_card_id, created_at, created_by, " +
"finish_item_id, account_id, bundle_id" +
"finish_item_id, account_id, bundle_id, reject_reason" +
") VALUES (" +
":id, :item_id, :sku, :barcode, :job_card_id, :created_at, :created_by, " +
":finish_item_id, :account_id, :bundle_id" +
":finish_item_id, :account_id, :bundle_id, :reject_reason" +
") ON DUPLICATE KEY UPDATE " +
"item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), " +
"job_card_id = VALUES(job_card_id), created_at = VALUES(created_at), created_by = VALUES(created_by), " +
"finish_item_id = VALUES(finish_item_id), account_id = VALUES(account_id), bundle_id = VALUES(bundle_id)",
"finish_item_id = VALUES(finish_item_id), account_id = VALUES(account_id), bundle_id = VALUES(bundle_id), reject_reason = VALUES(reject_reason)",
TABLE_NAME
);
String SELECT_BY_JOB_CARD_GROUP_REJECT_REASON = String.format("SELECT reject_reason, COUNT(*) AS total FROM %s WHERE job_card_id IN (:job_card_id) GROUP BY reject_reason", TABLE_NAME);
private static final String SELECT_BY_DATE_AND_IDs = String.format(
"SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR created_at >= :start_date) AND created_at <= :end_date AND id IN (:ids)",
TABLE_NAME
);
private static final String SELECT_BY_DATE_AND_IDs = String.format("SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR created_at >= :start_date) AND created_at <= :end_date AND id IN (:ids)", TABLE_NAME);
public StoreItemDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
@ -58,7 +58,8 @@ public class StoreItemDao {
.addValue("created_by", item.getCreatedBy())
.addValue("finish_item_id", item.getFinishedItemId())
.addValue("account_id", item.getAccountId())
.addValue("bundle_id", item.getBundleId());
.addValue("bundle_id", item.getBundleId())
.addValue("reject_reason", item.getRejectedReason());
}
public StoreItem find(long id) {
@ -96,6 +97,13 @@ public class StoreItemDao {
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_ID, params, new StoreItemRowMapper());
}
public Long calculateTotalRejectItemByJobCardId(long jobCardId) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("job_card_id", jobCardId);
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_FINISH_ITEM, params, Long.class);
return count != null ? count : 0;
}
public Long findByDateAndIds(String startDate, String endDate, List<Long> ids) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("start_date", startDate);
@ -104,4 +112,20 @@ public class StoreItemDao {
Long count = namedParameterJdbcTemplate.queryForObject(SELECT_BY_DATE_AND_IDs, params, Long.class);
return count != null ? count : 0;
}
public Map<String, Integer> totalCountByJobCardIdsAndGroupByRejectReason(List<Long> jobCardIds) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("job_card_id", jobCardIds);
List<Map<String, Object>> rows = namedParameterJdbcTemplate.queryForList(SELECT_BY_JOB_CARD_GROUP_REJECT_REASON, params);
Map<String, Integer> result = new HashMap<>();
for (Map<String, Object> row : rows) {
String reason = (String) row.get("reject_reason");
Integer total = ((Number) row.get("total")).intValue();
result.put(reason, total);
}
return result;
}
}

View File

@ -21,6 +21,7 @@ public class StoreItemRowMapper implements RowMapper<StoreItem> {
item.setFinishedItemId(rs.getLong("finish_item_id"));
item.setAccountId(rs.getLong("account_id"));
item.setBundleId(rs.getLong("bundle_id"));
item.setRejectedReason(rs.getString("reject_reason"));
return item;
}
}

View File

@ -6,6 +6,7 @@ public class FinishedItemWrapper {
private String qaStatus;
private Long accountId;
private String rejectReason;
private List<FinishedItem> items;
@ -33,6 +34,14 @@ public class FinishedItemWrapper {
this.accountId = accountId;
}
public String getRejectReason() {
return rejectReason;
}
public void setRejectReason(String rejectReason) {
this.rejectReason = rejectReason;
}
@Override
public String toString() {
return "FinishedItemWrapper{" +

View File

@ -1,9 +1,14 @@
package com.utopiaindustries.model.ctp;
public class POsDetails {
//po detail
private long poId;
private String poNumber;
private String articleTitle;
private long poQuantity;
private long poRequiredQuantity;
// items detail
private long totalCutting;
private long remainingCutting;
private long totalStitching;
@ -15,6 +20,7 @@ public class POsDetails {
private long totalAGradeItem;
private long totalBGradeItem;
private long totalCGradeItem;
private boolean poStatus;
public long getPoQuantity() {
return poQuantity;
@ -128,6 +134,30 @@ public class POsDetails {
this.totalCGradeItem = totalCGradeItem;
}
public long getPoId() {
return poId;
}
public void setPoId(long poId) {
this.poId = poId;
}
public long getPoRequiredQuantity() {
return poRequiredQuantity;
}
public void setPoRequiredQuantity(long poRequiredQuantity) {
this.poRequiredQuantity = poRequiredQuantity;
}
public boolean isPoStatus() {
return poStatus;
}
public void setPoStatus(boolean poStatus) {
this.poStatus = poStatus;
}
@Override
public String toString() {
return "POsDetails{" +

View File

@ -18,6 +18,7 @@ public class StoreItem implements InventoryArtifact {
private long finishedItemId;
private long bundleId;
private long accountId;
private String rejectedReason;
@Override
@ -122,4 +123,29 @@ public class StoreItem implements InventoryArtifact {
public void setAccountId(long accountId) {
this.accountId = accountId;
}
public String getRejectedReason() {
return rejectedReason;
}
public void setRejectedReason(String rejectedReason) {
this.rejectedReason = rejectedReason;
}
@Override
public String toString() {
return "StoreItem{" +
"id=" + id +
", itemId=" + itemId +
", sku='" + sku + '\'' +
", barcode='" + barcode + '\'' +
", jobCardId=" + jobCardId +
", createdAt=" + createdAt +
", createdBy='" + createdBy + '\'' +
", finishedItemId=" + finishedItemId +
", bundleId=" + bundleId +
", accountId=" + accountId +
", rejectedReason='" + rejectedReason + '\'' +
'}';
}
}

View File

@ -131,6 +131,7 @@ public class DashboardService {
progress.put("ALTER", (float) alterationPieceFinish);
progress.put("Reject", (float) rejectFinishedItem);
progress.put("wash", (float) washFinishedItem);
progress.put("finishingValueForBarChart", (float) approved + alterationPieceFinish + rejectFinishedItem + washFinishedItem + packagingItems);
progress.put("packaging", (float) packagingItems);
progress.put("totalPackaging", (float) packagingItemIDs.size());

View File

@ -741,7 +741,7 @@ public class InventoryService {
if (finishedItem.getQaStatus().equalsIgnoreCase("REJECT")) {
// create OUT and IN transactions for FI
StoreItem storeItem = (createStoreItems(finishedItem));
StoreItem storeItem = (createStoreItems(finishedItem, wrapper.getRejectReason()));
storeItem.setId(storeItemDao.save(storeItem));
if (lastInvTransaction != null) {
// OUT
@ -751,7 +751,7 @@ public class InventoryService {
// IN
createInventoryTransactionLeg(transaction, storeItem, toAccount, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.STORED_ITEM.name());
}
finishedItem.setIsSegregated(false);
finishedItem.setIsSegregated(true);
finishedItem.setStore(true);
storeItems.add(storeItem);
}
@ -788,7 +788,7 @@ public class InventoryService {
return packagingItems;
}
private StoreItem createStoreItems(FinishedItem finishedItem) {
private StoreItem createStoreItems(FinishedItem finishedItem, String reason) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
StoreItem storeItem = new StoreItem();
storeItem.setItemId(finishedItem.getItemId());
@ -799,6 +799,7 @@ public class InventoryService {
storeItem.setBarcode(finishedItem.getBarcode());
storeItem.setCreatedAt(LocalDateTime.now());
storeItem.setCreatedBy(authentication.getName());
storeItem.setRejectedReason(reason);
return storeItem;
}
}

View File

@ -1,6 +1,8 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.JobCardDAO;
import com.utopiaindustries.dao.ctp.PurchaseOrderCTPDao;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.model.ctp.*;
import com.utopiaindustries.model.uind.PurchaseOrder;
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
@ -14,15 +16,22 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderCTPService {
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final JobCardDAO jobCardDAO;
private final StoreItemDao storeItemDao;
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao) {
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao, JobCardDAO jobCardDAO, StoreItemDao storeItemDao) {
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.jobCardDAO = jobCardDAO;
this.storeItemDao = storeItemDao;
}
/*
@ -77,4 +86,17 @@ public class PurchaseOrderCTPService {
return purchaseOrderCTPDao.findByTerm( term );
}
public Map<String,Integer> getStoreItemsByPoId(Long poId){
Map<String,Integer> totalItems = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findByPoId(poId);
List<Long> jobCardIds = jobCards.stream()
.map(JobCard::getId)
.collect(Collectors.toList());
if(!jobCardIds.isEmpty()){
return storeItemDao.totalCountByJobCardIdsAndGroupByRejectReason(jobCardIds);
}else {
return totalItems;
}
}
}

View File

@ -1,21 +1,57 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.dao.uind.PurchaseOrderDAO;
import com.utopiaindustries.model.ctp.JobCardItem;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.model.uind.PurchaseOrder;
import com.utopiaindustries.util.HTMLBuilder;
import com.utopiaindustries.util.PDFResponseEntityInputStreamResource;
import com.utopiaindustries.util.URLUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderService {
private final PurchaseOrderDAO purchaseOrderDAO;
private final PurchaseOrderCTPService purchaseOrderCTPService;
private final HTMLBuilder htmlBuilder;
private PDFResponseEntityInputStreamResource pdfGenerator;
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO) {
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO, PurchaseOrderCTPService purchaseOrderCTPService, HTMLBuilder htmlBuilder, PDFResponseEntityInputStreamResource pdfGenerator) {
this.purchaseOrderDAO = purchaseOrderDAO;
this.purchaseOrderCTPService = purchaseOrderCTPService;
this.htmlBuilder = htmlBuilder;
this.pdfGenerator = pdfGenerator;
}
public List<PurchaseOrder> findByTerm( String term ){
return purchaseOrderDAO.findByTerm( term );
}
/**
* Print Job card *
* **/
public ResponseEntity<InputStreamResource> generatePOPdf(POsDetails pOsDetails, Model model, boolean jobCardDetail, boolean storeDetail ) throws Exception {
Map<String,Integer> storeItems = purchaseOrderCTPService.getStoreItemsByPoId(pOsDetails.getPoId());
model.addAttribute("poDetail", pOsDetails);
model.addAttribute( "baseUrl", URLUtils.getCurrentBaseUrl() );
if (storeDetail && !storeItems.isEmpty()){
model.addAttribute("showStore", true);
model.addAttribute("store", storeItems);
}else {
model.addAttribute("showStore", false);
}
String htmlStr = htmlBuilder.buildHTML( "po-status-pdf", model );
// return pdf
return pdfGenerator.generatePdf( htmlStr, "Po-status", "inline" );
}
}

View File

@ -22,31 +22,25 @@ import java.util.stream.Collectors;
public class ReportingService {
private final JobCardItemDAO jobCardItemDAO;
private final ProcessDAO processDAO;
private final BundleDAO bundleDAO;
private final InventoryTransactionLegDAO inventoryTransactionLegDAO;
private final InventoryTransactionDAO inventoryTransactionDAO;
private final JobCardDAO jobCardDAO;
private final CryptographyService cryptographyService;
private final MasterBundleDAO masterBundleDAO;
private final FinishedItemDAO finishedItemDAO;
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
private final InventoryAccountDAO inventoryAccountDAO;
private final PackagingItemsDAO packagingItemsDAO;
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final StoreItemDao storeItemDao;
public ReportingService(JobCardItemDAO jobCardItemDAO, ProcessDAO processDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, InventoryTransactionDAO inventoryTransactionDAO, JobCardDAO jobCardDAO, CryptographyService cryptographyService, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PackagingItemsDAO packagingItemsDAO) {
public ReportingService(JobCardItemDAO jobCardItemDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, JobCardDAO jobCardDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PurchaseOrderCTPDao purchaseOrderCTPDao, StoreItemDao storeItemDao) {
this.jobCardItemDAO = jobCardItemDAO;
this.processDAO = processDAO;
this.bundleDAO = bundleDAO;
this.inventoryTransactionLegDAO = inventoryTransactionLegDAO;
this.inventoryTransactionDAO = inventoryTransactionDAO;
this.jobCardDAO = jobCardDAO;
this.cryptographyService = cryptographyService;
this.masterBundleDAO = masterBundleDAO;
this.finishedItemDAO = finishedItemDAO;
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
this.inventoryAccountDAO = inventoryAccountDAO;
this.packagingItemsDAO = packagingItemsDAO;
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.storeItemDao = storeItemDao;
}
public Map<String, Integer> getJobCardProgress(String jobCardID) {
@ -216,7 +210,7 @@ public class ReportingService {
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(Long.parseLong(jobCardID));
List<FinishedItem> bGradeFinishItemsIds= finishedItems.stream()
.filter(item -> "B GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
.filter(item -> "REJECT".equals(item.getQaStatus())).collect(Collectors.toList());
List<FinishedItem> cGradeFinishItemsIds= finishedItems.stream()
.filter(item -> "C GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
@ -281,9 +275,6 @@ public class ReportingService {
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal expectedProduction = jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getExpectedProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
if(actualProduction.compareTo(totalProduction) == 0) {
phasePending.put("Stitching Total Time", null);
}else {
@ -444,37 +435,28 @@ public class ReportingService {
return barChartData;
}
public List<POsDetails> getAllPOs(String poName) {
public List<POsDetails> getAllPOs(String poCode) {
List<POsDetails> pOsDetailsList = new ArrayList<>();
List<JobCard> jobCards = jobCardDAO.findAll() ;
HashMap<String, List<JobCard>> filterJobCardsByPos;
if(poName != null && !poName.isEmpty()) {
filterJobCardsByPos = jobCards.stream()
.filter(jobCard -> jobCard.getPurchaseOrderId().equals(poName))
.collect(Collectors.groupingBy(
JobCard::getPurchaseOrderId,
HashMap::new,
Collectors.toList()
));
List<PurchaseOrderCTP> purchaseOrderCTPList;
if (poCode != null && !poCode.isEmpty()) {
purchaseOrderCTPList = purchaseOrderCTPDao.findByPoCode(poCode);
}else {
filterJobCardsByPos = jobCards.stream()
.collect(Collectors.groupingBy(
JobCard::getPurchaseOrderId,
HashMap::new,
Collectors.toList()
));
purchaseOrderCTPList = purchaseOrderCTPDao.findAll();
}
Map<String,Integer> jobCardCompleteItems = new HashMap<>();
for (String pos : filterJobCardsByPos.keySet()) {
for (PurchaseOrderCTP pos : purchaseOrderCTPList) {
List<JobCard> jobCards = jobCardDAO.findByPoId(pos.getId());
BigDecimal totalProduction = BigDecimal.ZERO;
BigDecimal actualProduction = BigDecimal.ZERO;
int poQuantity = 0;
String articleName = "";
Long qaProgressItems = 0L;
Long totalFinishItem = 0L;
Long totalRejectPieces = 0L;
POsDetails pOsDetails = new POsDetails();
for (JobCard jobCard : filterJobCardsByPos.get(pos)) {
for (JobCard jobCard : jobCards) {
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCard.getId());
totalProduction = totalProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
@ -483,56 +465,52 @@ public class ReportingService {
actualProduction = actualProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
poQuantity = jobCard.getPoQuantity();
articleName = jobCard.getArticleName();
qaProgressItems += Optional.ofNullable(stitchingOfflineItemDAO.CalculateTotalQA(jobCard.getId())).orElse(0L);
totalFinishItem += Optional.ofNullable(finishedItemDAO.calculateTotalFinishItem(jobCard.getId())).orElse(0L);
totalRejectPieces += Optional.ofNullable(storeItemDao.calculateTotalRejectItemByJobCardId(jobCard.getId())).orElse(0L);
jobCardCompleteItems = getSegregateItems(String.valueOf(jobCard.getId()));
if (jobCardCompleteItems == null) {
jobCardCompleteItems = new HashMap<>();
}
}
pOsDetails.setPoNumber(pos);
pOsDetails.setArticleTitle(articleName);
pOsDetails.setPoQuantity(poQuantity);
pOsDetails.setPoId(pos.getId());
pOsDetails.setPoNumber(pos.getPurchaseOrderCode());
pOsDetails.setArticleTitle(pos.getArticleName());
pOsDetails.setPoQuantity(pos.getPurchaseOrderQuantity());
pOsDetails.setPoRequiredQuantity(pos.getPurchaseOrderQuantityRequired());
pOsDetails.setTotalCutting(actualProduction.intValue());
pOsDetails.setTotalStitching(totalProduction.intValue());
pOsDetails.setTotalStitching(qaProgressItems);
pOsDetails.setTotalEndLineQC(qaProgressItems.intValue());
pOsDetails.setTotalFinishing(totalFinishItem);
pOsDetails.setPoStatus(false);
pOsDetails.setRemainingCutting(poQuantity - actualProduction.intValue());
pOsDetails.setRemainingStitching(poQuantity - totalProduction.intValue());
pOsDetails.setRemainingEndLineQC(poQuantity - qaProgressItems);
pOsDetails.setRemainingFinishing(poQuantity - totalFinishItem);
pOsDetails.setRemainingCutting(pos.getPurchaseOrderQuantityRequired() - actualProduction.intValue());
pOsDetails.setRemainingStitching(pos.getPurchaseOrderQuantityRequired() - qaProgressItems);
pOsDetails.setRemainingEndLineQC(pos.getPurchaseOrderQuantityRequired() - qaProgressItems);
pOsDetails.setRemainingFinishing(pos.getPurchaseOrderQuantityRequired() - totalFinishItem);
pOsDetails.setTotalAGradeItem(jobCardCompleteItems.getOrDefault("A GRADE", 0));
pOsDetails.setTotalBGradeItem(jobCardCompleteItems.getOrDefault("B GRADE", 0));
pOsDetails.setTotalCGradeItem(jobCardCompleteItems.getOrDefault("C GRADE", 0));
pOsDetails.setTotalBGradeItem(totalRejectPieces.intValue());
pOsDetailsList.add(pOsDetails);
}
return pOsDetailsList;
}
public HashMap<String, Map<String, Integer>> getAllPoJobCards(String PONumber, String selectDate) {
public HashMap<String, Map<String, Integer>> getAllPoJobCards(long poId, String selectDate) {
String startDate = selectDate != null && !selectDate.isEmpty() ? selectDate + " 00:00:01": null;
String endDate = selectDate != null && !selectDate.isEmpty() ? selectDate + " 23:59:59": null;
HashMap<String, Map<String, Integer>> poJobCardItemsProgress = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findAll();
// Filter JobCards by Purchase Order ID
List<JobCard> filterJobCardsByPos = jobCards.stream()
.filter(e -> e.getPurchaseOrderId().equals(PONumber))
.collect(Collectors.toList());
List<JobCard> filterJobCardsByPos = jobCardDAO.findByPoId(poId);
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.getPackagingAccounts();
List<Integer> gradingAccounts = inventoryAccounts.stream().map(e-> (int)(e.getId())).collect(Collectors.toList());
for (JobCard jobCard : filterJobCardsByPos) {
List<Bundle> bundles = bundleDAO.findByCardIdAndDATE(jobCard.getId(),startDate,endDate);
List<StitchingOfflineItem> stitchingOfflineItems = stitchingOfflineItemDAO.findByJobCardIdAndDate(jobCard.getId(),startDate,endDate);
List<FinishedItem> finishedItems = finishedItemDAO.calculateTotalFinishItem(jobCard.getId(),startDate,endDate);
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.getTransactionByJobCardAndDatesAndTypeAndAccountID(jobCard.getId(),startDate,endDate,"IN", gradingAccounts);
//cutting days wise
BigDecimal cutting = bundles.stream()
@ -544,26 +522,21 @@ public class ReportingService {
//total qa
Integer qa = finishedItems.size();
Map<String, Integer> segregateItems = inventoryTransactionLegs.stream()
.filter(leg -> inventoryAccounts.stream()
.anyMatch(account -> (int) account.getId() == (leg.getAccountId())))
.collect(Collectors.toMap(
leg -> inventoryAccounts.stream()
.filter(account -> (int) account.getId() == (leg.getAccountId()))
.findFirst()
.map(InventoryAccount::getTitle)
.orElse("Unknown"),
leg -> leg.getQuantity().intValue(),
Integer::sum,
HashMap::new
Map<String, Integer> segregateItems = finishedItems.stream()
.collect(Collectors.groupingBy(
FinishedItem::getQaStatus,
Collectors.collectingAndThen(
Collectors.counting(),
Long::intValue
)
));
Map<String, Integer> items = getCompleteProduction(String.valueOf(jobCard.getId()));
items.put("Cutting Progress",cutting.intValue());
items.put("Stitching Progress",stitching);
items.put("QA Progress",qa);
items.put("A Grade",segregateItems.get("A GRADE") != null ? segregateItems.get("A GRADE") : 0);
items.put("B Grade",segregateItems.get("B GRADE") != null ? segregateItems.get("B GRADE") : 0);
items.put("C Grade",segregateItems.get("C GRADE") != null ? segregateItems.get("C GRADE") : 0);
items.put("A Grade",segregateItems.get("APPROVED") != null ? segregateItems.get("APPROVED") : 0);
items.put("B Grade / Reject",segregateItems.get("REJECT") != null ? segregateItems.get("REJECT") : 0);
// Define sorting order
Map<String, Integer> indexMap = new HashMap<>();
@ -572,9 +545,8 @@ public class ReportingService {
indexMap.put("Stitching Progress", 3);
indexMap.put("QA Progress", 4);
indexMap.put("Finishing Progress", 5);
indexMap.put("A GRADE", 6);
indexMap.put("B GRADE", 7);
indexMap.put("C GRADE", 8);
indexMap.put("APPROVED", 6);
indexMap.put("REJECT", 7);
// Sort items based on indexMap order
Map<String, Integer> sortedItems = items.entrySet()

View File

@ -221,7 +221,7 @@
items: [],
purchaseOrderID:0,
articleName: '',
purchaseOrderQuantity: 0,
purchaseOrderQuantityRequired: 0,
purchaseOrderCode: '',
},
methods: {
@ -266,7 +266,7 @@
}, onPoSelect(id,purchaseOrder) {
this.purchaseOrderID = id,
this.articleName = purchaseOrder.articleName,
this.purchaseOrderQuantity = purchaseOrder.purchaseOrderQuantity,
this.purchaseOrderQuantityRequired = purchaseOrder.purchaseOrderQuantityRequired,
this.purchaseOrderCode = purchaseOrder.purchaseOrderCode
}
},
@ -274,7 +274,7 @@
this.jobCard = window.ctp.jobCard;
this.purchaseOrderID = this.jobCard.purchaseOrderId,
this.articleName = this.jobCard.articleName,
this.purchaseOrderQuantity = this.jobCard.poQuantity,
this.purchaseOrderQuantityRequired = this.jobCard.poQuantity,
this.purchaseOrderCode = this.jobCard.purchaseOrderTitle
this.items = this.jobCard.items;

View File

@ -76,7 +76,8 @@
let app = new Vue({
el : '#packagingApp',
data : {
items : []
items : [],
reason: '',
},
methods : {
onItemSelect: function (id, item) {
@ -90,6 +91,18 @@
const uniqueIds = new Set(ids);
return ids.length !== uniqueIds.size;
},
submitWithRejectReason: function (reason) {
this.reason = reason;
this.$nextTick(() => {
const form = document.getElementById('packagingApp');
if (form.checkValidity()) {
form.submit();
} else {
form.reportValidity();
}
});
}
},
mounted : function () {
console.log( this.$accounts )

View File

@ -88,7 +88,12 @@
submitWithQaStatus: function (status) {
this.QaStatus = status;
this.$nextTick(() => {
document.getElementById('qcForm').submit();
const form = document.getElementById('qcForm');
if (form.checkValidity()) {
form.submit();
} else {
form.reportValidity();
}
});
}
},

View File

@ -78,6 +78,10 @@
<a th:href="@{/store/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store') ? 'active' : ''}">Store</a>
</li>
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status') ? 'active' : ''}">
<a th:href="@{/po-status/}" class="nav-link">Online PO Status</a>
</li>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_REPORTING', 'ROLE_ADMIN')">
<a th:href="@{/reporting/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting') ? 'active' : ''}">Reporting</a>
@ -183,10 +187,6 @@
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/po-report') ? 'active' : ''}">
<a th:href="@{/reporting/po-report}" class="nav-link">PO Report</a>
</li>
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/job-card-report') ? 'active' : ''}">
<a th:href="@{/reporting/job-card-report}" class="nav-link">Job Card Report</a>
@ -205,6 +205,17 @@
</li>
</ul>
</nav>
<!--Second level of po-status-->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status/all-pos') ? 'active' : ''}">
<a th:href="@{/po-status/all-pos}" class="nav-link">All PO's</a>
</li>
</ul>
</nav>
<!-- second level stitching -->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/stitching')}">

View File

@ -21,7 +21,7 @@
<!-- Hidden Inputs for Dynamic Values -->
<input type="hidden" name="articleName" :value="articleName">
<input type="hidden" name="poQuantity" :value="purchaseOrderQuantity">
<input type="hidden" name="poQuantity" :value="purchaseOrderQuantityRequired">
<input type="hidden" name="purchaseOrderTitle" :value="purchaseOrderCode">
<input type="hidden" name="purchaseOrderId" :value="purchaseOrderID">
@ -57,7 +57,7 @@
<div class="col-sm-3 form-group">
<label>PO Quantity</label>
<!-- Dynamically show PO quantity -->
<span class="form-control">{{ purchaseOrderQuantity || jobCard.poQuantity }}</span>
<span class="form-control">{{ purchaseOrderQuantityRequired || jobCard.poQuantity }}</span>
</div>
<div class="col-sm-3 form-group" th:with="title=*{locationTitle},id=*{locationSiteId}">

View File

@ -157,7 +157,7 @@
th:data-title="${detail.get('articleName')} + ' (' + ${date} + ')'"
th:data-dates="${date}"
th:data-stitching="${phases.get('Stitching')?.intValue() ?: 0}"
th:data-finishing="${phases.get('finishing')?.intValue() ?: 0}"
th:data-finishing="${phases.get('finishingValueForBarChart')?.intValue() ?: 0}"
th:data-packaging="${phases.get('packaging')?.intValue() ?: 0}"
th:data-totalProduction="${detail.get('Shift Target')}"
th:data-fontSize="35">
@ -193,8 +193,6 @@
</div>
</div>
</div>
</main>
</div>
<script>

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:uind="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Job Card</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:700|Open+Sans:400,400i&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" th:href="@{|${baseUrl}/css/print.css|}">
</head>
<body>
<div class="container-fluid">
<table>
<tr>
<td width="400">
<img width="200" th:src="@{|${baseUrl}/img/utopia-industries.png|}" alt="Utopia Industries">
</td>
<td width="400">
<table class="bordered">
<tr class="tr-header">
<td colspan="2" th:text="'PO Online Status'"></td>
</tr>
<tbody>
<tr>
<td style="width: 40%; border: 1px solid black;"><i>PO Code</i></td>
<td style="width: 60%; border: 1px solid black;">
<a class="text-reset" target="_blank" th:text="${poDetail.getPoNumber()}"></a>
</td>
</tr>
<tr>
<td style="width: 40%; border: 1px solid black;"><i>Article Name</i></td>
<td style="width: 60%; border: 1px solid black;">
<a class="text-reset" target="_blank" th:text="${poDetail.getArticleTitle()}"></a>
</td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Quantity</i></td>
<td style="border: 1px solid black;"><span th:text="${poDetail.getPoQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Required Excess+</i></td>
<td style="border: 1px solid black;"><span th:text="${poDetail.getPoRequiredQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Status</i></td>
<td style="border: 1px solid black;">
<span th:if="*{poDetail.isPoStatus}" th:text="'CLOSE'"></span>
<span th:if="*{!poDetail.isPoStatus}" th:text="'OPEN'"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<table class="bordered" style="width: 100%; margin-top: 10px; border-collapse: collapse; ">
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 10px;">PO Details</h5>
<thead >
<tr class="tr-header">
<td>Cutting</td>
<td>Cutting Balance</td>
<td>Stitching</td>
<td>Stitching Balance</td>
<td>End Line QC</td>
<td>End Line QC Balance</td>
<td>Finishing Items</td>
<td>Finishing Items Balance</td>
<td>A Grade Items</td>
<td>Reject Items In Store</td>
</tr>
</thead>
<tbody>
<tr >
<td style="border: 1px solid black;" th:text="${poDetail.getTotalCutting()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingCutting()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalStitching()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingStitching()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalEndLineQC()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingEndLineQC()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalFinishing()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingFinishing()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalAGradeItem()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalBGradeItem()}"></td>
</tr>
</tbody>
</table>
<table class="bordered" style="width: 50%; margin-top: 20px;" th:if="${showStore}">
<tr class="tr-header">
<td colspan="2" th:text="'Reject Items In Store'"></td>
</tr>
<tbody>
<tr th:each="heading : ${store.keySet()}"
th:if="${store != null and not store.isEmpty()}">
<td style="width: 40%; border: 1px solid black;"><i th:text="${heading}"></i></td>
<td style="width: 60%; border: 1px solid black;">
<a class="text-reset" target="_blank" th:text="${store.get(heading)}"></a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

View File

@ -8,6 +8,7 @@
<main class="row page-main">
<aside class="col-sm-2" th:replace="/reporting/po-job-card-report-sidebar :: sidebar"></aside>
<div class="col-sm">
<h3>PO Job Cards</h3>
<table class="table">
<tbody>
<tr th:if="${allJobCard != null}" th:each="jobCard : ${allJobCard.keySet()}"

View File

@ -8,7 +8,7 @@
<form th:action="@{${#strings.replace(#httpServletRequest.requestURI, #request.getContextPath(), '')}}">
<h5 class="mb-4">Refine Your Search</h5>
<div class="form-group">
<label>PO Name</label>
<label>PO Code</label>
<input type="text" class="form-control" name="poName" th:value="${param['poName'] ?: poName}">
</div>
<input type="submit" class="btn btn-secondary btn-block" value="Search">

View File

@ -1,22 +1,21 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
xmlns:ctp="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('PO Report')"></head>
<body>
<div class="container-fluid">
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<aside class="col-sm-2" th:replace="/reporting/po-report-sidebar :: sidebar"></aside>
<div class="col-lg-10 col-sm-10">
<h3>PO's Report</h3>
<table class="table table-striped font-sm" data-order="[[ 0, &quot;asc&quot; ]]">
<h3>All PO's </h3>
<table th:if="${ #lists != null && #lists.size(allPOs) != 0 }" class="table table-striped font-sm" data-account-tables data-order="[[ 0, &quot;asc&quot; ]]">
<thead>
<tr>
<th>PO Number</th>
<th>PO Article</th>
<th>PO Quantity</th>
<th>Req+ Excess</th>
<th>Cutting</th>
<th>Cutting Balance</th>
<th>Stitching</th>
@ -26,16 +25,20 @@
<th>Finishing Items</th>
<th>Finishing Items Balance</th>
<th>A Grade Items</th>
<th>B Grade Items</th>
<th>C Grade Items</th>
<th>Reject Items In Store</th>
<th></th>
<th>PO Status</th>
<th>Generate PDF</th>
</tr>
</thead>
<tbody>
<!-- Dummy data for testing purposes -->
<tr th:each="poDetail : ${allPOs}">
<td><a class="text-reset" th:href="@{'/reporting/po-report-view/' + ${poDetail.poNumber}}" th:text="${poDetail.poNumber}"></a></td>
<td><a class="text-reset" th:href="@{'/po-status/po-report-view/' + ${poDetail.poId}}"
th:text="${poDetail.poNumber}"></a></td>
<td th:text="${poDetail.articleTitle}"></td>
<td th:text="${poDetail.poQuantity}"></td>
<td th:text="${poDetail.poRequiredQuantity}"></td>
<td th:text="${poDetail.totalCutting}"></td>
<td th:text="${poDetail.remainingCutting}"></td>
<td th:text="${poDetail.totalStitching}"></td>
@ -46,18 +49,161 @@
<td th:text="${poDetail.remainingFinishing}"></td>
<td th:text="${poDetail.totalAGradeItem}"></td>
<td th:text="${poDetail.totalBGradeItem}"></td>
<td th:text="${poDetail.totalCGradeItem}"></td>
<td data-show-dropdown-transactions
th:data-po-id="${poDetail.poId}"
title="Store-Items">
<span data-dropdown-icon-transactions class="bi bi-caret-right-fill"></span>
</td>
<td>
<span class="badge font-sm badge-danger" th:if="*{poDetail.poStatus}" th:text="'CLOSE'"></span>
<span class="badge font-sm badge-ACTIVE" th:if="*{!poDetail.poStatus}" th:text="'OPEN'"></span>
</td>
<td>
<form th:action="@{/po-status/generate-po-pdf}" method="get" target="_blank"
th:id="'form-' + ${poDetail.poId}">
<!-- Hidden inputs for all fields -->
<input type="hidden" name="poId" th:value="${poDetail.poId}"/>
<input type="hidden" name="poNumber" th:value="${poDetail.poNumber}"/>
<input type="hidden" name="articleTitle" th:value="${poDetail.articleTitle}"/>
<input type="hidden" name="poQuantity" th:value="${poDetail.poQuantity}"/>
<input type="hidden" name="poRequiredQuantity" th:value="${poDetail.poRequiredQuantity}"/>
<input type="hidden" name="totalCutting" th:value="${poDetail.totalCutting}"/>
<input type="hidden" name="remainingCutting" th:value="${poDetail.remainingCutting}"/>
<input type="hidden" name="totalStitching" th:value="${poDetail.totalStitching}"/>
<input type="hidden" name="remainingStitching" th:value="${poDetail.remainingStitching}"/>
<input type="hidden" name="totalEndLineQC" th:value="${poDetail.totalEndLineQC}"/>
<input type="hidden" name="remainingEndLineQC" th:value="${poDetail.remainingEndLineQC}"/>
<input type="hidden" name="totalFinishing" th:value="${poDetail.totalFinishing}"/>
<input type="hidden" name="remainingFinishing" th:value="${poDetail.remainingFinishing}"/>
<input type="hidden" name="totalAGradeItem" th:value="${poDetail.totalAGradeItem}"/>
<input type="hidden" name="totalBGradeItem" th:value="${poDetail.totalBGradeItem}"/>
<input type="hidden" name="poStatus" th:value="${poDetail.poStatus}"/>
<a href="javascript:void(0);"
th:onclick="'showPdfOptions(' + ${poDetail.poId} + ')'"
class="btn btn-sm btn-secondary"
title="Generate PDF">
<i class="bi bi-filetype-pdf"></i>
</a>
</form>
</td>
</tr>
</tbody>
</table>
<h4 th:if="${#lists.size(allPOs) == 0 }">No PO found.</h4>
</div>
<div class="modal fade" id="pdfOptionsModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Select PDF Options</h5>
</div>
<div class="modal-body">
<!-- <div class="form-check">-->
<!-- <input class="form-check-input" type="checkbox" id="includeJobCard" name="includeJobCard" value="true" checked>-->
<!-- <label class="form-check-label" for="includeJobCard">-->
<!-- Include Job Card Details-->
<!-- </label>-->
<!-- </div>-->
<div class="form-check">
<input class="form-check-input" type="checkbox" id="includeStoreDetails" name="includeStoreDetails" value="true" checked>
<label class="form-check-label" for="includeStoreDetails">
Include Store Details
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitPdfForm()">Generate PDF</button>
</div>
</div>
</div>
</div>
<!-- <h4 th:if="${#lists.size(cards) == 0 }">No cards found.</h4>-->
</main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script th:src="@{/js/summary.js}"></script>
<script>
// PDF Generation Functions
let currentPoIdForPdf = null;
function showPdfOptions(poId) {
currentPoIdForPdf = poId;
$('#pdfOptionsModal').modal('show');
}
function submitPdfForm() {
if (!currentPoIdForPdf) return;
const form = document.getElementById('form-' + currentPoIdForPdf);
// Remove existing options if they exist
const existingJobCard = form.querySelector('input[name="includeJobCard"]');
const existingStoreDetails = form.querySelector('input[name="includeStoreDetails"]');
if (existingJobCard) form.removeChild(existingJobCard);
if (existingStoreDetails) form.removeChild(existingStoreDetails);
// Add params to show store details in pdf
const includeStoreDetails = document.createElement('input');
includeStoreDetails.type = 'hidden';
includeStoreDetails.name = 'includeStoreDetails';
includeStoreDetails.value = document.getElementById('includeStoreDetails').checked;
form.appendChild(includeStoreDetails);
form.submit();
$('#pdfOptionsModal').modal('hide');
}
// DataTable and Dropdown Initialization
$(document).ready(function() {
const $body = $('body');
// Initialize DataTables for each individual table
$('table[data-account-table]').each(function () {
$(this).DataTable({
paging: false,
pageLength: 100,
searching: false,
lengthChange: false,
processing: false,
dom: `
<'row'<'col-sm-3'B><'col-sm-4'f>>
<'row'<'col-sm-6't>>
<'row'<'col-sm-3'i><'col-sm-4'p>>`,
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
});
// Dropdown transactions toggle
$body.on('click', '[data-show-dropdown-transactions]', function (e) {
e.preventDefault();
const $this = $(this);
const $tr = $this.closest('tr');
const $table = $this.closest('table');
const dataTable = $table.DataTable();
const $row = dataTable.row($tr);
const $spanDropdown = $this.find('[data-dropdown-icon-transactions]');
const poId = $this.data('po-id');
$spanDropdown.toggleClass('bi-caret-right-fill bi-caret-down-fill');
if ($row.child.isShown()) {
$row.child.hide();
} else {
$row.child(`<span class="spinner-border text-center spinner-border-md" role="status"></span>`).show();
$.ajax({
url: `/ctp/purchase-order/store-items/${poId}`,
success: function (data) {
$row.child(data).show();
}
});
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-8">
<table th:if="${#lists != null && #lists.size(storeItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-account-tables >
<thead>
<tr>
<th th:each="heading : ${storeItems.keySet()}" th:text="${heading}"></th>
</tr>
</thead>
<tbody>
<tr>
<td th:each="heading : ${storeItems.keySet()}" th:text="${storeItems.get(heading)}"></td>
</tr>
</tbody>
</table>
<h5 th:if="${#lists.size(storeItems.keySet()) == 0}" class="mt-2">No Inventory Transactions found.</h5>
</div>
</div>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script th:inline="javascript">
// Initialize DataTables for each individual table
$('table[data-account-tables]').each(function () {
const $table = $(this);
// Prevent reinitializing if already done
if (!$.fn.DataTable.isDataTable($table)) {
$table.DataTable({
paging: false,
searching: false,
lengthChange: false,
info: false,
dom: 't',
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
}
});
</script>
</body>
</html>

View File

@ -21,6 +21,7 @@
v-on:finished-item-select="onItemSelect">
</search-item>
</div>
<input type="hidden" name="rejectReason" v-model="reason">
<div class="col-sm-3 form-group">
<label>Store Account</label>
<select class="form-control" name="accountId" th:field="*{accountId}" required>
@ -40,8 +41,16 @@
></finish-item-table>
</div>
<div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Item Selected</div>
<button class="btn btn-primary" type="submit" v-bind:disabled="hasDuplicates()">Submit</button>
<a th:href="@{/packaging/receive-inventory}" class="btn btn-light">Cancel</a>
<button class="btn btn-primary mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Cut To Pack')">Cut To Pack
</button>
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Knitting')">Knitting
</button>
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Dying')">Dying
</button>
<a th:href="@{/store/receive-inventory}" class="btn btn-light">Cancel</a>
</form>
<script th:inline="javascript">
window.ctp.accounts = [[${accounts}]];