Search in sources :

Example 1 with VendorNumberBean

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

the class VendorHomeModel method editItem.

private void editItem(String title, final VendorBean vendor, final boolean newItem) {
    VendorEditorModel model = new VendorEditorModel(vendor, value -> {
        if (value == CommandValue.OK) {
            int indexOfNewOrUpdatedElement = 0;
            if (newItem) {
                SERVICE.create(vendor);
                postChangeHandler.onPostCreate();
                for (int i = 0; i < getSelectionInList().getList().size(); i++) {
                    VendorBean element = getSelectionInList().getList().get(i);
                    for (VendorNumberBean elementNumberBean : element.getVendorNumbers()) {
                        for (VendorNumberBean callbackNumberBean : vendor.getVendorNumbers()) {
                            if (callbackNumberBean.getVendorNumber() == elementNumberBean.getVendorNumber()) {
                                indexOfNewOrUpdatedElement = i;
                                break;
                            }
                        }
                        break;
                    }
                }
            } else {
                SERVICE.update(vendor);
                postChangeHandler.onPostUpdate();
                for (int i = 0; i < getSelectionInList().getList().size(); i++) {
                    VendorBean element = getSelectionInList().getList().get(i);
                    if (element.getId().equals(vendor.getId())) {
                        indexOfNewOrUpdatedElement = i;
                        break;
                    }
                }
            }
            getSelectionInList().setSelectionIndex(indexOfNewOrUpdatedElement);
        }
    });
    VendorAppliance.getInstance().openVendorEditor(title, model);
}
Also used : VendorBean(de.clearit.kindergarten.domain.VendorBean) VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean)

Example 2 with VendorNumberBean

use of de.clearit.kindergarten.domain.VendorNumberBean 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 3 with VendorNumberBean

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

the class VendorEditorModel method removeVendorNumber.

@Action(enabled = false)
public void removeVendorNumber(ActionEvent e) {
    VendorNumberBean vendorNumberBean = getSelection();
    // Remove from model list
    getSelectionInList().getList().remove(vendorNumberBean);
}
Also used : VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean) Action(com.jgoodies.application.Action)

Example 4 with VendorNumberBean

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

the class VendorEditorModel method addVendorNumber.

// Actions ****************************************************************
@Action
public void addVendorNumber(ActionEvent e) {
    TextComponentUtils.commitImmediately();
    if (getVendorNumberFieldModel().getValue() != null) {
        // Check for vendor numbers in current model
        if (vendorNumberAlreadyExists(Integer.valueOf((String) getVendorNumberFieldModel().getValue()))) {
            JOptionPane.showMessageDialog(new JFrame(), "Verk\u00e4ufernummer bereits vorhanden!");
            // Reset input field
            getVendorNumberFieldModel().setValue(null);
            return;
        }
        if (!VendorNumberService.getInstance().isVendorNumberExisting(Integer.valueOf((String) getVendorNumberFieldModel().getValue()))) {
            VendorNumberBean vendorNumberBean = new VendorNumberBean();
            // Read Vendor number from input field
            vendorNumberBean.setVendorNumber(Integer.valueOf((String) getVendorNumberFieldModel().getValue()));
            // Add to model list
            getSelectionInList().getList().add(vendorNumberBean);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "Verk\u00e4ufernummer bereits vorhanden!");
        }
        Collections.sort(getBean().getVendorNumbers(), Comparator.<VendorNumberBean>comparingInt(VendorNumberBean::getVendorNumber));
        Collections.sort(getSelectionInList().getList(), Comparator.<VendorNumberBean>comparingInt(VendorNumberBean::getVendorNumber));
        // Reset input field
        getVendorNumberFieldModel().setValue(null);
    }
}
Also used : JFrame(javax.swing.JFrame) VendorNumberBean(de.clearit.kindergarten.domain.VendorNumberBean) Action(com.jgoodies.application.Action)

Example 5 with VendorNumberBean

use of de.clearit.kindergarten.domain.VendorNumberBean 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

VendorNumberBean (de.clearit.kindergarten.domain.VendorNumberBean)5 VendorBean (de.clearit.kindergarten.domain.VendorBean)3 Action (com.jgoodies.application.Action)2 PurchaseBean (de.clearit.kindergarten.domain.PurchaseBean)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 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 JFrame (javax.swing.JFrame)1