Exemplo n.º 1
0
void AB_ImExporterAccountInfo_FillFromAccount(AB_IMEXPORTER_ACCOUNTINFO *iea,
					      const AB_ACCOUNT *a) {
  const char *s;
  AB_ACCOUNT_TYPE at;

  assert(iea);
  assert(a);

  s=AB_Account_GetBankCode(a);
  AB_ImExporterAccountInfo_SetBankCode(iea, s);

  s=AB_Account_GetBankName(a);
  AB_ImExporterAccountInfo_SetBankName(iea, s);

  s=AB_Account_GetAccountNumber(a);
  AB_ImExporterAccountInfo_SetAccountNumber(iea, s);

  s=AB_Account_GetAccountName(a);
  AB_ImExporterAccountInfo_SetAccountName(iea, s);

  s=AB_Account_GetIBAN(a);
  AB_ImExporterAccountInfo_SetIban(iea, s);

  s=AB_Account_GetBIC(a);
  AB_ImExporterAccountInfo_SetBic(iea, s);

  s=AB_Account_GetCurrency(a);
  AB_ImExporterAccountInfo_SetCurrency(iea, s);

  s=AB_Account_GetOwnerName(a);
  AB_ImExporterAccountInfo_SetOwner(iea, s);

  at=AB_Account_GetAccountType(a);
  AB_ImExporterAccountInfo_SetType(iea, at);
}
Exemplo n.º 2
0
AB_IMEXPORTER_ACCOUNTINFO *AB_ImExporterContext__GetAccountInfoForTransaction(AB_IMEXPORTER_CONTEXT *iec,
									      const AB_TRANSACTION *t){
  AB_IMEXPORTER_ACCOUNTINFO *iea;
  const char *tIban;
  const char *tBankCode;
  const char *tAccountNumber;

  tBankCode=AB_Transaction_GetLocalBankCode(t);
  if (!tBankCode) tBankCode="";
  tAccountNumber=AB_Transaction_GetLocalAccountNumber(t);
  if (!tAccountNumber) tAccountNumber="";
  tIban=AB_Transaction_GetLocalIban(t);
  if (!tIban) tIban="";

  iea=AB_ImExporterAccountInfo_List_First(iec->accountInfoList);
  while(iea) {
    const char *sBankCode;
    const char *sAccountNumber;
    const char *sIban;

    sBankCode=AB_ImExporterAccountInfo_GetBankCode(iea);
    if (!sBankCode) sBankCode="";
    sAccountNumber=AB_ImExporterAccountInfo_GetAccountNumber(iea);
    if (!sAccountNumber) sAccountNumber="";
    sIban=AB_ImExporterAccountInfo_GetIban(iea);
    if (!sIban) sIban="";

    if (strcasecmp(sIban, tIban)==0)
      return iea;

    if ((strcasecmp(sBankCode, tBankCode)==0) &&
	(strcasecmp(sAccountNumber, tAccountNumber)==0))
      return iea;

    iea=AB_ImExporterAccountInfo_List_Next(iea);
  }

  /* not found, append it */
  iea=AB_ImExporterAccountInfo_new();
  if (tIban && *tIban)
    AB_ImExporterAccountInfo_SetIban(iea, tIban);
  if (tBankCode && *tBankCode)
    AB_ImExporterAccountInfo_SetBankCode(iea, tBankCode);
  if (tAccountNumber && *tAccountNumber)
    AB_ImExporterAccountInfo_SetAccountNumber(iea, tAccountNumber);
  AB_ImExporterAccountInfo_List_Add(iea, iec->accountInfoList);

  return iea;
}
Exemplo n.º 3
0
AB_IMEXPORTER_ACCOUNTINFO*
AB_ImExporterContext_GetAccountInfo(AB_IMEXPORTER_CONTEXT *iec,
                                    const char *bankCode,
                                    const char *accountNumber){
  AB_IMEXPORTER_ACCOUNTINFO *iea;

  if (!bankCode)
    bankCode="";
  if (!accountNumber)
    accountNumber="";

  assert(iec);
  iea=AB_ImExporterContext_FindAccountInfo(iec, bankCode, accountNumber);
  if (!iea) {
    /* not found, append it */
    iea=AB_ImExporterAccountInfo_new();
    AB_ImExporterAccountInfo_SetBankCode(iea, bankCode);
    AB_ImExporterAccountInfo_SetAccountNumber(iea, accountNumber);
    AB_ImExporterAccountInfo_List_Add(iea, iec->accountInfoList);
  }
  return iea;
}
Exemplo n.º 4
0
AB_IMEXPORTER_ACCOUNTINFO *AB_ImExporterYN__ReadAccountInfo(AB_IMEXPORTER *ie,
                                                            AB_IMEXPORTER_CONTEXT *ctx,
                                                            GWEN_XMLNODE *doc)
{
  GWEN_XMLNODE *n;
  AB_IMEXPORTER_ACCOUNTINFO *ai;

  ai=AB_ImExporterAccountInfo_new();

  n=GWEN_XMLNode_FindFirstTag(doc, "SG2", 0, 0);
  if (n)
    n=GWEN_XMLNode_FindFirstTag(n, "FII", 0, 0);
  if (n) {
    GWEN_XMLNODE *nn;
    const char *s;

    nn=GWEN_XMLNode_FindFirstTag(n, "C078", 0, 0);
    if (nn) {
      GWEN_XMLNODE *nnn;

      /* account number */
      s=GWEN_XMLNode_GetCharValue(nn, "D_3194", 0);
      if (s)
        AB_ImExporterAccountInfo_SetAccountNumber(ai, s);
      /* IBAN */
      s=GWEN_XMLNode_GetCharValue(nn, "D_3192", 0);
      if (s)
        AB_ImExporterAccountInfo_SetIban(ai, s);
      /* currency */
      nnn=GWEN_XMLNode_FindFirstTag(nn, "D_6345", 0, 0);
      if (nnn) {
        s=GWEN_XMLNode_GetProperty(nnn, "value", 0);
        if (s)
          AB_ImExporterAccountInfo_SetCurrency(ai, s);
      }
    }

    /* account number */
    s=GWEN_XMLNode_GetCharValue(n, "PF:D_5388", 0);
    if (s)
      AB_ImExporterAccountInfo_SetAccountName(ai, s);
  }

  /* owner name */
  n=GWEN_XMLNode_GetNodeByXPath(doc, "SG3[1]/NAD",
                                GWEN_PATH_FLAGS_NAMEMUSTEXIST);
  if (n) {
    GWEN_XMLNODE *nn;

    nn=GWEN_XMLNode_FindFirstTag(n, "D_3035", 0, 0);
    if (nn) {
      const char *s;

      s=GWEN_XMLNode_GetProperty(nn, "Value", 0);
      if (s && strcasecmp(s, "HQ")==0) {
        nn=GWEN_XMLNode_FindFirstTag(n, "C058", 0, 0);
        if (nn) {
          s=GWEN_XMLNode_GetCharValue(nn, "D_3124", 0);
          if (s && *s) {
            GWEN_BUFFER *xbuf;

            xbuf=GWEN_Buffer_new(0, 256, 0, 1);
            AB_ImExporter_Iso8859_1ToUtf8(s, strlen(s), xbuf);
            AB_ImExporterAccountInfo_SetOwner(ai, GWEN_Buffer_GetStart(xbuf));
            GWEN_Buffer_free(xbuf);
          }
        }
      }
    }
  }

  return ai;
}
Exemplo n.º 5
0
int AH_ImExporterOFX_AccountCallback_cb(const struct OfxAccountData data,
                                        void *user_data)
{
  AH_IMEXPORTER_OFX *ieh;
  AB_IMEXPORTER_ACCOUNTINFO *ai;

  DBG_INFO(AQBANKING_LOGDOMAIN,
           "Account callback");
  ieh=(AH_IMEXPORTER_OFX *)user_data;

  ai=AB_ImExporterAccountInfo_new();
#ifdef HAVE_OFX_WITH_CONNECT
  if (data.account_number_valid) {
    AB_ImExporterAccountInfo_SetAccountNumber(ai, data.account_number);
    if (*(data.account_name))
      AB_ImExporterAccountInfo_SetAccountName(ai, data.account_name);
  }
  else if (data.account_id_valid)
    AB_ImExporterAccountInfo_SetAccountNumber(ai, data.account_id);
  else
    AB_ImExporterAccountInfo_SetAccountNumber(ai, "----");

  if (data.bank_id_valid)
    AB_ImExporterAccountInfo_SetBankCode(ai, data.bank_id);
#else
  if (data.account_id_valid) {
    AB_ImExporterAccountInfo_SetAccountNumber(ai, data.account_id);
    if (*(data.account_name))
      AB_ImExporterAccountInfo_SetAccountName(ai, data.account_name);
  }
  else {
    AB_ImExporterAccountInfo_SetAccountNumber(ai, "----");
  }
#endif

  if (data.account_type_valid) {
    AB_ACCOUNT_TYPE at;

    switch (data.account_type) {
    case OFX_CHECKING:
      at=AB_AccountType_Checking;
      break;
    case OFX_SAVINGS:
      at=AB_AccountType_Savings;
      break;
    case OFX_MONEYMRKT:
      at=AB_AccountType_Investment;
      break;
    case OFX_CREDITLINE:
      at=AB_AccountType_Bank;
      break;
    case OFX_CMA:
      at=AB_AccountType_Cash;
      break;
    case OFX_CREDITCARD:
      at=AB_AccountType_CreditCard;
      break;
    case OFX_INVESTMENT:
      at=AB_AccountType_Investment;
      break;
    default:
      at=AB_AccountType_Bank;
      break;
    }
    AB_ImExporterAccountInfo_SetType(ai, at);
  }
  else {
    AB_ImExporterAccountInfo_SetType(ai, AB_AccountType_Bank);
  }

  AB_ImExporterContext_AddAccountInfo(ieh->context, ai);
  ieh->lastAccountInfo=ai;
  return 0;
}