I Have the code that work well but it too long and look too bad. I try to format it, but it all set data, so I don't know how to make it better
Here is the code:
private static BrandProfitAndLoss getAllRateComparisonRecords(BrandProfitAndLoss brandProfitAndLoss , BrandProfitAndLoss brandProfitAndLossComp){
BrandProfitAndLoss result = new BrandProfitAndLoss();
result.setDate(brandProfitAndLossComp.getDate());
result.setOrder_item_num_comp(compareData(brandProfitAndLoss.getOrder_item_num(), brandProfitAndLossComp.getOrder_item_num()));
result.setOrder_count_comp(compareData(brandProfitAndLoss.getOrder_count(), brandProfitAndLossComp.getOrder_count()));
result.setOrder_price_comp(compareData(brandProfitAndLoss.getOrder_price(), brandProfitAndLossComp.getOrder_price()));
result.setOrder_amount_comp(compareData(brandProfitAndLoss.getOrder_amount(), brandProfitAndLossComp.getOrder_amount()));
result.setOrder_gross_comp(compareData(brandProfitAndLoss.getOrder_gross(), brandProfitAndLossComp.getOrder_gross()));
result.setOrder_wholesale_price_comp(compareData(brandProfitAndLoss.getOrder_wholesale_price(), brandProfitAndLossComp.getOrder_wholesale_price()));
result.setDelivery_count_comp(compareData(brandProfitAndLoss.getDelivery_count(), brandProfitAndLossComp.getDelivery_count()));
result.setDelivery_price_comp(compareData(brandProfitAndLoss.getDelivery_price(), brandProfitAndLossComp.getDelivery_price()));
result.setDelivery_item_num_comp(compareData(brandProfitAndLoss.getDelivery_item_num(), brandProfitAndLossComp.getDelivery_item_num()));
result.setDelivery_gross_comp(compareData(brandProfitAndLoss.getDelivery_gross(), brandProfitAndLossComp.getDelivery_gross()));
result.setDelivery_amount_comp(compareData(brandProfitAndLoss.getDelivery_amount(), brandProfitAndLossComp.getDelivery_amount()));
result.setApproval_rate_comp(compareData(brandProfitAndLoss.getApproval_rate(), brandProfitAndLossComp.getApproval_rate()));
result.setShipping_comp(compareData(brandProfitAndLoss.getShipping(), brandProfitAndLossComp.getShipping()));
result.setAll_delivery_price_comp(compareData(brandProfitAndLoss.getAll_delivery_price_comp(), brandProfitAndLossComp.getAll_delivery_price_comp()));
result.setReturn_sales_comp(compareData(brandProfitAndLoss.getReturn_sales(), brandProfitAndLossComp.getReturn_sales()));
result.setPoint_discount_comp(compareData(brandProfitAndLoss.getPoint_discount(), brandProfitAndLossComp.getPoint_discount()));
result.setPoint_allowance_comp(compareData(brandProfitAndLoss.getPoint_allowance(), brandProfitAndLossComp.getPoint_allowance()));
result.setSales_amount_comp(compareData(brandProfitAndLoss.getSales_amount(), brandProfitAndLossComp.getSales_amount()));
result.setPurchasing_cost_comp(compareData(brandProfitAndLoss.getPurchasing_cost(), brandProfitAndLossComp.getPurchasing_cost()));
result.setProfit_comp(compareData(brandProfitAndLoss.getProfit(), brandProfitAndLossComp.getProfit()));
result.setProfit_gross_comp(compareData(brandProfitAndLoss.getProfit_gross(), brandProfitAndLossComp.getProfit_gross()));
result.setYfc_cost_comp(compareData(brandProfitAndLoss.getYfc_cost(), brandProfitAndLossComp.getYfc_cost()));
result.setCommission_cost_comp(compareData(brandProfitAndLoss.getCommission_cost(), brandProfitAndLossComp.getCommission_cost()));
result.setServer_cost_comp(compareData(brandProfitAndLoss.getServer_cost(), brandProfitAndLossComp.getServer_cost()));
result.setBrand_cost_comp(compareData(brandProfitAndLoss.getBrand_cost(), brandProfitAndLossComp.getBrand_cost()));
result.setBrand_pol_comp(compareData(brandProfitAndLoss.getBrand_pol(), brandProfitAndLossComp.getBrand_pol()));
result.setCompLastYearRate_comp(compareData(brandProfitAndLoss.getCompLastYearRate(), brandProfitAndLossComp.getCompLastYearRate()));
return result;
}
And here is the compareDate method
private static float compareData(float thisYear, float lastYear) {
float result = 0;
if(thisYear == 0 || lastYear == 0){
return result;
}
return (thisYear / lastYear) - 1;
}
Thank for any help