예제 #1
0
        private void UpdateCustomer(Quickbooks qb, ICustomerRet customer, CheckToWrite r)
        {
            List <String>  account    = new List <string>();
            IMsgSetRequest msgRequest = qb.newRequest();

            msgRequest.Attributes.OnError = ENRqOnError.roeStop;
            ICustomerMod customerMod = msgRequest.AppendCustomerModRq();

            customerMod.ListID.SetValue(customer.ListID.GetValue());
            customerMod.AccountNumber.SetValue(r.RecipientId);
            customerMod.Name.SetValue(r.FullName);
            customerMod.BillAddress.Addr1.SetValue(customerMod.Name.GetValue());
            customerMod.BillAddress.Addr2.SetValue(r.Address1);
            customerMod.BillAddress.Addr3.SetValue(r.Address2);

            customerMod.Contact.SetValue(customerMod.Name.GetValue());
            customerMod.BillAddress.City.SetValue(r.City);
            customerMod.BillAddress.State.SetValue(r.State);
            customerMod.BillAddress.PostalCode.SetValue(r.Zip);
            customerMod.EditSequence.SetValue(customer.EditSequence.GetValue());
            IMsgSetResponse response = qb.performRequest(msgRequest);

            if (response.ResponseList.GetAt(0).StatusCode != 0)
            {
                throw new Exception("Unable to update customer " + response.ResponseList.GetAt(0).StatusMessage);
            }
        }
예제 #2
0
        private ICustomerRet addCustomer(Quickbooks qb, CheckToWrite r)
        {
            IMsgSetRequest msgRequest = qb.newRequest();

            msgRequest.Attributes.OnError = ENRqOnError.roeStop;

            ICustomerAdd addCustomer = msgRequest.AppendCustomerAddRq();

            addCustomer.AccountNumber.SetValue(r.RecipientId);
            addCustomer.Name.SetValue(r.FullName);
            addCustomer.BillAddress.Addr1.SetValue(addCustomer.Name.GetValue());
            addCustomer.BillAddress.Addr2.SetValue(r.Address1);
            addCustomer.BillAddress.Addr3.SetValue(r.Address2);
            addCustomer.Contact.SetValue(addCustomer.Name.GetValue());
            addCustomer.BillAddress.City.SetValue(r.City);
            addCustomer.BillAddress.State.SetValue(r.State);
            addCustomer.BillAddress.PostalCode.SetValue(r.Zip);

            IMsgSetResponse response = qb.performRequest(msgRequest);

            if (response.ResponseList.GetAt(0).StatusCode == 0)
            {
                ICustomerRet result = (ICustomerRet)response.ResponseList.GetAt(0).Detail;
                return(result);
            }
            else
            {
                throw new Exception("Unable to add customer " + response.ResponseList.GetAt(0).StatusMessage);
            }
        }
예제 #3
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);
            }
        }