Ejemplo n.º 1
0
int AB_ImExporterYN__ReadAccountStatus(AB_IMEXPORTER *ie,
				       AB_IMEXPORTER_ACCOUNTINFO *ai,
				       GWEN_XMLNODE *doc) {
  GWEN_XMLNODE *n;

  n=GWEN_XMLNode_FindFirstTag(doc, "SG4", 0, 0);
  while(n) {
    GWEN_XMLNODE *nn;

    nn=GWEN_XMLNode_GetNodeByXPath(n, "LIN/PF:D_0805",
				   GWEN_PATH_FLAGS_NAMEMUSTEXIST);
    if (nn) {
      const char *s;

      s=GWEN_XMLNode_GetProperty(nn, "Value", 0);
      if (s && strcasecmp(s, "LEN")==0) {
	GWEN_XMLNODE *nnn;
	GWEN_TIME *ti=0;
        AB_VALUE *val=0;

        /* read time */
	nnn=GWEN_XMLNode_GetNodeByXPath(n, "SG5/DTM",
					GWEN_PATH_FLAGS_NAMEMUSTEXIST);
	if (nnn)
	  ti=AB_ImExporterYN__ReadTime(ie, nnn, 202);

	/* read value */
	nnn=GWEN_XMLNode_GetNodeByXPath(n, "SG5/MOA",
					GWEN_PATH_FLAGS_NAMEMUSTEXIST);
	if (nnn)
	  val=AB_ImExporterYN__ReadValue(ie, nnn, 343);

	if (val) {
	  AB_ACCOUNT_STATUS *ast;
	  AB_BALANCE *bal;

          AB_Value_SetCurrency(val, AB_ImExporterAccountInfo_GetCurrency(ai));
	  ast=AB_AccountStatus_new();
	  bal=AB_Balance_new(val, ti);

	  AB_AccountStatus_SetBookedBalance(ast, bal);
	  AB_Balance_free(bal);

	  AB_ImExporterAccountInfo_AddAccountStatus(ai, ast);
	}
	AB_Value_free(val);
        GWEN_Time_free(ti);
      }
    }

    n=GWEN_XMLNode_FindNextTag(n, "SG4", 0, 0);
  }

  return 0;
}
Ejemplo n.º 2
0
GWEN_DATE *AB_ImExporterYN__ReadDate(AB_IMEXPORTER *ie, GWEN_XMLNODE *node, int value)
{
  GWEN_XMLNODE *n;
  GWEN_DATE *da=NULL;

  n=GWEN_XMLNode_GetNodeByXPath(node, "C507", GWEN_PATH_FLAGS_NAMEMUSTEXIST);
  if (n) {
    GWEN_XMLNODE *nn;
    int v=0;

    nn=GWEN_XMLNode_FindFirstTag(n, "D_2005", 0, 0);
    if (nn)
      v=atoi(GWEN_XMLNode_GetProperty(nn, "Value", "0"));

    if (value==0 || v==value) {
      const char *s;

      s=GWEN_XMLNode_GetCharValue(n, "D_2380", 0);
      if (s)
        da=GWEN_Date_fromStringWithTemplate(s, "YYYYMMDD");
    }
  }

  return da;
}
Ejemplo n.º 3
0
GWEN_TIME *AB_ImExporterYN__ReadTime(AB_IMEXPORTER *ie,
				     GWEN_XMLNODE *node,
				     int value) {
  GWEN_XMLNODE *n;
  GWEN_TIME *ti=0;

  n=GWEN_XMLNode_GetNodeByXPath(node, "C507",
				GWEN_PATH_FLAGS_NAMEMUSTEXIST);
  if (n) {
    GWEN_XMLNODE *nn;
    int v=0;

    nn=GWEN_XMLNode_FindFirstTag(n, "D_2005", 0, 0);
    if (nn)
      v=atoi(GWEN_XMLNode_GetProperty(nn, "Value", "0"));

    if (value==0 || v==value) {
      const char *s;

      s=GWEN_XMLNode_GetCharValue(n, "D_2380", 0);
      if (s)
	ti=AB_ImExporter_DateFromString(s, "YYYYMMDD", 0);
    }
  }

  return ti;
}
Ejemplo n.º 4
0
const char *GWEN_XMLNode_GetCharValueByPath(GWEN_XMLNODE *n,
    const char *name,
    const char *defValue) {
  GWEN_XMLNODE *nn;

  nn=GWEN_XMLNode_GetNodeByXPath(n, name, 0);
  if (nn) {
    GWEN_XMLNODE *dn;

    dn=GWEN_XMLNode_GetFirstData(nn);
    if (dn) {
      if (dn->data)
        return dn->data;
    }
  }

  return defValue;
}
Ejemplo n.º 5
0
int AB_ImExporterYN__ReadTransactions(AB_IMEXPORTER *ie,
                                      AB_IMEXPORTER_ACCOUNTINFO *ai,
                                      GWEN_XMLNODE *doc)
{
  GWEN_XMLNODE *n;

  n=GWEN_XMLNode_FindFirstTag(doc, "SG4", 0, 0);
  while (n) {
    GWEN_XMLNODE *nn;

    nn=GWEN_XMLNode_GetNodeByXPath(n, "LIN/PF:D_0805",
                                   GWEN_PATH_FLAGS_NAMEMUSTEXIST);
    if (nn) {
      const char *s;

      s=GWEN_XMLNode_GetProperty(nn, "Value", 0);
      if (s &&
          (strcasecmp(s, "LNE")==0 ||
           strcasecmp(s, "LNS")==0)
         ) {
        nn = GWEN_XMLNode_FindFirstTag(n, "SG6", 0, 0);
        while (nn) {
          AB_TRANSACTION *t;
          const char *s;

          t=AB_ImExporterYN__ReadLNE_LNS(ie, ai, nn);
          s=AB_ImExporterAccountInfo_GetAccountNumber(ai);
          AB_Transaction_SetLocalAccountNumber(t, s);
          s=AB_ImExporterAccountInfo_GetIban(ai);
          AB_Transaction_SetLocalIban(t, s);
          AB_ImExporterAccountInfo_AddTransaction(ai, t);

          nn=GWEN_XMLNode_FindNextTag(nn, "SG6", 0, 0);
        }
      }
    }

    n=GWEN_XMLNode_FindNextTag(n, "SG4", 0, 0);
  }

  return 0;
}
Ejemplo n.º 6
0
int GWEN_XMLNode_SetCharValueByPath(GWEN_XMLNODE *n, uint32_t flags,
                                    const char *name,
                                    const char *value) {
  GWEN_XMLNODE *nn;

  nn=GWEN_XMLNode_GetNodeByXPath(n, name, 0);
  if (nn) {
    GWEN_XMLNODE *nnn;

    /* clear current entries */
    if (flags & GWEN_XML_PATH_FLAGS_OVERWRITE_VALUES)
      GWEN_XMLNode_List_Clear(nn->children);

    /* create value node */
    nnn=GWEN_XMLNode_new(GWEN_XMLNodeTypeData, value);
    GWEN_XMLNode_AddChild(nn, nnn);

    return 0;
  }
  else {
    DBG_ERROR(GWEN_LOGDOMAIN, "Unable to create node [%s]", name);
    return GWEN_ERROR_INVALID;
  }
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
AB_TRANSACTION *AB_ImExporterYN__ReadLNE_LNS(AB_IMEXPORTER *ie,
                                             AB_IMEXPORTER_ACCOUNTINFO *ai,
                                             GWEN_XMLNODE *node)
{
  AB_TRANSACTION *t;
  GWEN_XMLNODE *nn;
  GWEN_DATE *da=NULL;
  AB_VALUE *val=NULL;

  t=AB_Transaction_new();

  /* get date */
  nn=GWEN_XMLNode_FindFirstTag(node, "DTM", 0, 0);
  if (nn)
    da=AB_ImExporterYN__ReadDate(ie, nn, 209);
  AB_Transaction_SetValutaDate(t, da);
  GWEN_Date_free(da);
  da=NULL;

  /* read amount */
  nn=GWEN_XMLNode_FindFirstTag(node, "MOA", 0, 0);
  if (nn) {
    /* Gutschrift */
    val=AB_ImExporterYN__ReadValue(ie, nn, 210);
    if (val) {
      if (AB_Value_IsZero(val)) {
        AB_Value_free(val);
        val=NULL;
      }
    }
    if (val==NULL) {
      val=AB_ImExporterYN__ReadValue(ie, nn, 211);
      if (val)
        AB_Value_Negate(val);
    }
  }
  if (val==NULL)
    val=AB_Value_new();
  AB_Value_SetCurrency(val, AB_ImExporterAccountInfo_GetCurrency(ai));
  AB_Transaction_SetValue(t, val);
  AB_Value_free(val);
  val=0;

  /* read purpose */
  nn=GWEN_XMLNode_GetNodeByXPath(node, "FTX/C108",
                                 GWEN_PATH_FLAGS_NAMEMUSTEXIST);
  if (nn) {
    GWEN_XMLNODE *nnn;

    nnn=GWEN_XMLNode_FindFirstTag(nn, "D_4440", 0, 0);
    while (nnn) {
      GWEN_XMLNODE *nData;

      nData=GWEN_XMLNode_GetFirstData(nnn);
      if (nData) {
        const char *s;

        s=GWEN_XMLNode_GetData(nData);
        if (s) {
          GWEN_BUFFER *xbuf;

          xbuf=GWEN_Buffer_new(0, 256, 0, 1);
          AB_ImExporter_Iso8859_1ToUtf8(s, strlen(s), xbuf);
          AB_Transaction_AddPurposeLine(t, GWEN_Buffer_GetStart(xbuf));
          GWEN_Buffer_free(xbuf);
        }
      }
      nnn=GWEN_XMLNode_FindNextTag(nnn, "D_4440", 0, 0);
    }
  }

  return t;
}