use of de.clearit.kindergarten.domain.VendorBean 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);
}
use of de.clearit.kindergarten.domain.VendorBean 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);
}
use of de.clearit.kindergarten.domain.VendorBean in project kindergarten by clear-group-ausbildung.
the class PurchaseHomeModel method alleVerkaeufer.
private VendorBean alleVerkaeufer() {
VendorBean alleVerkaeufer = new VendorBean();
alleVerkaeufer.setLastName("Alle");
return alleVerkaeufer;
}
use of de.clearit.kindergarten.domain.VendorBean in project kindergarten by clear-group-ausbildung.
the class VendorHomeModel method newItem.
@Action
public void newItem(ActionEvent e) {
String title = RESOURCES.getString("newVendor.title");
editItem(title, new VendorBean(), true);
}
use of de.clearit.kindergarten.domain.VendorBean in project kindergarten by clear-group-ausbildung.
the class VendorListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
VendorBean vendor = (VendorBean) value;
setText(formatVendor(vendor));
return component;
}
Aggregations