예제 #1
0
 private double getChildSum(Lehen lehen) {
   double childSum = 0;
   for (Lehen child : getData().getLehen().getChildList(lehen.getId()).values()) {
     double tax = child.getSales() * ConfigBasis.SALES_TAX / 100.0;
     childSum = childSum + tax;
     child.getBank().depositKonto(child.getSales(), "ME", 0);
     child.getBank().withdrawKonto(tax, "ME", 0);
     child.setSales(0.0);
   }
   return childSum;
 }
예제 #2
0
  private void doFeudalTax() {
    for (Settlement settle : getData().getSettlements().values()) {
      double umsatzTax = settle.getSales();
      double settlerTax = settle.getTaxSum();
      settle.setSales(0.0);
      settle.setTaxSum(0.0);
      Owner owner = getData().getOwners().getOwner(settle.getOwnerId());
      int lehenId = settle.getTributId();
      int kingdomId = 0;
      Lehen tributLehen = getData().getLehen().getLehen(lehenId);
      if (tributLehen != null) {
        kingdomId = tributLehen.getKingdomId();
        tributLehen.depositSales((umsatzTax));
      } else if (owner != null) {
        kingdomId = owner.getKingdomId();
        owner.depositSales((umsatzTax));
      }
      Lehen kingLehen = getData().getLehen().getKingdomRoot(kingdomId);
      if (kingLehen != null) {
        kingLehen.depositSales((settlerTax));
      }
    }

    for (Kingdom kingdom : getData().getKingdoms().values()) {
      if (kingdom.getId() > 0) {
        Lehen root = getData().getLehen().getKingdomRoot(kingdom.getId());
        if (root != null) {
          for (Lehen lehen : getData().getLehen().getChildList(root.getId()).values()) {
            for (Lehen child : getData().getLehen().getChildList(lehen.getId()).values()) {
              double childsum = getChildSum(child);
              child.depositSales(childsum);
            }
            double sum = getChildSum(lehen);
            lehen.depositSales(sum);
          }
          double rootSum = getChildSum(root);
          root.getBank().depositKonto(rootSum, "TAX", 0);
          root.getBank().depositKonto(root.getSales(), "TAX", 0);
          root.setSales(0.0);
        }
      }
    }
  }