Package org.kapott.hbci.structures

Examples of org.kapott.hbci.structures.Saldo


    // Jetzt speichern wir noch den neuen Saldo.
    Info[] info = result.getEntries();
    if (info == null || info.length == 0)
      throw new ApplicationException(i18n.tr("Keine Saldo-Informationen erhalten"));
   
    Saldo saldo = info[0].ready;
    Value avail = info[0].available;
    konto.setSaldo(saldo.value.getDoubleValue());
    if (avail != null)
      konto.setSaldoAvailable(avail.getDoubleValue());
View Full Code Here


        info.konto.iban=result.getProperty(header+".KTV.iban");
        info.konto.type=result.getProperty(header+".kontobez");
        info.konto.curr=result.getProperty(header+".curr");
        getMainPassport().fillAccountInfo(info.konto);
       
        info.ready=new Saldo();
        String cd=result.getProperty(header+".booked.CreditDebit");
        String st=(cd.equals("D")?"-":"") + result.getProperty(header+".booked.BTG.value","0");
        info.ready.value=new Value(
            st,
            result.getProperty(header+".booked.BTG.curr"));
        info.ready.timestamp=HBCIUtils.strings2DateTimeISO(result.getProperty(header+".booked.date"),
                                                           result.getProperty(header+".booked.time"));
       
        cd=result.getProperty(header+".pending.CreditDebit");
        if (cd!=null) {
            st=(cd.equals("D")?"-":"") + result.getProperty(header+".pending.BTG.value", "0");
            info.unready=new Saldo();
            info.unready.value=new Value(
                st,
                result.getProperty(header+".pending.BTG.curr"));
            info.unready.timestamp=HBCIUtils.strings2DateTimeISO(result.getProperty(header+".pending.date"),
                                                                  result.getProperty(header+".pending.time"));
View Full Code Here

    umsatz.setPrimanota(u.primanota);

    double kurs = 1.95583;

    //BUGZILLA 67 http://www.willuhn.de/bugzilla/show_bug.cgi?id=67
    Saldo s = u.saldo;
    if (s != null)
    {
      Value v = s.value;
      if (v != null)
      {
View Full Code Here

                }
                if (st_start!=null) {
                    // Tag 60 (Anfangssaldo) gibt es in MT942 nicht,
                    // darum wird btag.start nur in MT940 gef�llt

                    btag.start=new Saldo();
                    btag.starttype=starttype;

                    String cd=st_start.substring(0,1);

                    try {
                        btag.start.timestamp=dateFormat.parse(st_start.substring(1,7));
                    } catch (Exception e) {
                        btag.start.timestamp=null;
                    }

                    // hier aus dem CD-Indikator und dem absoluten Saldo-Betrag
                    // einen String f�r den Saldo-Betrag zusamennbauen
                    btag.start.value=new Value(
                        (cd.equals("D")?"-":"")+st_start.substring(10).replace(',','.'),
                        st_start.substring(7,10));
                }

                // looping to get all "umsaetze"

                // TODO: beim MT942 (btag.start==null) m�sste als Initialwert
                // fuer den Saldo hier eigentlich der Abschluss-Saldo aus den
                // gebuchten Ums�tzen verwendet werden (den habe ich an dieser
                // Stelle aber nicht so ohne weiteres)
                long saldo = (btag.start!=null)?btag.start.value.getLongValue():0;
                int  ums_counter=0;

                while (true) {
                    String st_ums=Swift.getTagValue(st_tag,"61",ums_counter);
                    if (st_ums==null)
                        break;

                    GVRKUms.UmsLine line=new GVRKUms.UmsLine();

                    // extract valuta
                    line.valuta=dateFormat.parse(st_ums.substring(0,6));

                    // extract bdate
                    int next=0;
                    if (st_ums.charAt(6)>'9') {
                        // [2012-01-27 - Patch von Frank/Pecunia]
                        // beim :61er Tag ist das Buchungsdatum optional. Wenn es nicht gesetzt ist, muss das Buchungsdatum des
                        // Umsatzes z.B. aus :60F kommen
                        if (btag.start !=  null && btag.start.timestamp != null) line.bdate = btag.start.timestamp;
                        else line.bdate=line.valuta;

                        next=6;

                    } else {
                        line.bdate=dateFormat.parse(st_ums.substring(0,2)+
                            st_ums.substring(6,10));

                        // wenn bdate und valuta um mehr als einen monat voneinander
                        // abweichen, dann ist das jahr des bdate falsch (1.1.2005 vs. 31.12.2004)
                        // korrektur des bdate-jahres in die richtige richtung notwendig
                        // FE: ein Monat reicht nicht, es sollte schon ein halbes Jahr sein - es gab verschiedene Probleme mit Umsaetzen im falschen Jahr!!
                        // http://www.onlinebanking-forum.de/phpBB2/viewtopic.php?p=75348
                        if (Math.abs(line.bdate.getTime()-line.valuta.getTime())>180L*24*3600*1000) {
                            int diff;

                            if (line.bdate.before(line.valuta)) {
                                diff=+1;
                            } else {
                                diff=-1;
                            }
                            Calendar cal=Calendar.getInstance();
                            cal.setTime(line.bdate);
                            cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+diff);
                            line.bdate=cal.getTime();
                        }

                        next=10;
                    }

                    // extract credit/debit
                    String cd;
                    if (st_ums.charAt(next)=='C' || st_ums.charAt(next)=='D') {
                        line.isStorno=false;
                        cd=st_ums.substring(next,next+1);
                        next++;
                    } else {
                        line.isStorno=true;
                        cd=st_ums.substring(next+1,next+2);
                        next+=2;
                    }

                    // skip part of currency
                    char currpart=st_ums.charAt(next);
                    if (currpart>'9')
                        next++;

                    line.value=new Value();

                    // TODO: bei einem MT942 wird die waehrung hier automatisch auf EUR
                    // gesetzt, weil die auto-erkennung (anhand des anfangssaldos) hier nicht
                    // funktioniert, weil es im MT942 keinen anfangssaldo gibt
                    line.value.setCurr((btag.start!=null)?btag.start.value.getCurr():"EUR");

                    // extract value and skip code
                    int    npos=st_ums.indexOf("N",next);
                    // welcher Code (C/D) zeigt einen negativen Buchungsbetrag
                    // an? Bei einer "normalen" Buchung ist das D(ebit). Bei
                    // einer Storno-Buchung ist der Betrag allerdings negativ,
                    // wenn eine ehemalige Gutschrift (Credit) storniert wird,
                    // in dem Fall w�re als "C" der Indikator f�r den negativen
                    // Buchungsbetrag
                    String negValueIndikator=line.isStorno?"C":"D";
                    line.value.setValue(
                        HBCIUtilsInternal.string2Long(
                            (cd.equals(negValueIndikator)?"-":"") + st_ums.substring(next,npos).replace(',','.'),
                            100));
                    next=npos+4;

                    // update saldo
                    saldo+=line.value.getLongValue();

                    line.saldo=new Saldo();
                    line.saldo.timestamp=line.bdate;
                    // TODO: bei einem MT942 wird die waehrung hier automatisch auf EUR
                    // gesetzt, weil die auto-erkennung (anhand des anfangssaldos) hier nicht
                    // funktioniert, weil es im MT942 keinen anfangssaldo gibt
                    line.saldo.value=new Value(saldo, (btag.start!=null)?btag.start.value.getCurr():"EUR");

                    // extract customerref
                    npos=st_ums.indexOf("//",next);
                    if (npos==-1)
                        npos=st_ums.indexOf("\r\n",next);
                    if (npos==-1)
                        npos=st_ums.length();
                    line.customerref=st_ums.substring(next,npos);
                    next=npos;

                    // check for instref
                    if (next<st_ums.length() && st_ums.substring(next,next+2).equals("//")) {
                        // extract instref
                        next+=2;
                        npos=st_ums.indexOf("\r\n",next);
                        if (npos==-1)
                            npos=st_ums.length();
                        line.instref=st_ums.substring(next,npos);
                        next=npos+2;
                    }
                    if (line.instref==null)
                        line.instref="";

                    // check for additional information
                    if (next<st_ums.length() && st_ums.charAt(next)=='\r') {
                        next+=2;

                        // extract orig Value
                        pos=st_ums.indexOf("/OCMT/",next);
                        if (pos!=-1) {
                            int slashpos=st_ums.indexOf("/",pos+9);
                            if (slashpos==-1)
                                slashpos=st_ums.length();

                            try
                            {
                              line.orig_value=new Value(
                                  st_ums.substring(pos+9,slashpos).replace(',','.'),
                                  st_ums.substring(pos+6,pos+9));
                            }
                            catch (NumberFormatException nfe)
                            {
                              // Der Betrag darf fehlen. Tolerieren wir
                            }
                        }

                        // extract charge Value
                        pos=st_ums.indexOf("/CHGS/",next);
                        if (pos!=-1) {
                            int slashpos=st_ums.indexOf("/",pos+9);
                            if (slashpos==-1)
                                slashpos=st_ums.length();

                            try
                            {
                              line.charge_value=new Value(
                                  st_ums.substring(pos+9,slashpos).replace(',','.'),
                                  st_ums.substring(pos+6,pos+9));
                            }
                            catch (NumberFormatException nfe)
                            {
                              // Der Betrag darf fehlen. Tolerieren wir
                            }
                        }
                    }

                    String st_multi=Swift.getTagValue(st_tag,"86",ums_counter);
                    if (st_multi!=null) {
                        line.gvcode=st_multi.substring(0,3);
                        st_multi=Swift.packMulti(st_multi.substring(3));

                        if (!line.gvcode.equals("999")) {
                            line.isSepa = line.gvcode.startsWith("1");
                            line.text=Swift.getMultiTagValue(st_multi,"00");
                            line.primanota=Swift.getMultiTagValue(st_multi,"10");
                            for (int i=0;i<10;i++) {
                                line.addUsage(Swift.getMultiTagValue(st_multi,Integer.toString(20+i)));
                            }

                            Konto acc=new Konto();
                            acc.blz=Swift.getMultiTagValue(st_multi,"30");
                            acc.number=Swift.getMultiTagValue(st_multi,"31");
                           
                            // fuer den Fall, dass in der BLZ sowas hier drin steht: "GENODEF1S06 SVWZ+ ja"
                            // Siehe http://www.onlinebanking-forum.de/phpBB2/viewtopic.php?t=16182
                            if (acc.blz != null)
                            {
                                int space = acc.blz.indexOf(" ");
                                if (space != -1)
                                {
                                    HBCIUtils.log("blz/bic \"" + acc.blz + "\" contains invalid chars, trimming after first space", HBCIUtils.LOG_DEBUG);
                                    acc.blz = acc.blz.substring(0,space);
                                }
                            }

                            if (line.isSepa)
                            {
                              acc.bic = acc.blz;
                              acc.iban = acc.number;
                            }

                            acc.name=Swift.getMultiTagValue(st_multi,"32");
                            acc.name2=Swift.getMultiTagValue(st_multi,"33");
                            if (acc.blz!=null ||
                                    acc.number!=null ||
                                    acc.name!=null ||
                                    acc.name2!=null) {

                                if (acc.blz==null)
                                    acc.blz="";
                                if (acc.number==null)
                                    acc.number="";
                                if (acc.name==null)
                                    acc.name="";
                                line.other=acc;
                            }

                            line.addkey=Swift.getMultiTagValue(st_multi,"34");
                            for (int i=0;i<4;i++) {
                                line.addUsage(Swift.getMultiTagValue(st_multi,Integer.toString(60+i)));
                            }
                        } else {
                            line.additional=st_multi;
                        }
                    }

                    btag.addLine(line);
                    ums_counter++;
                }

                // extract "schlusssaldo"

                String st_end=Swift.getTagValue(st_tag,"62F",0);
                char   endtype='F';
                btag.endtype='F';
                if (st_end==null) {
                    st_end=Swift.getTagValue(st_tag,"62M",0);
                    endtype='M';
                }
                if (st_end!=null) {
                    // Tag 62 (Schlusssaldo) gibt es in MT942 nicht,
                    // darum wird btag.end nur in MT940 gef�llt

                    btag.end=new Saldo();
                    btag.endtype=endtype;

                    String cd=st_end.substring(0,1);

                    try {
View Full Code Here

TOP

Related Classes of org.kapott.hbci.structures.Saldo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.