Пример #1
0
        private void WriteRefundCheck(Quickbooks qb, CheckToWrite r)
        {
            ICustomerRet customer = FindCustomer(qb, r.FullName);

            if (customer == null)
            {
                customer = addCustomer(qb, r);
            }
            else
            {
                UpdateCustomer(qb, customer, r);
            }

            IMsgSetRequest msgRequest = qb.newRequest();

            msgRequest.Attributes.OnError = ENRqOnError.roeStop;

            ICheckAdd addCheckRequest = msgRequest.AppendCheckAddRq();

            addCheckRequest.PayeeEntityRef.ListID.SetValue(customer.ListID.GetValue());

            addCheckRequest.Memo.SetValue(r.Memo);
            addCheckRequest.AccountRef.FullName.SetValue(r.QbBankAccount);
            IExpenseLineAdd expenseAdd = addCheckRequest.ExpenseLineAddList.Append();

            expenseAdd.AccountRef.FullName.SetValue(r.QbIncomeAccount);
            expenseAdd.Amount.SetValue((double)r.Amount);
            expenseAdd.Memo.SetValue(r.Memo);

            addCheckRequest.IsToBePrinted.SetValue(true);
            addCheckRequest.RefNumber.SetEmpty();

            IMsgSetResponse response = qb.performRequest(msgRequest);

            if (response.ResponseList.GetAt(0).StatusCode != 0)
            {
                throw new Exception("failed to write refund check " + response.ResponseList.GetAt(0).StatusMessage);
            }
        }