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

Working with cashbook entries

0

I'm trying to open a cashbook and add some finance postings (hardware sale) with wat and balance it with bank. Are there any samples that shows how to add entry and update amounts?

I've started out with this:

            var bank = client.Account_FindByNumber(5820);
            var hardwaresale = client.Account_FindByNumber(1010);
           var sss = client.CashBookEntry_CreateFinanceVoucher(cbh, bank, hardwaresale);

 

It compiles but is it correct? 
How to add amount?
How to split to to debit accounts (bank/cash)?

Where can I read up on how to use the methods in the api apart from the api reference which doesnt really describe how to use the methods as such?

best

Jesper

 

created Nov 26, 2013 by jesperordrup
0% Accept Rate
Q 3 A 2 C 0

1 Answer

+1

Hi Jesper,

Apparently nobody is around. Not even e-conomic ppl? There are really quite many unanswered posts in this forum.

I solved most.  The code below handles x number of orders. One question - it seems that every time i add an entry it still increments the next available number. Even though I change them to balance bank / sale. Is that intended behavior?

CODE:

          EconomicWebServiceSoapClient _client = new EconomicWebServiceSoapClient();

            ((BasicHttpBinding)_client.Endpoint.Binding).AllowCookies = true;

 

 

            var x = _client.Connect(account, username, password);

 

            // setting up

            CashBookHandle cbh = _client.CashBook_FindByName(cashBookName);

          

            var vat = _client.VatAccount_FindByVatCode(vatName);

            var bank = _client.Account_FindByNumber(accountBank);

            var cash = _client.Account_FindByNumber(accountCash);

            foreach (var order in orders) {

                decimal orderTotal = 0;

 

                foreach (var ol in order.Orderlines)

                {

 

                    orderTotal += ol.Price;

                    Product p = Product.Single(ol.FKProductId); // find produktet 

                    var accountHandle = _client.Account_FindByNumber(p.konto);  // account handle

                    var cbEntry = _client.CashBookEntry_CreateFinanceVoucher(cbh, accountHandle, null); // opret en entry i kassekladden

                    var cbData = _client.CashBookEntry_GetData(cbEntry); // hent data fra entry

                    itemnumber = itemnumber == 0 ? cbData.VoucherNumber : itemnumber;  // alle posteringer skal være på samme voucher. Første postings voucher bruger vi på resten.

                    _client.CashBookEntry_SetAmount(cbEntry, ol.Price * (-1));               // belob             _client.CashBookEntry_SetVoucherNumber(cbEntry,itemnumber); // fix entry voucher number

                    _client.CashBookEntry_SetVatAccount(cbEntry, vat); // momspis

                    _client.CashBookEntry_SetText(cbEntry, "Order: " + order.Id + ", " + p.Name); // noget tekst

 

 

 

                }

 

                var cbEntryBank = _client.CashBookEntry_CreateFinanceVoucher(cbh, bank, null); // opret en entry i kassekladden

                var cbDataBank = _client.CashBookEntry_GetData(cbEntryBank); // hent data fra entry

                _client.CashBookEntry_SetVoucherNumber(cbEntryBank, itemnumber); // samme voucher ...

                _client.CashBookEntry_SetAmount(cbEntryBank, orderTotal); // penge

                _client.CashBookEntry_SetText(cbEntryBank, "Order: "  + order.Id); // noget tekst

             

             

                

              

            

            

            }

 _client.Close();

answered Nov 29, 2013 by jesperordrup
Visma e-conomic A/S
...