private void LoadData() { var orders = GetAllSelectedOrders(); var reportData = new List <TaxReportLine>(); foreach (var order in orders) { if (order.StatusCode == OrderStatusCode.Completed || order.StatusCode == OrderStatusCode.ReadyForShipping) { var reportLine = reportData. Where(rl => rl.CountryBvin == order.ShippingAddress.CountryBvin). Where(rl => rl.RegionBvin == order.ShippingAddress.RegionBvin). FirstOrDefault(); if (reportLine == null) { reportLine = new TaxReportLine { CountryBvin = order.ShippingAddress.CountryBvin, RegionBvin = order.ShippingAddress.RegionBvin, CountryName = order.ShippingAddress.CountryDisplayName, RegionName = order.ShippingAddress.RegionDisplayName }; reportData.Add(reportLine); } reportLine.TotalTax += order.TotalTax; } } TaxCount = reportData.Count; gvTaxReport.DataSource = reportData; gvTaxReport.DataBind(); ShowNoRecordsMessage(TaxCount == 0); }
public static void SendVATReturnProc(VATMaint graph, VATPeriodFilter p, bool finalised = false) { #region Tax Box /* * Outputs * Box 1 (vatDueSales) VAT due in the period on sales and other outputs * Box 2 (vatDueAcquisitions) VAT due in the period on acquisitions from other EU member states * Box 3 (totalVatDue) Total VAT due (Box 1 + Box 2) * * Inputs * Box 4 (vatReclaimedCurrPeriod) VAT reclaimed in the period on purchases and other inputs (including acquisitions from the EU) * Box 5 (netVatDue) net VAT to be paid to HMRC or reclaimed (difference between Box 3 and Box 4) * Box 6 (totalValueSalesExVAT) total value of sales and all other outputs excluding any VAT * Box 7 (totalValuePurchasesExVAT) the total value of purchases and all other inputs excluding any VAT * Box 8 (totalValueGoodsSuppliedExVAT) total value of all supplies of goods and related costs, excluding any VAT, to other EU member states * Box 9 (totalAcquisitionsExVAT) total value of all acquisitions of goods and related costs, excluding any VAT, from other EU member states */ #endregion Model.VATreturn ret = new Model.VATreturn() { periodKey = p.PeriodKey, finalised = finalised }; #region fill report decimal amt = 0; foreach (PXResult <TaxReportLine, TaxHistoryReleased> res in graph.Period_Details.Select()) { TaxReportLine line = res; TaxHistoryReleased hist = res; amt = hist.ReportFiledAmt ?? 0; switch (line.ReportLineNbr) { case "1": ret.vatDueSales = amt; break; case "2": ret.vatDueAcquisitions = amt; break; case "3": ret.totalVatDue = amt; break; case "4": ret.vatReclaimedCurrPeriod = amt; break; case "5": ret.netVatDue = amt; break; case "6": ret.totalValueSalesExVAT = amt; break; case "7": ret.totalValuePurchasesExVAT = amt; break; case "8": ret.totalValueGoodsSuppliedExVAT = amt; break; case "9": ret.totalAcquisitionsExVAT = amt; break; } } #endregion try { VATreturnResponse response = graph.VATProvider.SendReturn(ret); PXTrace.WriteInformation(JsonConvert.SerializeObject(response)); } catch (Exceptions.VATAPIInvalidToken eToken) { PXTrace.WriteError(eToken); throw new PXException(Messages.PleaseAuthorize); } catch (Exceptions.VATAPIException eApi) { PXTrace.WriteError(eApi); if (eApi.Data.Contains("errorJson")) { PXTrace.WriteError(eApi.Data["errorJson"].ToString()); } throw eApi; } catch (Exception e) { PXTrace.WriteError(e); throw e; } throw new PXException(Messages.VATreturnIsAccepted); }