コード例 #1
0
ファイル: imexporter.c プロジェクト: Zauberstuhl/aqbanking
GWEN_TIME *AB_ImExporter_DateFromString(const char *p, const char *tmpl,
					int inUtc) {
  GWEN_TIME *ti;

  if (strchr(tmpl, 'h')==0) {
    GWEN_BUFFER *dbuf;
    GWEN_BUFFER *tbuf;

    dbuf=GWEN_Buffer_new(0, 32, 0, 1);
    GWEN_Buffer_AppendString(dbuf, p);
    GWEN_Buffer_AppendString(dbuf, "-12:00");

    tbuf=GWEN_Buffer_new(0, 32, 0, 1);
    GWEN_Buffer_AppendString(tbuf, tmpl);
    GWEN_Buffer_AppendString(tbuf, "-hh:mm");

    ti=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf),
			       GWEN_Buffer_GetStart(tbuf));
    GWEN_Buffer_free(tbuf);
    GWEN_Buffer_free(dbuf);
  }
  else {
    if (inUtc)
      ti=GWEN_Time_fromUtcString(p, tmpl);
    else
      ti=GWEN_Time_fromString(p, tmpl);
  }
  return ti;
}
コード例 #2
0
ファイル: egkcard.c プロジェクト: aqbanking/libchipcard
LC_CLIENT_RESULT LC_EgkCard_ReadInsuranceData_5_1_0(GWEN_XMLNODE *n,
						    LC_HI_INSURANCE_DATA *d) {
  const char *s;
  GWEN_XMLNODE *nn;

  n=GWEN_XMLNode_FindFirstTag(n,
			      "Versicherter",
			      NULL, NULL);
  if (n) {
    nn=GWEN_XMLNode_FindFirstTag(n,
				 "Versicherungsschutz",
				 NULL, NULL);
    if (nn) {
      GWEN_XMLNODE *nnn;

      s=GWEN_XMLNode_GetCharValue(nn, "Beginn", NULL);
      if (s) {
	GWEN_TIME *ti=GWEN_Time_fromUtcString(s, "YYYYMMDD");
	LC_HIInsuranceData_SetCoverBegin(d, ti);
	GWEN_Time_free(ti);
      }
      s=GWEN_XMLNode_GetCharValue(nn, "Ende", NULL);
      if (s) {
	GWEN_TIME *ti=GWEN_Time_fromUtcString(s, "YYYYMMDD");
	LC_HIInsuranceData_SetCoverEnd(d, ti);
	GWEN_Time_free(ti);
      }

      nnn=GWEN_XMLNode_FindFirstTag(nn,
				    "Kostentraeger",
				    NULL, NULL);
      if (nnn) {
	s=GWEN_XMLNode_GetCharValue(nnn, "Kostentraegerkennung", NULL);
	LC_HIInsuranceData_SetInstitutionId(d, s);
	s=GWEN_XMLNode_GetCharValue(nnn, "Name", NULL);
	LC_HIInsuranceData_SetInstitutionName(d, s);
      }
    }
    else {
      DBG_INFO(LC_LOGDOMAIN,
	       "XML element \"Versicherungsschutz\" not found");
    }
    nn=GWEN_XMLNode_FindFirstTag(n,
				 "Zusatzinfos",
				 NULL, NULL);
    if (nn)
      nn=GWEN_XMLNode_FindFirstTag(nn,
				   "ZusatzinfosGKV",
				   NULL, NULL);
    if (nn) {
      s=GWEN_XMLNode_GetCharValue(nn, "Rechtskreis", NULL);
      LC_HIInsuranceData_SetGroup(d, s);
      s=GWEN_XMLNode_GetCharValue(nn, "Versichertenart", NULL);
      LC_HIInsuranceData_SetStatus(d, s);
    }
  }

  return LC_Client_ResultOk;
}
コード例 #3
0
ファイル: egkcard.c プロジェクト: aqbanking/libchipcard
LC_CLIENT_RESULT LC_EgkCard_ReadPersonalData_old(GWEN_XMLNODE *n,
						 LC_HI_PERSONAL_DATA *d) {
  const char *s;
  GWEN_XMLNODE *nn;
  
  s=GWEN_XMLNode_GetCharValue(n, "Versicherten_ID", NULL);
  LC_HIPersonalData_SetInsuranceId(d, s);
  
  s=GWEN_XMLNode_GetCharValue(n, "Geburtsdatum", NULL);
  if (s) {
    GWEN_TIME *ti=GWEN_Time_fromUtcString(s, "YYYYMMDD");
    LC_HIPersonalData_SetDateOfBirth(d, ti);
    GWEN_Time_free(ti);
  }
  s=GWEN_XMLNode_GetCharValue(n, "Vorname", NULL);
  LC_HIPersonalData_SetPrename(d, s);
  s=GWEN_XMLNode_GetCharValue(n, "Nachname", NULL);
  LC_HIPersonalData_SetName(d, s);
  s=GWEN_XMLNode_GetCharValue(n, "Sex", "1");
  if (s) {
    if (strcasecmp(s, "1")==0)
      LC_HIPersonalData_SetSex(d, LC_HIPersonalData_SexMale);
    else if (strcasecmp(s, "2")==0)
      LC_HIPersonalData_SetSex(d, LC_HIPersonalData_SexFemale);
    else {
      DBG_WARN(LC_LOGDOMAIN, "Unknown sex \"%s\"", s);
    }
  }
  
  nn=GWEN_XMLNode_FindFirstTag(n,
			       "Anschrift",
			       NULL, NULL);
  if (nn) {
    s=GWEN_XMLNode_GetCharValue(nn, "Postleitzahl", NULL);
    LC_HIPersonalData_SetAddrZipCode(d, s);
    s=GWEN_XMLNode_GetCharValue(nn, "Ort", NULL);
    LC_HIPersonalData_SetAddrCity(d, s);
    s=GWEN_XMLNode_GetCharValue(nn, "Wohnsitzlaendercode", NULL);
    LC_HIPersonalData_SetAddrCountry(d, s);
    nn=GWEN_XMLNode_FindFirstTag(nn,
				 "Adresse",
				 NULL, NULL);
    if (nn) {
      s=GWEN_XMLNode_GetCharValue(nn, "Strasse", NULL);
      LC_HIPersonalData_SetAddrStreet(d, s);
      s=GWEN_XMLNode_GetCharValue(nn, "Hausnummer", NULL);
      LC_HIPersonalData_SetAddrHouseNum(d, s);
    }
  }

  return LC_Client_ResultOk;
}
コード例 #4
0
ファイル: util.c プロジェクト: Zauberstuhl/aqbanking
AB_TRANSACTION *mkSepaTransfer(AB_ACCOUNT *a, GWEN_DB_NODE *db, int expTransferType) {
  AB_BANKING *ab;
  AB_TRANSACTION *t;
  const char *s;
  int i;
  GWEN_TIME *d;

  assert(a);
  assert(db);

  ab=AB_Account_GetBanking(a);
  assert(ab);

  t=AB_Transaction_new();

  AB_Banking_FillGapsInTransaction(ab, a, t);

  s=GWEN_DB_GetCharValue(db, "name", 0, 0);
  if (s && *s)
    AB_Transaction_SetLocalName(t, s);

  /* remote account */
  s=GWEN_DB_GetCharValue(db, "remoteBankId", 0, 0);
  if (s && *s)
    AB_Transaction_SetRemoteBankCode(t, s);
  s=GWEN_DB_GetCharValue(db, "remoteAccountId", 0, 0);
  if (s && *s)
    AB_Transaction_SetRemoteAccountNumber(t, s);

  s=GWEN_DB_GetCharValue(db, "remoteIban", 0, 0);
  if (s && *s)
    AB_Transaction_SetRemoteIban(t, s);
  else {
    DBG_ERROR(0, "No remote IBAN given");
    AB_Transaction_free(t);
    return NULL;
  }

  s=GWEN_DB_GetCharValue(db, "remoteBic", 0, 0);
  if (s && *s)
    AB_Transaction_SetRemoteBic(t, s);
  else if (strncmp(AB_Transaction_GetLocalIban(t),
                   AB_Transaction_GetRemoteIban(t), 2)) {
    DBG_ERROR(0, "Remote BIC id required for international transaction");
    AB_Transaction_free(t);
    return NULL;
  }

  for (i=0; i<10; i++) {
    s=GWEN_DB_GetCharValue(db, "remoteName", i, 0);
    if (!s)
      break;
    if (*s)
      AB_Transaction_AddRemoteName(t, s, 0);
  }
  if (i<1) {
    DBG_ERROR(0, "No remote name given");
    AB_Transaction_free(t);
    return NULL;
  }

  /* transfer data */
  for (i=0; i<20; i++) {
    s=GWEN_DB_GetCharValue(db, "purpose", i, 0);
    if (!s)
      break;
    if (*s)
      AB_Transaction_AddPurpose(t, s, 0);
  }
  if (i<1) {
    DBG_ERROR(0, "No purpose given");
    AB_Transaction_free(t);
    return NULL;
  }

  i=GWEN_DB_GetIntValue(db, "textkey", 0, -1);
  if (i>0)
    AB_Transaction_SetTextKey(t, i);

  s=GWEN_DB_GetCharValue(db, "value", 0, 0);
  if (s && *s) {
    AB_VALUE *v;

    v=AB_Value_fromString(s);
    assert(v);
    if (AB_Value_IsNegative(v) || AB_Value_IsZero(v)) {
      DBG_ERROR(0, "Only positive non-zero amount allowed");
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetValue(t, v);
    AB_Value_free(v);
  }
  else {
    DBG_ERROR(0, "No value given");
    AB_Transaction_free(t);
    return NULL;
  }

  /* dated transfer, SEPA debit notes */
  s=GWEN_DB_GetCharValue(db, "executionDate", 0, 0);
  if (s && *s) {
    GWEN_BUFFER *dbuf;

    dbuf=GWEN_Buffer_new(0, 32, 0, 1);
    GWEN_Buffer_AppendString(dbuf, s);
    GWEN_Buffer_AppendString(dbuf, "-00:00");
    d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf),
                                     "YYYYMMDD-hh:mm");
    GWEN_Buffer_free(dbuf);
    if (d==0) {
      DBG_ERROR(0, "Invalid execution date value \"%s\"", s);
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetDate(t, d);
    GWEN_Time_free(d);
  }

  /* standing orders */
  s=GWEN_DB_GetCharValue(db, "firstExecutionDate", 0, 0);
  if (s && *s) {
    GWEN_BUFFER *dbuf;

    dbuf=GWEN_Buffer_new(0, 32, 0, 1);
    GWEN_Buffer_AppendString(dbuf, s);
    GWEN_Buffer_AppendString(dbuf, "-00:00");
    d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf),
                                     "YYYYMMDD-hh:mm");
    GWEN_Buffer_free(dbuf);
    if (d==0) {
      DBG_ERROR(0, "Invalid first execution date value \"%s\"", s);
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetFirstExecutionDate(t, d);
    GWEN_Time_free(d);
  }

  s=GWEN_DB_GetCharValue(db, "lastExecutionDate", 0, 0);
  if (s && *s) {
    GWEN_BUFFER *dbuf;

    dbuf=GWEN_Buffer_new(0, 32, 0, 1);
    GWEN_Buffer_AppendString(dbuf, s);
    GWEN_Buffer_AppendString(dbuf, "-00:00");
    d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf),
                                     "YYYYMMDD-hh:mm");
    GWEN_Buffer_free(dbuf);
    if (d==0) {
      DBG_ERROR(0, "Invalid last execution date value \"%s\"", s);
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetLastExecutionDate(t, d);
    GWEN_Time_free(d);
  }

  if (expTransferType==AB_Job_TypeSepaCreateStandingOrder ||
      expTransferType==AB_Job_TypeSepaModifyStandingOrder) {
    const char *s;
    AB_TRANSACTION_PERIOD period=AB_Transaction_PeriodUnknown;

    /* only needed for standing orders */
    s=GWEN_DB_GetCharValue(db, "executionPeriod", 0, 0);
    if (s && *s) {
      period=AB_Transaction_Period_fromString(s);
      if (period==AB_Transaction_PeriodUnknown) {
        DBG_ERROR(0, "Invalid execution period value \"%s\"", s);
        AB_Transaction_free(t);
        return NULL;
      }
    }
    else {
      DBG_ERROR(0, "Missing execution period value");
      return NULL;
    }
    AB_Transaction_SetPeriod(t, period);

    i=GWEN_DB_GetIntValue(db, "executionCycle", 0, -1);
    if (i <= 0) {
      DBG_ERROR(0, "Invalid execution cycle value \"%d\"", i);
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetCycle(t, i);

    i=GWEN_DB_GetIntValue(db, "executionDay", 0, -1);
    if (i <= 0 || (period == AB_Transaction_PeriodWeekly && i > 7) ||
        (period == AB_Transaction_PeriodMonthly && i > 30 &&
         (i < 97 || i > 99))) {
      DBG_ERROR(0, "Invalid execution day value \"%d\"", i);
      AB_Transaction_free(t);
      return NULL;
    }
    AB_Transaction_SetExecutionDay(t, i);
  }

  return t;
}