Search in sources :

Example 1 with PayoffSoldItemsData

use of de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData in project kindergarten by clear-group-ausbildung.

the class ExportDataService method getPayoffDataForVendor.

/**
 * Returns a {@link PayoffDataReceipt} for the given {@link VendorBean}.
 *
 * @param pVendor
 *          the vendor to get the data for.
 *
 * @return {@link PayoffDataReceipt} to create the receipts.
 */
public static PayoffDataReceipt getPayoffDataForVendor(VendorBean pVendor) {
    PurchaseService purchaseService = PurchaseService.getInstance();
    List<PurchaseBean> purchaseAllList = purchaseService.getAll();
    ArrayList<Integer> vendorNumberList = new ArrayList<>();
    ArrayList<PayoffSoldItemsData> payoffSoldItemsDataList = new ArrayList<>();
    List<PurchaseBean> totalPurchaseList = new ArrayList<>();
    for (VendorNumberBean vendorNumberBean : pVendor.getVendorNumbers()) {
        int vendorNumber = vendorNumberBean.getVendorNumber();
        vendorNumberList.add(vendorNumber);
        List<PurchaseBean> purchaseList = purchaseAllList.stream().filter(purchase -> purchase.getVendorNumber().equals(vendorNumber)).collect(Collectors.toList());
        totalPurchaseList.addAll(purchaseList);
        HashMap<Integer, Double> soldItemNumbersPricesMap = new HashMap<>();
        for (PurchaseBean purchase : purchaseList) {
            soldItemNumbersPricesMap.put(purchase.getItemNumber(), purchase.getItemPrice().doubleValue());
        }
        payoffSoldItemsDataList.add(new PayoffSoldItemsData(vendorNumber, soldItemNumbersPricesMap, purchaseService.getItemSumByPurchases(purchaseList).doubleValue()));
    }
    return new PayoffDataReceipt(vendorNumberList, pVendor.getFirstName(), pVendor.getLastName(), purchaseService.getItemSumByPurchases(totalPurchaseList).doubleValue(), purchaseService.getKindergartenProfitByPurchases(totalPurchaseList).doubleValue(), purchaseService.getVendorPayoutByPurchases(totalPurchaseList).doubleValue(), purchaseService.getItemCountByPurchases(totalPurchaseList), payoffSoldItemsDataList);
}
Also used : PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) PurchaseService(de.clearit.kindergarten.domain.PurchaseService) HashMap(java.util.HashMap) PayoffDataReceipt(de.clearit.kindergarten.domain.export.entity.PayoffDataReceipt) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) VendorBean(de.clearit.kindergarten.domain.VendorBean) PayoffDataInternal(de.clearit.kindergarten.domain.export.entity.PayoffDataInternal) List(java.util.List) PayoffDataInternalVendor(de.clearit.kindergarten.domain.export.entity.PayoffDataInternalVendor) VendorService(de.clearit.kindergarten.domain.VendorService) VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean) PayoffSoldItemsData(de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData) HashMap(java.util.HashMap) PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) ArrayList(java.util.ArrayList) PurchaseService(de.clearit.kindergarten.domain.PurchaseService) PayoffSoldItemsData(de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData) VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean) PayoffDataReceipt(de.clearit.kindergarten.domain.export.entity.PayoffDataReceipt)

Example 2 with PayoffSoldItemsData

use of de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData in project kindergarten by clear-group-ausbildung.

the class ExportReceipt method createSoldItemList.

private void createSoldItemList(List<PayoffSoldItemsData> pPayoffSoldItemDataList, Cell pStartCell) {
    int rowCountGlobal = pStartCell.getRowIndex();
    int columnIndex = pStartCell.getColumnIndex();
    for (PayoffSoldItemsData payoffSoldItemData : pPayoffSoldItemDataList) {
        rowCountGlobal = createPlaceholderRow(rowCountGlobal, columnIndex, "");
        rowCountGlobal = createVendorHeaderRow(rowCountGlobal, columnIndex, payoffSoldItemData.getVendorNumber());
        if (payoffSoldItemData.getSoldItemNumbersPricesMap().isEmpty()) {
            rowCountGlobal = createPlaceholderRow(rowCountGlobal, columnIndex, "Keine Artikel verkauft");
        } else {
            rowCountGlobal = createItemRows(rowCountGlobal, columnIndex, payoffSoldItemData);
        }
    }
}
Also used : PayoffSoldItemsData(de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData)

Aggregations

PayoffSoldItemsData (de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData)2 PurchaseBean (de.clearit.kindergarten.domain.PurchaseBean)1 PurchaseService (de.clearit.kindergarten.domain.PurchaseService)1 VendorBean (de.clearit.kindergarten.domain.VendorBean)1 VendorNumberBean (de.clearit.kindergarten.domain.VendorNumberBean)1 VendorService (de.clearit.kindergarten.domain.VendorService)1 PayoffDataInternal (de.clearit.kindergarten.domain.export.entity.PayoffDataInternal)1 PayoffDataInternalVendor (de.clearit.kindergarten.domain.export.entity.PayoffDataInternalVendor)1 PayoffDataReceipt (de.clearit.kindergarten.domain.export.entity.PayoffDataReceipt)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1