nheron

Untitled

Oct 6th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. package org.training.leisure.swimmingpool;
  2.  
  3. import java.lang.Number;
  4. import org.chtijbug.example.swimmingpool.CalculatedAttribute;
  5. import org.chtijbug.example.swimmingpool.Price;
  6. import org.chtijbug.example.swimmingpool.Person;
  7. import org.chtijbug.example.swimmingpool.Period;
  8. import org.chtijbug.example.swimmingpool.SeasonType;
  9. import org.chtijbug.example.swimmingpool.PriceType;
  10.  
  11. rule "BirthdayReduction"
  12. dialect "mvel"
  13. ruleflow-group "reduction"
  14. when
  15. ccat : CalculatedAttribute( key == "IsPersonBirthday" , stringValue == "true" )
  16. pper : Person( calculatedAttributeList contains ccat , sprice : standardPrice > 0.0B )
  17. not (pprice : Price( description == "BirthdayReduction" ) and Person( priceList contains pprice , this == pper ))
  18. Period( seasonType == SeasonType.day )
  19. then
  20. Price nprice = new Price();
  21. nprice.setDescription( "BirthdayReduction" );
  22. nprice.setAmount( sprice.divide(new BigDecimal("10.0"),BigDecimal.ROUND_HALF_UP) );
  23. nprice.setPriceType( PriceType.promotion );
  24. insert( nprice );
  25. pper.addPrice( nprice );
  26. modify( pper ) {
  27. setPriceList( pper.getPriceList() )
  28. }
  29. end
Advertisement
Add Comment
Please, Sign In to add comment