Exemplo n.º 1
0
        public Response <bool> DeleteInvoice(DeleteInvoiceRequest request)
        {
            Response <bool> response = new Response <bool>();

            if (request == null || request.ID == 0)
            {
                ArgumentNullException ex = new ArgumentNullException("DeleteInvoice request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                InvoiceAccessor accessor = new InvoiceAccessor();
                accessor.DeleteInvoice(request.ID);
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.Exception = ex;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
Exemplo n.º 2
0
 public async Task WebRequestTest()
 {
     var api = new SzamlazzHuApi();
     var request = CreateSampleRequest();
     string apiKey = Environment.GetEnvironmentVariable("SZAMLAZZ_HU_KEY");
     request.AuthenticationData.ApiKey = apiKey;
     request.Header.InvoiceNumberPrefix = "NINCS";
     request.Header.IssueDate = DateTime.Now;
     request.Header.CompletionDate = DateTime.Now;
     request.Header.DueDate = DateTime.Now;
     request.Header.FeeCollection = true;
     var response = await api.CreateInvoice(request);
     Assert.IsTrue(response.Success);
     var getInvoiceRequest = new GetInvoiceRequest();
     getInvoiceRequest.AuthenticationData.ApiKey = apiKey;
     getInvoiceRequest.InvoiceNumber = response.InvoiceNumber;
     var getInvoiceResponse = await api.GetInvoice(getInvoiceRequest);
     Assert.AreEqual(request.Seller.BankName, getInvoiceResponse.Seller.BankName);
     Assert.AreEqual(request.Seller.BankAccount, getInvoiceResponse.Seller.BankAccount);
     Assert.AreEqual(request.Header.Comment, getInvoiceResponse.InvoiceHeader.Comment);
     Assert.AreEqual(request.Header.CompletionDate.Date, getInvoiceResponse.InvoiceHeader.CompletionDate.Date);
     Assert.AreEqual(request.Header.Currency, getInvoiceResponse.InvoiceHeader.Currency);
     Assert.AreEqual(request.Header.DueDate.Date, getInvoiceResponse.InvoiceHeader.DueDate.Date);
     Assert.AreEqual(request.Header.ExchangeRate, getInvoiceResponse.InvoiceHeader.ExchangeRate);
     Assert.AreEqual(request.Header.FeeCollection, getInvoiceResponse.InvoiceHeader.FeeCollection);
     Assert.AreEqual(request.Header.InvoiceNumberPrefix, getInvoiceResponse.InvoiceHeader.InvoiceNumberPrefix);
     Assert.AreEqual(request.Header.IssueDate.Date, getInvoiceResponse.InvoiceHeader.IssueDate.Date);
     Assert.AreEqual(request.Header.Language, getInvoiceResponse.InvoiceHeader.Language);
     Assert.AreEqual(request.Header.PaymentType, getInvoiceResponse.InvoiceHeader.PaymentType);
     Assert.AreEqual(request.Customer.Name, getInvoiceResponse.Customer.Name);
     Assert.AreEqual(request.Customer.CustomerAddress.Country, getInvoiceResponse.Customer.CustomerAddress.Country);
     Assert.AreEqual(request.Customer.CustomerAddress.PostalCode, getInvoiceResponse.Customer.CustomerAddress.PostalCode);
     Assert.AreEqual(request.Customer.CustomerAddress.City, getInvoiceResponse.Customer.CustomerAddress.City);
     Assert.AreEqual(request.Customer.CustomerAddress.StreetAddress, getInvoiceResponse.Customer.CustomerAddress.StreetAddress);
     Assert.AreEqual(request.Customer.EmailAddress, getInvoiceResponse.Customer.EmailAddress);
     Assert.AreEqual(request.Customer.Identification, getInvoiceResponse.Customer.Identification);
     Assert.AreEqual(request.Customer.TaxNumber, getInvoiceResponse.Customer.TaxNumber);
     Assert.AreEqual(request.Items.Count, getInvoiceResponse.InvoiceItems.Count);
     for (int i = 0; i < request.Items.Count; ++i)
     {
         Assert.AreEqual(request.Items[i].GrossAmount, getInvoiceResponse.InvoiceItems[i].GrossAmount);
         Assert.AreEqual(request.Items[i].Name, getInvoiceResponse.InvoiceItems[i].Name);
         Assert.AreEqual(request.Items[i].NetPrice, getInvoiceResponse.InvoiceItems[i].NetPrice);
         Assert.AreEqual(request.Items[i].Quantity, getInvoiceResponse.InvoiceItems[i].Quantity);
         Assert.AreEqual(request.Items[i].UnitOfQuantity, getInvoiceResponse.InvoiceItems[i].UnitOfQuantity);
         Assert.AreEqual(request.Items[i].UnitPrice, getInvoiceResponse.InvoiceItems[i].UnitPrice);
         Assert.AreEqual(request.Items[i].VatAmount, getInvoiceResponse.InvoiceItems[i].VatAmount);
         Assert.AreEqual(request.Items[i].VatRate, getInvoiceResponse.InvoiceItems[i].VatRate);
     }
     var deleteInvoiceRequest = new DeleteInvoiceRequest();
     deleteInvoiceRequest.AuthenticationData.ApiKey = apiKey;
     deleteInvoiceRequest.InvoiceNumber = response.InvoiceNumber;
     var deleteInvoiceResponse = await api.DeleteProFormaInvoice(deleteInvoiceRequest);
     Assert.IsTrue(deleteInvoiceResponse.Success, deleteInvoiceResponse.ErrorMessage);
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        ///<param name="deleteInvoiceRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param>
        public DeleteInvoiceResponse DeleteInvoice(DeleteInvoiceRequest deleteInvoiceRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, deleteInvoiceRequest.ToNVPString(string.Empty), ServiceName, "DeleteInvoice", credential);

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "Invoice";

            NVPUtil util = new NVPUtil();

            return(DeleteInvoiceResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
Exemplo n.º 4
0
        public ResultJson DeleteInvoice(DeleteInvoiceRequest request)
        {
            ResultJson result        = new ResultJson();
            var        Addressresult = InvoiceFunc.Instance.DeleteById(request.Id);

            if (Addressresult)
            {
                result.HttpCode = 200;
                result.Message  = "发票删除成功!";
            }
            else
            {
                result.HttpCode = 300;
                result.Message  = "发票删除失败!";
            }
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        ///<param name="deleteInvoiceRequest"></param>

        public DeleteInvoiceResponse DeleteInvoice(DeleteInvoiceRequest deleteInvoiceRequest)
        {
            return(DeleteInvoice(deleteInvoiceRequest, (string)null));
        }