use of de.clearit.kindergarten.domain.export.entity.PayoffDataReceipt 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.export.entity.PayoffDataReceipt in project kindergarten by clear-group-ausbildung.
the class ExportReceipt method createReceipt.
/**
* Creates an receipt in excel for the given vendor.
*
* @param pVendor
* {@link VendorBean}
*/
public void createReceipt(VendorBean pVendor) {
try {
wb = new XSSFWorkbook(new FileInputStream("./abrechnung_template.xlsx"));
sheet = wb.getSheetAt(0);
createStyles();
PayoffDataReceipt payoffData = ExportDataService.getPayoffDataForVendor(pVendor);
fillInPlaceholders(payoffData);
FileOutputStream fileOut = new FileOutputStream(getDateiname(payoffData));
wb.write(fileOut);
fileOut.close();
wb.close();
} catch (FileNotFoundException e) {
LOGGER.debug("Error - Excel Template not found");
LOGGER.error(e.getMessage());
} catch (IOException e) {
LOGGER.debug("Error Exel Export");
LOGGER.error(e.getMessage());
}
}
Aggregations