Search in sources :

Example 1 with PurchaseBean

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

the class PurchaseEditorModel method removeLineItem.

@Action(enabled = false)
public void removeLineItem(final ActionEvent e) {
    final PurchaseBean purchase = getSelection();
    final String mainInstruction = RESOURCES.getString("deleteItem.mainInstruction", "Artikel-Nr: " + purchase.getItemNumber() + ", Verk\u00e4fernummer: " + purchase.getVendorNumber());
    final TaskPane pane = new TaskPane(MessageType.QUESTION, mainInstruction, CommandValue.YES, CommandValue.NO);
    pane.setPreferredWidth(PreferredWidth.MEDIUM);
    pane.showDialog(e, RESOURCES.getString("deleteItem.title"));
    if (pane.getCommitValue() == CommandValue.YES) {
        getSelectionInList().getList().remove(purchase);
        refreshSummary();
    }
}
Also used : PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) TaskPane(com.jgoodies.jsdl.core.pane.TaskPane) Action(com.jgoodies.application.Action)

Example 2 with PurchaseBean

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

the class PurchaseEditorModel method addLineItem.

// Actions ****************************************************************
@Action
public void addLineItem(final ActionEvent e) {
    TextComponentUtils.commitImmediately();
    triggerCommit();
    if (checkBeanContent()) {
        getSelectionInList().getList().add(getBean());
        refreshSummary();
        setBean(new PurchaseBean());
    }
}
Also used : PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) Action(com.jgoodies.application.Action)

Example 3 with PurchaseBean

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

the class PurchaseHomeModel method newItem.

@Action
public void newItem(final ActionEvent e) {
    final String title = RESOURCES.getString("newPurchase.title");
    editItem(e, title, new PurchaseBean(), true);
}
Also used : PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) Action(com.jgoodies.application.Action)

Example 4 with PurchaseBean

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

the class PurchaseHomeModel method filterPurchases.

private void filterPurchases() {
    VendorBean selectedVendor = getVendorList().getSelection();
    List<PurchaseBean> filteredOrAllPurchases = new ArrayList<>();
    if (alleVerkaeufer().equals(selectedVendor)) {
        filteredOrAllPurchases.addAll(SERVICE.getAll());
    } else {
        filteredOrAllPurchases.addAll(SERVICE.getAll().stream().filter(bean -> selectedVendor.getVendorNumbers().stream().map(VendorNumberBean::getVendorNumber).collect(Collectors.toList()).contains(bean.getVendorNumber())).collect(Collectors.toList()));
    }
    getSelectionInList().getList().clear();
    getSelectionInList().getList().addAll(filteredOrAllPurchases);
    refreshSummary();
}
Also used : VendorBean(de.clearit.kindergarten.domain.VendorBean) PurchaseBean(de.clearit.kindergarten.domain.PurchaseBean) ArrayList(java.util.ArrayList)

Example 5 with PurchaseBean

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

Aggregations

PurchaseBean (de.clearit.kindergarten.domain.PurchaseBean)8 Action (com.jgoodies.application.Action)4 VendorBean (de.clearit.kindergarten.domain.VendorBean)3 ArrayList (java.util.ArrayList)3 TaskPane (com.jgoodies.jsdl.core.pane.TaskPane)2 PurchaseService (de.clearit.kindergarten.domain.PurchaseService)2 VendorNumberBean (de.clearit.kindergarten.domain.VendorNumberBean)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 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Application (com.jgoodies.application.Application)1 ResourceMap (com.jgoodies.application.ResourceMap)1 CommitCallback (com.jgoodies.desktop.CommitCallback)1 DesktopFrame (com.jgoodies.desktop.DesktopFrame)1 DesktopManager (com.jgoodies.desktop.DesktopManager)1