Exemplo n.º 1
0
 public TreatyWithWTRRates GetsingleDomesticRate(string hostCountryCode)
 {
     var singleDomesticRate = new WTRateBusiness().GetSingleDomesticRate(hostCountryCode);
     TreatyWithWTRRates trWithWTR = new TreatyWithWTRRates()
     {
         DivSubstantialHoldingRate = singleDomesticRate.Data[0].DividendsRate,
         DivPortfolioRate = "",
         InterestGeneralRate = singleDomesticRate.Data[0].InterestRate,
         InterestCbRate = "",
         InterestBankRate = "",
         RoyaltyPatentRate = singleDomesticRate.Data[0].RoyalityRate,
         RoyaltyCrRate = "",
         RoyaltyLpRate = "",
         RoyaltyTmRate = "",
         DivSubstantialHoldingRateArticleLine = "",
         DivportfolioRateArticleLine = "",
         InterestGeneralRateArticleLine = "",
         InterestBankRateArticleLine = "",
         InterestCbRateArticleLine = "",
         RoyaltyPatentRateArticleLine = "",
         RoyaltyCrRateArticleLine = "",
         RoyaltyLpRateArticleLine = "",
         RoyaltyTmRateArticleLine = "",
         Country = "Domestic WHT rates",
         CountryId = 0,
         CountryCode = singleDomesticRate.Data[0].Code,
         EffectiveDate = "",
         EntryIntoForce = "",
         Id = 0,
         IsContentAvailable = false,
         Status = "",
         Title = "",
         IsContentAvailableForDividendRate = false,
         IsContentAvailableForInterestRate = false,
         IsContentAvailableForRoyaltyRate = false,
     };
     return trWithWTR;
 }
Exemplo n.º 2
0
        public List<TreatyWithWTRRates> GetTreatyWithWTRRates(string hostCountryCode)
        {
            using (var work = new UnitOfWork())
            {
                var treatyMetadata = new TreatyRepository(work).GetTreaty(hostCountryCode, "").ToList();
                var treatyBusiness = new TreetyBusiness();
                var conceptIds = "DIV_10" + "," + "INT_11" + "," + "ROY_12";
                var partnerCountryCodes = string.Join(",", treatyMetadata.Select(b => b.Country1.Code).ToList());
                var partnerCountryCodes2 = string.Join(",", treatyMetadata.Select(b => b.Country.Code).ToList());
                partnerCountryCodes = partnerCountryCodes + "," + partnerCountryCodes2;
                var articles = new TreetyBusiness().GetArticlesByHostCountry(hostCountryCode, partnerCountryCodes, conceptIds);
                List<TreatyWithWTRRates> listWTRRates = new List<TreatyWithWTRRates>();
                foreach (var treetyMD in treatyMetadata)
                {
                    var list = new WTRateRepository(work).GetAllWTRatesValue(treetyMD.HostCountryId, treetyMD.PartnerCountryId);
                    if (list.Count == 0) list = new WTRateRepository(work).GetAllWTRatesValue(treetyMD.PartnerCountryId, treetyMD.HostCountryId);
                    var divStreamId = ConfigurationManager.AppSettings["DivSubstantialHoldingRateStreamId"].Trim();
                    var divportfolioStreamId = ConfigurationManager.AppSettings["DIVPortfolioStreamId"].Trim();
                    var intGeneralStreamId = ConfigurationManager.AppSettings["IntGeneralStreamId"].Trim();
                    var intCbStreamId = ConfigurationManager.AppSettings["InterestCBRateStreamId"].Trim();
                    var intBankStreamId = ConfigurationManager.AppSettings["InterestBankRateStreamId"].Trim();
                    var royPatentStreamId = ConfigurationManager.AppSettings["RoyalityPatentRateStreamId"].Trim();
                    var royTmStreamId = ConfigurationManager.AppSettings["RoyalityTmRateStreamId"].Trim();
                    var royCrStreamId = ConfigurationManager.AppSettings["RoyalityCrRateStreamId"].Trim();
                    var royLpStreamId = ConfigurationManager.AppSettings["RoyalityLpRateStreamId"].Trim();

                    var divValue = list.Where(b => b.StreamId.Equals(divStreamId)).FirstOrDefault();
                    var divportfolioRatevalue = list.Where(b => b.StreamId.Equals(divportfolioStreamId)).FirstOrDefault();
                    var intGeneralValue = list.Where(b => b.StreamId.Equals(intGeneralStreamId)).FirstOrDefault();
                    var intCbValue = list.Where(b => b.StreamId.Equals(intCbStreamId)).FirstOrDefault();
                    var intBankValue = list.Where(b => b.StreamId.Equals(intBankStreamId)).FirstOrDefault();
                    var royPatentValue = list.Where(b => b.StreamId.Equals(royPatentStreamId)).FirstOrDefault();
                    var royTmValue = list.Where(b => b.StreamId.Equals(royTmStreamId)).FirstOrDefault();
                    var royLpValue = list.Where(b => b.StreamId.Equals(royLpStreamId)).FirstOrDefault();
                    var royCrValue = list.Where(b => b.StreamId.Equals(royCrStreamId)).FirstOrDefault();

                    var countryPair = treatyBusiness.GetPairCountryCode(treetyMD.Country.Code, treetyMD.Country1.Code);
                    var partnerCountryName = treetyMD.Country1.Code == hostCountryCode ? treetyMD.Country.Name : treetyMD.Country1.Name;
                    var partnerCountryId = treetyMD.Country1.Code == hostCountryCode ? treetyMD.Country.Id : treetyMD.Country1.Id;
                    TreatyWithWTRRates trWithWTR = new TreatyWithWTRRates()
                          {
                              DivSubstantialHoldingRate = divValue == null ? "" : divValue.Rate,
                              DivPortfolioRate = divportfolioRatevalue == null ? "" : divportfolioRatevalue.Rate,
                              InterestGeneralRate = intGeneralValue == null ? "" : intGeneralValue.Rate,
                              InterestCbRate = intCbValue == null ? "" : intCbValue.Rate,
                              InterestBankRate = intBankValue == null ? "" : intBankValue.Rate,
                              RoyaltyPatentRate = royPatentValue == null ? "" : royPatentValue.Rate,
                              RoyaltyCrRate = royCrValue == null ? "" : royCrValue.Rate,
                              RoyaltyLpRate = royLpValue == null ? "" : royLpValue.Rate,
                              RoyaltyTmRate = royTmValue == null ? "" : royTmValue.Rate,
                              DivSubstantialHoldingRateArticleLine = divValue == null ? "" : divValue.ArticleLine,
                              DivportfolioRateArticleLine = divportfolioRatevalue == null ? "" : divportfolioRatevalue.ArticleLine,
                              InterestGeneralRateArticleLine = intGeneralValue == null ? "" : intGeneralValue.ArticleLine,
                              InterestBankRateArticleLine = intBankValue == null ? "" : intBankValue.ArticleLine,
                              InterestCbRateArticleLine = intCbValue == null ? "" : intCbValue.ArticleLine,
                              RoyaltyPatentRateArticleLine = royPatentValue == null ? "" : royPatentValue.ArticleLine,
                              RoyaltyCrRateArticleLine = royCrValue == null ? "" : royCrValue.ArticleLine,
                              RoyaltyLpRateArticleLine = royLpValue == null ? "" : royLpValue.ArticleLine,
                              RoyaltyTmRateArticleLine = royTmValue == null ? "" : royTmValue.ArticleLine,
                              Country = partnerCountryName,
                              CountryId = partnerCountryId,
                              CountryCode = countryPair[0].Equals(hostCountryCode) ? countryPair[1] : countryPair[0],
                              EffectiveDate = treetyMD.EffectiveDate,
                              EntryIntoForce = treetyMD.EntryIntoForce,
                              Id = treetyMD.Id,
                              IsContentAvailable = (treetyMD.TreatyPdf != null && treetyMD.TreatyPdf.Length > 0),
                              Status = treetyMD.Status,
                              Title = treetyMD.Title,
                              IsContentAvailableForDividendRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "DIV_10" && b.ArticleContent.Length > 0) > 0,
                              IsContentAvailableForInterestRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "INT_11" && b.ArticleContent.Length > 0) > 0,
                              IsContentAvailableForRoyaltyRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "ROY_12" && b.ArticleContent.Length > 0) > 0,
                          };
                    listWTRRates.Add(trWithWTR);
                }
                listWTRRates = listWTRRates.OrderBy(b => b.Country).ToList();
                var singleDomesticItem = GetsingleDomesticRate(hostCountryCode);
                listWTRRates.Insert(0, singleDomesticItem);
                return listWTRRates;
            }
        }