API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

The data class does not have a corresponding entity when....

0
Hi.

I'm building a batch job to import a lot of accounts where I only set all the basic properties. No problems here.
I run thru all my accounts to check if there are some that should have an OpeningAccount set, which there are and that is my problem.

Here is my code: (rewritten as it comes from different methods)

IAccountData updateAccount = AccountImportProcessLineBasic(inputLine); //Build the AccountData with basic properties set

            if (inputLine[accountImportOpeningAccountMapping] != ) //Check if this account needs an openingAccount
            {
                int contraAccountNumer = Convert.ToInt32(inputLine[accountImportOpeningAccountMapping]); //Get the account number

                IAccount openingAccount = session.Account.FindByNumber(contraAccountNumer); //Get Account from Economic by account number
                if (openingAccount != null)
                {
                    updateAccount.OpeningAccount = openingAccount; //If I actually find an account set the property (I'll allways find the account as I started with creating all my accounts)
                }
            }
...
if (updateAccount.OpeningAccount != null)
                {
                    session.Account.UpdateFromData(updateAccount); //Updating Account on server fails
                    outputLog.AppendLine(  Updated Opening Account on Number:  + updateAccount.Number.ToString() +   - Name:  + updateAccount.Name +   - Type:  + updateAccount.Type.ToString());
                }

Initially I would have used session to get the Account from Economic, performed the update on the object and then submitted the change by using session.Account.update(..) that is not possible because there are no methods to do this. The only way is to do it by using AccountData, but AccountData are not mapped/have a corresponding entity, so what should I do?

I properly have missed a thing but what is it?

Kindly regards Rasmus
created Sep 29, 2010 by Ruffio
0% Accept Rate
Q 3 A 5 C 0

3 Answers

0
Hi Rasmus,

I think we need to see your AccountImportProcessLineBasic() method's contents to help you resolve this.


Best regards,
answered Sep 30, 2010 by Christian Estrup
0
Ok, here it is:

private IAccountData AccountImportProcessLineBasic(string[] inputLine)
        {
            int number = Convert.ToInt32(inputLine[accountImportNumberMapping]);
            string name = inputLine[accountImportNameMapping];
            AccountType accountType = AccountImportTypeConvertion(inputLine[accountImportTypeMapping]);

            IAccountData newAccount = session.AccountData.Create(number, name, accountType);
            newAccount.BlockDirectEntries = AccountImportBlockDirectEntriesConvertion(inputLine[accountImportBlockDirectEntriesMapping]);

            if (inputLine[accountImportDebitCreditMapping] != ) newAccount.DebitCredit = AccountImportDebitCreditConvertion(inputLine[accountImportDebitCreditMapping]);
            newAccount.IsAccessible = AccountImportIsAccessibleConvertion(inputLine[accountImportIsAccessibleMapping]);
            return newAccount;
        }

Something tells me that it because I use session.AccountData.Create instead of getting it from the server, but I can't see how I can do that.

Kindly regards
answered Oct 4, 2010 by Ruffio
0
I think I have got it.

I shall do the following:

account = session.Account.FindBynumber(1050);
accountData = session.AccountData.GetData(account);

IAccount openingAccount = session.Account.FindByNumber(openingAccountNumer);
                if (openingAccount != null)
                {
                    accountData .OpeningAccount = openingAccount;
                }

session.Account.UpdateFromData(accountData);
answered Oct 4, 2010 by Ruffio
Visma e-conomic A/S
...