Search in sources :

Example 11 with VendorBean

use of de.clearit.kindergarten.domain.VendorBean in project kindergarten by clear-group-ausbildung.

the class ExportDataService method getPayoffDataInternal.

/**
 * Returns a {@link PayoffDataInternal} for the Internal Payoff.
 *
 * @return {@link PayoffDataInternal} to create the internal payoff.
 */
public static PayoffDataInternal getPayoffDataInternal() {
    PurchaseService purchaseService = PurchaseService.getInstance();
    List<PurchaseBean> purchaseAllList = purchaseService.getAll();
    Double totalSum = purchaseService.getItemSumByPurchases(purchaseAllList).doubleValue();
    Double totalProfit = purchaseService.getKindergartenProfitByPurchases(purchaseAllList).doubleValue();
    Double totalPayout = purchaseService.getVendorPayoutByPurchases(purchaseAllList).doubleValue();
    Integer totalItemCount = purchaseService.getItemCountByPurchases(purchaseAllList);
    ArrayList<PayoffDataInternalVendor> payoffDataInternalVendorList = new ArrayList<>();
    List<VendorBean> vendorList = VendorService.getInstance().getAll();
    for (VendorBean vendor : vendorList) {
        List<PurchaseBean> vendorPurchaseList = new ArrayList<>();
        for (VendorNumberBean vendorNumberBean : vendor.getVendorNumbers()) {
            int vendorNumber = vendorNumberBean.getVendorNumber();
            List<PurchaseBean> purchaseList = purchaseAllList.stream().filter(purchase -> purchase.getVendorNumber().equals(vendorNumber)).collect(Collectors.toList());
            vendorPurchaseList.addAll(purchaseList);
        }
        payoffDataInternalVendorList.add(new PayoffDataInternalVendor(vendor, purchaseService.getVendorPayoutByPurchases(vendorPurchaseList).doubleValue()));
    }
    return new PayoffDataInternal(totalSum, totalProfit, totalPayout, totalItemCount, payoffDataInternalVendorList);
}
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) PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) PayoffDataInternalVendor(de.clearit.kindergarten.domain.export.entity.PayoffDataInternalVendor) ArrayList(java.util.ArrayList) PayoffDataInternal(de.clearit.kindergarten.domain.export.entity.PayoffDataInternal) PurchaseService(de.clearit.kindergarten.domain.PurchaseService) VendorBean(de.clearit.kindergarten.domain.VendorBean) VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean)

Aggregations

VendorBean (de.clearit.kindergarten.domain.VendorBean)11 ArrayList (java.util.ArrayList)4 PurchaseBean (de.clearit.kindergarten.domain.PurchaseBean)3 VendorNumberBean (de.clearit.kindergarten.domain.VendorNumberBean)3 Collectors (java.util.stream.Collectors)3 Action (com.jgoodies.application.Action)2 PurchaseService (de.clearit.kindergarten.domain.PurchaseService)2 VendorService (de.clearit.kindergarten.domain.VendorService)2 PayoffDataInternal (de.clearit.kindergarten.domain.export.entity.PayoffDataInternal)2 PayoffDataInternalVendor (de.clearit.kindergarten.domain.export.entity.PayoffDataInternalVendor)2 PayoffDataReceipt (de.clearit.kindergarten.domain.export.entity.PayoffDataReceipt)2 PayoffSoldItemsData (de.clearit.kindergarten.domain.export.entity.PayoffSoldItemsData)2 Format (java.text.Format)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Application (com.jgoodies.application.Application)1 ResourceMap (com.jgoodies.application.ResourceMap)1 Completion (com.jgoodies.completion.text.Completion)1 DefaultCompletion (com.jgoodies.completion.text.DefaultCompletion)1 CommitCallback (com.jgoodies.desktop.CommitCallback)1