Ejemplo n.º 1
0
        private MessageSpec_Type GetMessageSpec(ExcelPackage package)
        {
            var messageSpec = new MessageSpec_Type();

            this.receivingCountryClass = new List <ReceivingCountryClass>();

            // cbc_oecd.MessageSpec.SendingEntityIN
            messageSpec.TransmittingCountry = CountryCode_Type.ZA;


            // ReceivingCountry
            List <CountryCode_Type> ReceivingCountries = new List <CountryCode_Type>();

            var rowNumber = 2;

            while (true)
            {
                var cellValue = GetExcelStringValue(package, "SUMMARY", "A" + rowNumber);
                if (string.IsNullOrEmpty(cellValue))
                {
                    break;
                }


                ReceivingCountries.Add(EnumLookup.GetCountryCodeEnumType(cellValue)); // (S:SUMMARY - Cells:A)

                this.receivingCountryClass.Add(new ReceivingCountryClass
                {
                    RowNumber   = rowNumber,
                    CountryCode = cellValue
                });
                rowNumber++;
            }
            messageSpec.ReceivingCountry = new CountryCode_Type[] { CountryCode_Type.ZA };

            // MessageType
            messageSpec.MessageType = MessageType_EnumType.CBC;

            // Language
            messageSpec.Language          = LanguageCode_Type.EN;
            messageSpec.LanguageSpecified = true;

            // Warning
            messageSpec.Warning = GetExcelStringValue(package, "CoverPage", "B20");

            // Contact
            messageSpec.Contact = GetExcelStringValue(package, "CoverPage", "B1"); // (S: CoverPage; Cells:B1)

            // MessageRefId
            messageSpec.MessageRefId     = GetExcelStringValue(package, "CoverPage", "B2");// "ZA2019BAW"; // (S: CoverPage; Cells:B2)
            messageSpec.CorrMessageRefId = new string[] { GetExcelStringValue(package, "CoverPage", "B3") };

            // MessageTypeIndic
            messageSpec.MessageTypeIndic          = EnumLookup.GetCbcMessageTypeIndicEnumType(GetExcelStringValue(package, "CoverPage", "B4")); // CbcMessageTypeIndic_EnumType.CBC401; //  (S: CoverPage; Cells:B3)
            messageSpec.MessageTypeIndicSpecified = true;

            // ReportingPeriod
            // messageSpec.ReportingPeriod = new DateTime(GetExcelIntValue(package, "CoverPage", "B5").Value, GetExcelIntValue(package, "CoverPage", "B6").Value, GetExcelIntValue(package, "CoverPage", "B7").Value); // new DateTime(2019, 9, 30);  //  (S: CoverPage; Cells:B4, B5, B6)
            messageSpec.ReportingPeriod = DateTime.Parse(GetExcelStringValue(package, "CoverPage", "B5"));

            messageSpec.Timestamp = DateTime.Now;


            // messageSpec.SendingEntityIN = null; // TODO Check with SARS

            // messageSpec.CorrMessageRefId = null;  // This data element is not used for CbC reporting


            return(messageSpec);
        }