Advertisement
Guest User

Untitled

a guest
May 24th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1.         //Kolla om det finns rabatt på produkten öht
  2.         if(properties.containsKey(p.getProductNo())) {
  3.            
  4.             //Kontrollera om rabatt gäller för nuvarande datum
  5.             String values = properties.getProperty(p.getProductNo());
  6.             String[] valuesArray = values.split(";");
  7.             String startDateString = valuesArray[3];
  8.             String endDateString = valuesArray[4];
  9.            
  10.            
  11.             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  12.             java.util.Date startDate = sdf.parse(startDateString);
  13.             java.util.Date endDate = sdf.parse(endDateString);
  14.             java.util.Date todayDate = new java.util.Date();
  15.  
  16.             if(startDate.before(todayDate) && todayDate.before(endDate)){
  17.                 String props = properties.get(p.getProductNo()).toString();
  18.                 String[] allaProperties = props.split(";");
  19.  
  20.                 //Rabatt för antal
  21.                 if(allaProperties[0].equals("antal") && quantity >= Integer.parseInt(allaProperties[1])) {
  22.                     double discount = Double.parseDouble(allaProperties[2]);
  23.                     rowSum = rowSum - formatter.roundTwoDecimals(discount);
  24.                 }
  25.                 //Rabatt för belopp
  26.                 else if(allaProperties[0].equals("belopp") && rowSum >= Integer.parseInt(allaProperties[1])) {
  27.                     double discount = rowSum * Double.parseDouble(allaProperties[2]);
  28.                     rowSum = rowSum - formatter.roundTwoDecimals(discount);
  29.                 }
  30.            
  31.             }
  32.            
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement