Esempio n. 1
0
 def _GetEndBalance(self, account_id, datefrom, dateto ):
     sql = "SELECT SUM(ji.amount) \
              FROM acc_journal j \
              JOIN acc_journal_items d ON j.id = ji.acc_journal_id \
             WHERE ji.account_id = %d" % account_id
     if dateto:
         sql += " AND   j.transaction_date < '%s' " % dateto
     
     sqldebit  = sql + " AND ji.debit =  True "
     sqlcredit = sql + " AND ji.debit =  False"
     
     return (fetch.getSum(sqlcredit)-fetch.getSum(sqldebit))
Esempio n. 2
0
 def _sumCredit(self,account_id, datefrom, dateto ):
     if datefrom and dateto:
         sql = "SELECT SUM(ji.amount) \
                  FROM acc_journal j \
                  JOIN journal_items ji ON j.id = ji.journal_id \
                 WHERE j.transaction_date BETWEEN '%s' AND '%s' \
                   AND ji.account_id = %d \
                   AND ji.debit = False  " % (datefrom, dateto, account_id)
         
     elif datefrom and not dateto:
         sql = "SELECT SUM(ji.amount) \
                  FROM acc_journal  j \
                  JOIN acc_journal_items  ji ON j.id = ji.journal_id \
                 WHERE j.transaction_date > '%s' \
                   AND ji.account_id = %d \
                   AND ji.debit = False  " % (datefrom, account_id)
         
     elif not datefrom and dateto:
         sql = "SELECT SUM(ji.amount) \
                  FROM acc_journal j \
                  JOIN acc_journal_items ji ON j.id = ji.journal_id \
                 WHERE j.transaction_date < AND '%s' \
                   AND ji.account_id = %d \
                   AND ji.debit = False  " % (dateto, account_id)
     else:
         sql = "SELECT SUM(ji.amount) \
                  FROM acc_journal  j \
                  JOIN acc_journal_items ji ON j.id = ji.journal_id \
                 WHERE ji.account_id = %d \
                   AND ji.debit = False  " % (account_id,)
     return fetch.getSum(sql)
Esempio n. 3
0
    def _getStartBalance(self, account_id, datefrom, dateto ):
        #rint'_getStartBalance' , account_id, datefrom, dateto
        sql = "SELECT SUM(ji.amount) \
                 FROM acc_journal  j \
                 JOIN acc_journal_items  d ON j.id = ji.journal_id \
                WHERE ji.account_id = %d" % account_id
        
        if datefrom:
            sql += "  AND j.transaction_date < '%s' " % datefrom

        sqldebit  = sql + " AND ji.debit =  True "
        sqlcredit = sql + " AND ji.debit =  False"
        
        debit  = fetch.getSum(sqldebit)
        credit = fetch.getSum(sqlcredit)
        #rint'debit', debit,'     credit',credit
        return (credit-debit)