Beispiel #1
0
 private void Calc(VATreturn v)
 {
     GatherVatReturn(v);
     v.totalVatDue = v.vatDueSales + v.vatDueAcquisitions;
     v.netVatDue   = v.totalVatDue - v.vatReclaimedCurrPeriod;
     ScatterVatReturn(v);
 }
Beispiel #2
0
        public VATreturnResponse SendReturn(VATreturn vatReturn)
        {
            RefreshAccessToken();
            string             url         = urlSite + _urlSubmitVATreturn.Replace("{vrn}", vrn);
            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, url);

            httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(_acceptHeader));
            httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

            foreach (var item in fraudHeaders)
            {
                httpRequest.Headers.Add(item.Key, item.Value);
            }

            string json = JsonConvert.SerializeObject(vatReturn, new DecimalJsonConverter());

            httpRequest.Content = new StringContent(json, Encoding.UTF8, _contentTypeHeader);
            VATreturnResponse ret;

            using (var httpClient = new HttpClient())
            {
                HttpResponseMessage response = httpClient.SendAsync(httpRequest).Result;
                checkApiResponse(response, VATApiType.SubmitVATreturnForPeriod);

                ret = JsonConvert.DeserializeObject <VATreturnResponse>(response.Content.ReadAsStringAsync().Result);
            }
            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// Submit VAT return for period
        /// </summary>
        /// <param name="periodkey"></param>
        /// <returns></returns>
        public VATreturn Returns(string periodkey)
        {
            RefreshAccessToken();
            string             url         = urlSite + _urlReturns.Replace("{vrn}", vrn).Replace("{periodKey}", periodkey);
            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Get, url);

            httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(_acceptHeader));
            httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

            foreach (var item in fraudHeaders)
            {
                httpRequest.Headers.Add(item.Key, item.Value);
            }

            VATreturn vATreturn = null;

            using (var httpClient = new HttpClient())
            {
                HttpResponseMessage response = httpClient.SendAsync(httpRequest).Result;
                checkApiResponse(response, VATApiType.ViewVATReturn);

                var content = response.Content.ReadAsStringAsync();
                vATreturn = JsonConvert.DeserializeObject <VATreturn>(content.Result);
            }

            return(vATreturn);
        }
Beispiel #4
0
 private void GatherVatReturn(VATreturn v)
 {
     v.periodKey                    = tbPeriodKey.Text;
     v.vatDueSales                  = tbVatDueSales.DecimalValue;
     v.vatDueAcquisitions           = tbDueAcquisitions.DecimalValue;
     v.totalVatDue                  = tbTotalVatDue.DecimalValue;
     v.vatReclaimedCurrPeriod       = tbVatReclaimedCurrPeriod.DecimalValue;
     v.netVatDue                    = tbNetVatDue.DecimalValue;
     v.totalValueSalesExVAT         = tbTotalValueSalesExVAT.IntegerValue;
     v.totalValuePurchasesExVAT     = tbTotalValuePurchasesExVAT.IntegerValue;
     v.totalValueGoodsSuppliedExVAT = tbTotalValueGoodsSuppliedExVAT.IntegerValue;
     v.totalAcquisitionsExVAT       = tbTotalAcquisitionsExVAT.IntegerValue;
 }
Beispiel #5
0
 private void ScatterVatReturn(VATreturn v)
 {
     tbPeriodKey.Text                            = v.periodKey;
     tbVatDueSales.NumericValue                  = v.vatDueSales;
     tbDueAcquisitions.NumericValue              = v.vatDueAcquisitions;
     tbTotalVatDue.NumericValue                  = v.totalVatDue;
     tbVatReclaimedCurrPeriod.NumericValue       = v.vatReclaimedCurrPeriod;
     tbNetVatDue.NumericValue                    = v.netVatDue;
     tbTotalValueSalesExVAT.NumericValue         = v.totalValueSalesExVAT;
     tbTotalValuePurchasesExVAT.NumericValue     = v.totalValuePurchasesExVAT;
     tbTotalValueGoodsSuppliedExVAT.NumericValue = v.totalValueGoodsSuppliedExVAT;
     tbTotalAcquisitionsExVAT.NumericValue       = v.totalAcquisitionsExVAT;
 }