Example #1
0
        public static R68ClaimRepayment CreateRepayments()
        {
            if (GiftAidDonations != null)
            {
                R68ClaimRepaymentGAD[] GADs = new R68ClaimRepaymentGAD[GiftAidDonations.Rows.Count];

                _loggingService.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType
                                        , String.Concat("Processing ", GiftAidDonations.Rows.Count, " donation records."));

                for (int i = 0; i < GiftAidDonations.Rows.Count; i++)
                {
                    if (GiftAidDonations.Columns.Contains("Type"))
                    {
                        if (GiftAidDonations.Rows[i]["Type"].ToString().ToUpper() == "AGG")
                        {
                            R68ClaimRepaymentGADCreator aggDonationCreator = new R68ClaimRepaymentGADCreator(new AggDonationR68ClaimRepaymentGADBuilder(_loggingService), _loggingService);
                            aggDonationCreator.SetInputRow(GiftAidDonations.Rows[i]);
                            aggDonationCreator.CreateR68ClaimRepaymentGAD();
                            GADs[i] = aggDonationCreator.GetR68ClaimRepaymentGAD();
                        }
                        if (GiftAidDonations.Rows[i]["Type"].ToString().ToUpper() == "GAD")
                        {
                            R68ClaimRepaymentGADCreator donorCreator = new R68ClaimRepaymentGADCreator(new DonorR68ClaimRepaymentGADBuilder(_loggingService), _loggingService);
                            donorCreator.SetInputRow(GiftAidDonations.Rows[i]);
                            donorCreator.CreateR68ClaimRepaymentGAD();
                            GADs[i] = donorCreator.GetR68ClaimRepaymentGAD();
                        }
                    }
                    else
                    {
                        R68ClaimRepaymentGADCreator donorCreator = new R68ClaimRepaymentGADCreator(new DonorR68ClaimRepaymentGADBuilder(_loggingService), _loggingService);
                        donorCreator.SetInputRow(GiftAidDonations.Rows[i]);
                        donorCreator.CreateR68ClaimRepaymentGAD();
                        GADs[i] = donorCreator.GetR68ClaimRepaymentGAD();
                    }
                }

                var repayment = new R68ClaimRepayment();
                repayment.GAD                     = GADs;
                repayment.EarliestGAdate          = Convert.ToDateTime(GiftAidDonations.Compute("min(Date)", string.Empty));
                repayment.EarliestGAdateSpecified = true;

                _loggingService.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType
                                        , "ClaimRepayment object created.");

                return(repayment);
            }
            _loggingService.LogWarning(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "No records for GiftAid repayment");
            return(null);
        }
Example #2
0
        public static DonorError GetGADError(string filename, string location)
        {
            XPathDocument  doc = new XPathDocument(filename);
            XPathNavigator nav = doc.CreateNavigator();

            XmlNamespaceManager nsMgr = new XmlNamespaceManager(nav.NameTable);

            nsMgr.AddNamespace("hd", @"http://www.govtalk.gov.uk/CM/envelope");
            nsMgr.AddNamespace("r68", @"http://www.govtalk.gov.uk/taxation/charities/r68/2");

            XPathNavigator GAD = nav.SelectSingleNode(location, nsMgr);

            XmlRootAttribute GADROOT = new XmlRootAttribute();

            GADROOT.ElementName = "GAD";
            GADROOT.Namespace   = "http://www.govtalk.gov.uk/taxation/charities/r68/2";
            GADROOT.IsNullable  = true;

            XmlSerializer serializer = new XmlSerializer(typeof(R68ClaimRepaymentGAD), GADROOT);

            XmlDocument GADXML = new XmlDocument();

            GADXML.Load(GAD.ReadSubtree());

            MemoryStream xmlStream = new MemoryStream();

            GADXML.Save(xmlStream);
            xmlStream.Seek(0, SeekOrigin.Begin);

            //object tempobj = serializer.Deserialize(xmlStream);

            R68ClaimRepaymentGAD      Donation = (R68ClaimRepaymentGAD)serializer.Deserialize(xmlStream);
            R68ClaimRepaymentGADDonor Donor    = (R68ClaimRepaymentGADDonor)Donation.Item;

            DonorError donorErr = new DonorError
            {
                Forename       = Donor.Fore,
                Surname        = Donor.Sur,
                Address1       = Donor.House,
                Postcode       = Donor.Item.GetType() == typeof(string) ? Donor.Item.ToString() : "", //@TODO: Does this work for Overseas?
                DonationAmount = Donation.Total.ToString(),
                DonationDate   = Donation.Date.ToString()
            };

            return(donorErr);
        }
Example #3
0
        public static void TestSerialize()
        {
            R68ClaimGASDS gasds = new R68ClaimGASDS();

            gasds.ConnectedCharities = r68_YesNoType.no;
            gasds.CommBldgs          = r68_YesNoType.no;

            R68ClaimRepaymentOtherInc otherinc = new R68ClaimRepaymentOtherInc();

            otherinc.Payer  = "Peter Other";
            otherinc.Gross  = 13.12M;
            otherinc.OIDate = Convert.ToDateTime("2014-10-31");
            otherinc.Tax    = 2.62M;

            R68ClaimRepaymentOtherInc[] OtherIncs = new R68ClaimRepaymentOtherInc[1];
            OtherIncs[0] = otherinc;

            R68ClaimRepaymentGADDonor donor = new R68ClaimRepaymentGADDonor();

            donor.Fore  = "Jane";
            donor.Sur   = "Smith";
            donor.House = "1";
            donor.Item  = "BA23 9CD";

            R68ClaimRepaymentGAD gad = new R68ClaimRepaymentGAD();

            gad.Item        = donor;
            gad.TotalString = "12.00";
            gad.Date        = Convert.ToDateTime("2014-10-03");

            XmlDocument xmlGad =
                XmlSerializationHelpers.SerializeItem(gad);

            byte[] bytes = Encoding.UTF8.GetBytes(xmlGad.OuterXml);

            xmlGad.Save(@"C:\Temp\GAD.xml");

            R68ClaimRepaymentGAD[] GADS = new R68ClaimRepaymentGAD[1];
            GADS[0] = gad;

            R68ClaimRepayment repayment = new R68ClaimRepayment();

            repayment.EarliestGAdateSpecified = true;
            repayment.EarliestGAdate          = Convert.ToDateTime("2014-10-03");
            repayment.GAD      = GADS;
            repayment.OtherInc = OtherIncs;

            R68ClaimRegulator regulator = new R68ClaimRegulator();

            regulator.Item  = R68ClaimRegulatorRegName.CCEW;
            regulator.RegNo = "A1234";

            R68Claim claim = new R68Claim();

            claim.OrgName   = "My Organisation";
            claim.HMRCref   = "AA12345";
            claim.GASDS     = gasds;
            claim.Regulator = regulator;
            claim.Repayment = repayment;

            XmlDocument claimXml =
                XmlSerializationHelpers.SerializeItem(claim);

            claimXml.Save(@"C:\Temp\R68Claim.xml");
        }
 public void InitialiseR68ClaimRepaymentGAD(ILoggingService loggingService)
 {
     _r68ClaimRepaymentGAD = new R68ClaimRepaymentGAD();
     _loggingService       = loggingService;
 }