Subversion Repositories SmartDukaan

Rev

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

Rev 36578 Rev 36958
Line 17... Line 17...
17
import com.spice.profitmandi.dao.entity.dtr.*;
17
import com.spice.profitmandi.dao.entity.dtr.*;
18
import com.spice.profitmandi.dao.entity.fofo.*;
18
import com.spice.profitmandi.dao.entity.fofo.*;
19
import com.spice.profitmandi.dao.entity.inventory.State;
19
import com.spice.profitmandi.dao.entity.inventory.State;
20
import com.spice.profitmandi.dao.entity.transaction.Order;
20
import com.spice.profitmandi.dao.entity.transaction.Order;
21
import com.spice.profitmandi.dao.entity.user.Address;
21
import com.spice.profitmandi.dao.entity.user.Address;
22
import com.spice.profitmandi.dao.entity.user.Counter;
-
 
23
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
-
 
24
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
22
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
25
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
23
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
26
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
24
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
27
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
25
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
28
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
26
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
Line 825... Line 823...
825
                itemIdQuantityMap.merge(fofoOrderItem.getItemId(), fofoOrderItem.getQuantity(), Integer::sum);
823
                itemIdQuantityMap.merge(fofoOrderItem.getItemId(), fofoOrderItem.getQuantity(), Integer::sum);
826
            }
824
            }
827
            smartCartService.minusOpeningStockBatch(itemIdQuantityMap, fofoOrder.getFofoId());
825
            smartCartService.minusOpeningStockBatch(itemIdQuantityMap, fofoOrder.getFofoId());
828
        }
826
        }
829
 
827
 
830
        // Flagship credit conversion: invoice on the flagship loan links directly to purchase orders,
828
        // Flagship credit conversion: convert exactly the sold devices by their IMEI/serial. Each flagship
831
        // so we only need the sold catalog IDs — no need to re-check model_flagship table
829
        // limit row covers one IMEI, so the sold serials map straight to the rows to convert — same-model
-
 
830
        // siblings (this invoice or other billing tranches) keep their interest-free window.
832
        try {
831
        try {
833
            if (sdCreditService.hasActiveFlagshipLimits(fofoId)) {
832
            if (sdCreditService.hasActiveFlagshipLimits(fofoId) && !serialNumbers.isEmpty()) {
834
                Set<Integer> soldCatalogIds = fofoItems.stream()
-
 
835
                        .map(foi -> itemMap.get(foi.getItemId()))
-
 
836
                        .filter(Objects::nonNull)
-
 
837
                        .map(Item::getCatalogItemId)
-
 
838
                        .collect(Collectors.toSet());
-
 
839
 
-
 
840
                if (!soldCatalogIds.isEmpty()) {
-
 
841
                    sdCreditService.convertFlagshipOnSale(fofoId, soldCatalogIds);
833
                sdCreditService.convertFlagshipOnSale(fofoId, serialNumbers);
842
                }
-
 
843
            }
834
            }
844
        } catch (Exception e) {
835
        } catch (Exception e) {
845
            LOGGER.error("Failed to convert flagship credits on sale for fofoId {}", fofoId, e);
836
            LOGGER.error("Failed to convert flagship credits on sale for fofoId {}", fofoId, e);
846
        }
837
        }
847
 
838