Esempio n. 1
0
/* --------------------------------------------------------------- FUNCTION */
AH_JOB *AH_Job_GetTransactions_new(AB_USER *u,
                                   AB_ACCOUNT *account) {
  AH_JOB *j;
  AH_JOB_GETTRANSACTIONS *aj;
  GWEN_DB_NODE *dbArgs;
  GWEN_DB_NODE *updgroup;

  int useCreditCardJob = 0;

  //Check if we should use DKKKU
  updgroup=AH_User_GetUpdForAccount(u, account);
  if (updgroup) {
     GWEN_DB_NODE *n;
      n=GWEN_DB_GetFirstGroup(updgroup);
      while(n) {
        if (strcasecmp(GWEN_DB_GetCharValue(n, "job", 0, ""),
                       "DKKKU")==0) {
          useCreditCardJob = 1;
          break;
        }
        n=GWEN_DB_GetNextGroup(n);
      } /* while */
  } /* if updgroup for the given account found */

  if(useCreditCardJob)
    j=AH_AccountJob_new("JobGetTransactionsCreditCard", u, account);
  else
    j=AH_AccountJob_new("JobGetTransactions", u, account);
  if (!j)
    return 0;

  GWEN_NEW_OBJECT(AH_JOB_GETTRANSACTIONS, aj);
  GWEN_INHERIT_SETDATA(AH_JOB, AH_JOB_GETTRANSACTIONS, j, aj,
                       AH_Job_GetTransactions_FreeData);
  /* overwrite some virtual functions */
  if(useCreditCardJob)
    AH_Job_SetProcessFn(j, AH_Job_GetTransactionsCreditCard_Process);
  else
    AH_Job_SetProcessFn(j, AH_Job_GetTransactions_Process);

  AH_Job_SetExchangeFn(j, AH_Job_GetTransactions_Exchange);

  /* set some known arguments */
  dbArgs=AH_Job_GetArguments(j);
  assert(dbArgs);
  if(useCreditCardJob)
    GWEN_DB_SetCharValue(dbArgs, GWEN_DB_FLAGS_DEFAULT,
                         "accountNumber", AB_Account_GetAccountNumber(account));
  else
    GWEN_DB_SetCharValue(dbArgs, GWEN_DB_FLAGS_DEFAULT,
                       "allAccounts", "N");
  return j;
}
/* --------------------------------------------------------------- FUNCTION */
AH_JOB *AH_Job_SepaStandingOrderGet_new(AB_USER *u, AB_ACCOUNT *account) {
  AH_JOB *j;
  GWEN_DB_NODE *dbArgs;

  j=AH_AccountJob_new("JobSepaStandingOrderGet", u, account);
  if (!j)
    return 0;

  /* overwrite some virtual functions */
  AH_Job_SetPrepareFn(j, AH_Job_SepaStandingOrderGet_Prepare);
  AH_Job_SetProcessFn(j, AH_Job_SepaStandingOrdersGet_Process);
  AH_Job_SetExchangeFn(j, AH_Job_SepaStandingOrdersGet_Exchange);

  /* set some known arguments */
  dbArgs=AH_Job_GetArguments(j);
  assert(dbArgs);
  GWEN_DB_SetCharValue(dbArgs, GWEN_DB_FLAGS_DEFAULT,
                       "allAccounts", "N");
  return j;
}