def checkZpk(self, zpk):
     balance = zpk.getCurrentBalance()
     calculatedCredit = (self.sumCredit(zpk.getId()).add(
         BigDecimal(balance.getStartCredit()))).setScale(
             2, RoundingMode.HALF_UP)
     calculatedDebit = (self.sumDebit(zpk.getId()).add(
         BigDecimal(balance.getStartDebit()))).setScale(
             2, RoundingMode.HALF_UP)
     expectedCredit = BigDecimal(balance.getCredit()).setScale(
         2, RoundingMode.HALF_UP)
     expectedDebit = BigDecimal(balance.getDebit()).setScale(
         2, RoundingMode.HALF_UP)
     if not expectedCredit.equals(calculatedCredit):
         self._logger.info("On zpk %d found wrongly calculated credit:" %
                           zpk.getId())
         self._logger.info("calculated: %s" %
                           calculatedCredit.toPlainString())
         self._logger.info("expected: %s" % expectedCredit.toPlainString())
     if not expectedDebit.equals(calculatedDebit):
         self._logger.info("On zpk %d found wrongly calculated debit:" %
                           zpk.getId())
         self._logger.info("calculated: %s" %
                           calculatedDebit.toPlainString())
         self._logger.info("expected: %s" % expectedDebit.toPlainString())
Esempio n. 2
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')