예제 #1
0
    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)
예제 #2
0
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