private static Dividend ApproveXBRL4_InsertDvdXBRL(XBRL_event_info xei, Dividend dvd) { if (dvd == null || xei == null) { return(null); } DividendXBRL dvdXBRL = DividendXBRL_master.Get_dvdXBRL(xei.XBRL_ReferenceNumber, dvd.DividendIndex); if (dvdXBRL == null) { dvdXBRL = new DividendXBRL(); } Depositary depo = DepositaryMaster.GetDepositary_by_name(xei.depoName); if (depo == null) { depo = DepositaryMaster.GetDepositary_by_name(xei.Sender); } if (depo != null) { dvdXBRL.Depositary.Value = depo.DepositaryName.Value; } dvdXBRL.DividendIndex.Value = dvd.DividendIndex; dvdXBRL.XBRL_ReferenceNumber.Value = xei.XBRL_ReferenceNumber; dvdXBRL.Announcement_Identifier.Value = xei.AnnouncementIdentifier; if (!dvdXBRL.IsCompleteEvent_flag) { dvdXBRL.Event_Completeness.Value = xei.EventCompleteness; } if (dvdXBRL.XBRL_ID > 0) { if (dvdXBRL.CheckValueChanges()) { dvdXBRL.LastModifiedBy.Value = Utility.CurrentUser; dvdXBRL.LastModifiedDate.Value = DateTime.Now; bool flag = dvdXBRL.Update_to_DB(); } } else { dvdXBRL.LastModifiedBy.Value = Utility.CurrentUser; dvdXBRL.LastModifiedDate.Value = DateTime.Now; bool flag = dvdXBRL.Insert_to_DB(); } return(dvd); }
private static bool DifferentRef_from_sameDepo(XBRL_event_info xei, Dividend existing_dvd) { if (xei == null || existing_dvd == null) { return(false); } List <DividendXBRL> dx_list = existing_dvd.Get_dividendXBRL_list(); foreach (DividendXBRL dx in dx_list) { if (dx.XBRL_ReferenceNumber.IsValueEmpty || dx.Depositary.IsValueEmpty) { continue; } if (dx.XBRL_ReferenceNumber.Value.Equals(xei.XBRL_ReferenceNumber, StringComparison.OrdinalIgnoreCase)) { continue; } Depositary existingDepo = DepositaryMaster.GetDepositary_by_name(dx.Depositary.Value); if (existingDepo == null) { continue; } Depositary XBRLdepo = DepositaryMaster.GetDepositary_by_name(xei.depoName); if (XBRLdepo == null) { XBRLdepo = DepositaryMaster.GetDepositary_by_name(xei.Sender); } if (XBRLdepo == null) { continue; } if (XBRLdepo.DepositaryName.Value.Equals(existingDepo.DepositaryName.Value, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }
public string Create_dividendID(int dvdID_offset = 0) { if (dvdID_offset > 49 || dvdID_offset < 0) { dvdID_offset = 0; //only support offset range 0 ~ 49 for now } Depositary depo = null; int sponserID = 99; string depoID = "00"; if (this.Sponsored.Value) { sponserID = 0 + dvdID_offset; depo = DepositaryMaster.GetDepositary_by_name(this.Depositary.Value); } else { sponserID -= dvdID_offset; depo = DepositaryMaster.GetDepositary_by_name(Depositaries.Depositary.Unsponsored); } if (depo != null) { depoID = depo.DepositaryID.Value; } StringBuilder dvdID_sb = new StringBuilder(); dvdID_sb.Append(HssStr.Trim_to_size(sponserID, 2));//sponsered or not dvdID_sb.Append(HssStr.Trim_to_size(depoID, 2)); dvdID_sb.Append(HssStr.Trim_to_size(this.CUSIP.Value, 9)); dvdID_sb.Append(this.RecordDate_ADR.Value.ToString("MMddyyyy")); dvdID_sb.Append(HssStr.Trim_to_size(this.IncomeEventID.Value, 2, '0')); return(dvdID_sb.ToString()); }
private static void ApproveXBRL3_AddFees(Dividend dvd) { if (dvd == null) { return; } string depo_str = dvd.Sponsored.Value ? dvd.Depositary.Value : dvd.FirstFiler.Value; Depositary depo = DepositaryMaster.GetDepositary_by_name(depo_str); if (depo == null) { return; } Schedule_Of_Fees_DSC sfd = DSC_master.GetDSC_from_CDS(dvd.Country.Value, depo.DepositaryName.Value, dvd.RecordDate_ADR.Value, dvd.SecurityTypeID.Value); if (sfd == null) { return; } Dictionary <decimal, Schedule_Of_Fees_Per_Rate> Japan_atSourceFee_dic = DSC_master.Get_SFPR_dic(dvd.Country.Value, depo.DepositaryName.Value, dvd.RecordDate_ADR.Value); Bulk_DBcmd bk_cmd = new Bulk_DBcmd(); List <DTC_Position_Headers> header_list = DTCpositionHeader_master.Get_headerList_modNum(dvd.DTCPosition_ModelNumber.Value); HashSet <decimal> unique_WHrate_hs = new HashSet <decimal>(); foreach (DTC_Position_Headers dph in header_list) { unique_WHrate_hs.Add(dph.WHRate.Value); } foreach (decimal WHrate in unique_WHrate_hs) { Dividend_Schedule_Of_Fees_DSC dsfd = new Dividend_Schedule_Of_Fees_DSC(); dsfd.DividendIndex.Value = dvd.DividendIndex; dsfd.WHRate.Value = WHrate / 100; dsfd.LongFormFees.Value = sfd.LongFormFees.Value; dsfd.MinLongFormFee.Value = sfd.MinLongFormFee.Value; dsfd.Fee_Consularization.Value = dvd.ConsularizationFee.Value; dsfd.Fee_QuickRefund.Value = sfd.ShortFormFees.Value; /* //useless for now * dsfd.Fee_AtSource.Value = dvd.AtSourceFee.Value; * dsfd.Fee_Max.Value = dvd.MAX_Fees.Value; * dsfd.ExemptAtSourceFee.Value = sfd.ExemptAtSourceFee.Value;//combined into FavAtSourceFee * dsfd.ShortFormFees.Value = sfd.ShortFormFees.Value; * dsfd.MinShortFormFee.Value = sfd.MinShortFormFee.Value; */ dsfd.MinAtSourceFee.Value = sfd.MinAtSourceFee.Value; dsfd.MinQuickRefundFee.Value = sfd.MinQuickRefundFee.Value; dsfd.FavTransparentEntityFee.Value = sfd.FavTransparentEntityFee.Value; if (Japan_atSourceFee_dic.ContainsKey(WHrate)) { Schedule_Of_Fees_Per_Rate sfpr = Japan_atSourceFee_dic[WHrate]; dsfd.FavAtSourceFee.Value = sfpr.RateWithADSC.Value; dsfd.AdditionalDSCFee.Value = sfpr.ADSC.Value; dsfd.AdditionalDSCFee1.Value = sfpr.ADSC.Value; } else { if (WHrate == 0) { dsfd.FavAtSourceFee.Value = sfd.ExemptAtSourceFee.Value; } else { dsfd.FavAtSourceFee.Value = sfd.FavAtSourceFee.Value; } dsfd.AdditionalDSCFee.Value = sfd.AdditionalDSCFee.Value; dsfd.AdditionalDSCFee1.Value = sfd.AdditionalDSCFee.Value; } dsfd.Source_FeeID.Value = sfd.FeesID; dsfd.LastModifiedBy.Value = "StevenXBRL-" + Utility.CurrentUser; dsfd.ModifiedDateTime.Value = DateTime.Now; bk_cmd.Add_DBcmd(dsfd.Get_DBinsert()); } int count = bk_cmd.SaveToDB(Utility.Get_DRWIN_hDB()); }
private static Security CreateSecurity_fromXBRL(XBRL_event_info xei) { if (xei == null) { return(null); } if (string.IsNullOrEmpty(xei.CUSIP)) { Console.WriteLine("SecurityMaster error 0: no CUSIP in XBRL"); return(null); } if (xei.ADR_Ratio_ADR == 0 || xei.ADR_Ratio_ORD == 0) { Console.WriteLine("SecurityMaster error 1: ratio incorrect in XBRL"); return(null); } Country cty = CountryMaster.GetCountry_name(xei.ISO2CntryCode); Depositary depo = DepositaryMaster.GetDepositary_by_name(xei.depoName); if (depo == null) { depo = DepositaryMaster.GetDepositary_by_name(xei.Sender); } if (depo == null) { Console.WriteLine("SecurityMaster error 2: no depository info in XBRL"); return(null); } Security xbrl_sec = new Security(); xbrl_sec.Name.Value = xei.Issue.ToUpper(); xbrl_sec.CUSIP.Value = xei.CUSIP; xbrl_sec.ClearingSystem.Value = "DTCC"; xbrl_sec.SecurityType.Value = "ADR"; xbrl_sec.ADR_RATIO_ADR.Value = xei.ADR_Ratio_ADR; xbrl_sec.ADR_RATIO_ORD.Value = xei.ADR_Ratio_ORD; if (cty != null) { xbrl_sec.Country.Value = cty.name; } if (xei.Sponsored) { xbrl_sec.Depositary.Value = depo.DepositaryName.Value; } else //Un-sponsored event { if (xei.IsFirstFiler) { xbrl_sec.Depositary.Value = Depositary.Unsponsored; xbrl_sec.FirstFiler.Value = depo.DepositaryShortName.Value; } else { Console.WriteLine("SecurityMaster info 0: Unsponsored event and this depo is not first filer, return null"); return(null); } } xbrl_sec.LastModifiedBy.Value = Utility.CurrentUser; xbrl_sec.ModifiedDateTime.Value = DateTime.Now; return(xbrl_sec); }