Esempio n. 1
0
 def setUpClass(self):
     dbFile = "/tmp/testing_accounts.db"
     if os.path.exists(dbFile):
         os.unlink(dbFile)
     db = Database.instance('sqlite:///%s' % dbFile)
     db.buildTables()
     
     # Create Tenant
     tenant = Tenant(name="zerodine GmbH", esr_account="01-1234-5", esr_reference_prefix="999888")
     tenant.save()
     Current.instance(id=tenant.id)
Esempio n. 2
0
    def saldo(self):
        db = Database.instance()
        sumCredit = db.session.query(func.sum(Journal.amount)).filter(Journal.accountCredit_id==self.id).scalar()
        sumDebit = db.session.query(func.sum(Journal.amount)).filter(Journal.accountDebit_id==self.id).scalar()
        if not sumCredit: sumCredit = 0
        if not sumDebit: sumDebit = 0
        if self.type & 1:
            # odd
            total = sumDebit - sumCredit
        else:
            # even
            total = sumCredit - sumDebit
            
        #print "%s Debit: %f Credit: %f %d %s" % (self.name, sumDebit, sumCredit, self.type, self.type & 1)

        return total
Esempio n. 3
0
 def sum(self):
     db = Database.instance()
     return float(db.session.query(Documentposition, func.sum((Product.price/100*(100-Documentposition.deduction)) * Documentposition.quantity))
         .join(Product)
         .filter(Documentposition.document_id==self.id)
         .all()[0][1])