コード例 #1
0
 def checkIfPayed(self, invoice):
     costs = BigDecimal(0.0)
     payments = BigDecimal(0.0)
     for position in invoice.getPositions():
         if position.getType(
         ) == "INVOICE_COST" and not position.isCanceled():
             costs = costs.add(position.getValue())
         elif position.getType(
         ) == "INVOICE_PAYMENT" and not position.isCanceled():
             payments = payments.add(position.getValue())
     if costs.equals(payments):
         self._logger.info("Costs equals payments, marking as payed...")
         invoice.putAttribute("PAYED", 'true')
     else:
         self._logger.info(
             "Costs(%f) doesn't equal payments(%f), marking as unpayed..." %
             (costs.floatValue(), payments.floatValue()))
         invoice.putAttribute("PAYED", 'false')
コード例 #2
0
 def recalculateShares(self, community):
     totalArea = BigDecimal(0)
     percent = BigDecimal(100)
     for possession in community.getPossessions():
         totalArea = totalArea.add(possession.getArea())
     self._logger.info("Total area of community %s calculated as %f" %
                       (community.getName(), totalArea.floatValue()))
     for possession in community.getPossessions():
         tmpPossessionArea = possession.getArea().divide(
             totalArea, 6, RoundingMode.HALF_UP)
         possessionArea = tmpPossessionArea.multiply(percent)
         self._logger.info(
             "Possession area for %d calculated as %f" %
             (possession.getId(), possessionArea.floatValue()))
         possession.setShare(possessionArea)