def main(): for i in xrange(20200, 20250): #print unicode(laskutus.get_description(i), 'iso-8859-1').encode('utf8') print laskutus.get_description(i) print "DO NOT USE ANYMORE. Exiting." sys.exit(1) conn = psycopg2.connect(host=settings.psql.host, user=settings.psql.user, password=settings.psql.passwd, database=settings.psql.db) conn.set_client_encoding('UTF8') cur = conn.cursor() try: cur.execute("SELECT id,description FROM entry") res = cur.fetchall() for r in res: (id,desc) = r desc = desc.decode('utf-8') print desc cur.execute("UPDATE entry SET description = %s WHERE id = %s", (desc, id)) except psycopg2.DatabaseError, e: if conn: conn.rollback() print 'Error %s' % e sys.exit(1)
def main(): for i in xrange(20200, 20250): #print unicode(laskutus.get_description(i), 'iso-8859-1').encode('utf8') print laskutus.get_description(i) print "DO NOT USE ANYMORE. Exiting." sys.exit(1) conn = psycopg2.connect(host=settings.psql.host, user=settings.psql.user, password=settings.psql.passwd, database=settings.psql.db) conn.set_client_encoding('UTF8') cur = conn.cursor() try: cur.execute("SELECT id,description FROM entry") res = cur.fetchall() for r in res: (id, desc) = r desc = desc.decode('utf-8') print desc cur.execute("UPDATE entry SET description = %s WHERE id = %s", (desc, id)) except psycopg2.DatabaseError, e: if conn: conn.rollback() print 'Error %s' % e sys.exit(1)
def hoax_init(self): if self.viite.strip(): self.viite = int(self.viite) payment_id = laskutus.get_payment_by_refnumber(self.viite) if payment_id == 0: self.description = "" self.account = settings.accounts.muut_kulut else: self.description = laskutus.get_description(payment_id) self.account = laskutus.get_account(payment_id) if not self.is_verkkomaksut(): laskutus.mark_paid(payment_id, self.summa, self.kirjauspvm)
def get_payments(filename): """ Parsitaan verkkomaksujen kirjanpitoraportista maksut oikeesti """ batches = [] f = open(filename) skipping = True for r in f: # hypätään header-rivin yli if skipping: skipping = False continue try: (rowtype, date, reference, order_id, name, batch_amount, batch_amount_ex_vat, vat, amount, provision, transaction, payment_amount, _) = r.replace('"', '').replace('=', '').split(";") except ValueError: (rowtype, date, reference, order_id, name, batch_amount, batch_amount_ex_vat) = r.rstrip().replace('"', '').replace('=', '').split(";") if rowtype == "TILITYS": (d, m, y) = date.split(".") batch_date = "%d-%02d-%02d" % (int(y),int(m),int(d)) batches.append({ 'reference' : reference, 'date' : batch_date, 'batch' : [] }) elif rowtype == "MAKSU": if tickets.is_ticket(order_id): account = tickets.account(order_id) description = tickets.description(order_id) # print "%d" % (int(amount[:-3])) else: account = laskutus.get_account(order_id) if not account: raise Exception("Could not get account for payment %s" % (order_id)) continue description = laskutus.get_description(order_id) batches[-1]['batch'].append({ 'account' : account, 'amount' : float(payment_amount.replace(",",".")), 'description' : description }) else: raise Exception("ei osunut") continue # for b in batches: # generate_batch_report(b) return batches