/// <summary> /// Create New Dividend /// </summary> /// <returns>Approved Dividend in [Dividend_Control_Approved]</returns> private static Dividend ApproveXBRL2_CreateNewDividend(XBRL_event_info xei, Security sec) { Dividend XBRL_dvd = new Dividend(); XBRL_dvd.Init_from_XBRL(xei, sec); XBRL_dvd.LastModifiedBy.Value = "StevenXBRL-" + Utility.CurrentUser; //insert temp dividend into [Dividend_Control] if (!XBRL_dvd.Insert_to_DB(DividendTable_option.Dividend_Control)) { MessageBox.Show("Helper_XBRL error 0: can't save into [Dividend_Control]"); return(null); } //Get DividendIndex from saved dividend in [Dividend_Control] Dividend appr_dvd = Helper_Dividend.GetDividend_dvdID(XBRL_dvd.DividendID.Value, DividendTable_option.Dividend_Control); if (appr_dvd != null) { Helper_XBRL_approval.ApproveXBRL3_AddFees(appr_dvd); appr_dvd.Insert_to_DB(DividendTable_option.Dividend_Control_Approved); } else { MessageBox.Show("Helper_XBRL error 1: can't save into [Dividend_Control_Approved]"); return(null); } return(appr_dvd); }
private DataTable Get_fee_DT(XBRL_event_info xei) { DataTable fee_dt = new DataTable("Fee"); fee_dt.Columns.Add("ID", typeof(int)); fee_dt.Columns.Add("WithholdingTaxPercentage"); fee_dt.Columns.Add("PayoutAmount"); fee_dt.Columns.Add("TaxAmountWithheldFromPayout"); fee_dt.Columns.Add("TaxReliefFee"); fee_dt.Columns.Add("FeeRate"); fee_dt.Columns.Add("DepositaryServiceFee"); fee_dt.Columns.Add("PayoutAmountNetOfTax"); if (xei == null) { return(fee_dt); } foreach (FeeInfo fi in xei.fee_list) { DataRow row = fee_dt.Rows.Add(); row["ID"] = this.id_SavedfilesRcvd; row["WithholdingTaxPercentage"] = fi.WithholdingTaxPercentage; row["PayoutAmount"] = fi.PayoutAmount; row["TaxAmountWithheldFromPayout"] = fi.TaxAmountWithheldFromPayout; row["TaxReliefFee"] = fi.TaxReliefFee; row["FeeRate"] = fi.FeeRate; row["DepositaryServiceFee"] = fi.DepositaryServiceFee; row["PayoutAmountNetOfTax"] = fi.PayoutAmountNetOfTax; } return(fee_dt); }
private static Dividend ApproveXBRL0_find_existingDividend(XBRL_event_info xei) { if (xei == null) { return(null); } Dividend existingDVD = Helper_Dividend.GetDividend_XBRL_refNum(xei.XBRL_ReferenceNumber); if (existingDVD == null) { List <Dividend> list = Helper_Dividend.Get_DividendList_CR(xei.CUSIP, xei.RecordDate_ADR); foreach (Dividend dvd in list) { if (dvd.GetStatus() == HssUtility.General.HssStatus.Cancel) { continue; } else { existingDVD = dvd; break; } } } return(existingDVD); }
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 Dividend ApproveXBRL2_UpdateDividend(XBRL_event_info xei, Dividend existing_dvd, Security sec) { if (existing_dvd == null || xei == null) { return(null); } existing_dvd.Init_from_XBRL(xei, sec); existing_dvd.LastModifiedBy.Value = "StevenXBRL-" + Utility.CurrentUser; bool f1 = existing_dvd.Update_to_DB(DividendTable_option.Dividend_Control, false); bool f2 = existing_dvd.Update_to_DB(DividendTable_option.Dividend_Control_Approved, true); return(existing_dvd); }
private DataTable Get_field_DT(XBRL_event_info xei) { DataTable field_dt = new DataTable("Fields"); field_dt.Columns.Add("ID", typeof(int)); field_dt.Columns.Add("XBRL Element"); field_dt.Columns.Add("DRWIN Field Name"); field_dt.Columns.Add("Value"); if (xei == null) { return(field_dt); } int id = this.id_SavedfilesRcvd; field_dt.Rows.Add(id, "UnderlyingSecurityIssuerCountryofIncorporation", "ISO2CntryCode", xei.ISO2CntryCode); field_dt.Rows.Add(id, "InstrumentIdentifier", "CUSIP", xei.CUSIP); field_dt.Rows.Add(id, "InstrumentIdentifier", "ISIN", xei.ISIN); field_dt.Rows.Add(id, "DepositoryReceiptSponsorIndicator", "Sponsored", xei.Sponsored); field_dt.Rows.Add(id, "PaymentDate", "PayDate_ADR", xei.PayDate_ADR); field_dt.Rows.Add(id, "OrdExDividendDate", "ExDate", xei.ExDate); field_dt.Rows.Add(id, "OrdPaymentDate", "PayDate_ORD", xei.PayDate_ORD); field_dt.Rows.Add(id, "RecordDate", "RecordDate_ADR", xei.RecordDate_ADR); field_dt.Rows.Add(id, "OrdRecordDate", "RecordDate_ORD", xei.RecordDate_ORD); field_dt.Rows.Add(id, "ADRBase", "ADR_Ratio_ADR", xei.ADR_Ratio_ADR); field_dt.Rows.Add(id, "OrdinaryShare", "ADR_Ratio_ORD", xei.ADR_Ratio_ORD); field_dt.Rows.Add(id, "ForeignExchangeConversionRateForADRPayment", "FXrate_foreign_to_US", xei.FXrate_foreign_to_US); field_dt.Rows.Add(id, "ForeignExchangeConversionRateForADRPayment", "FXrate_US_to_foreign", xei.FXrate_US_to_foreign); field_dt.Rows.Add(id, "EventCompleteness", "EventCompleteness", xei.EventCompleteness); field_dt.Rows.Add(id, "WithholdingTaxPercentage", "StatutoryRate", xei.StatutoryRate); field_dt.Rows.Add(id, "OrdinaryGrossDividendPayoutRate", "DivGrossAmount_ORD", xei.DivGrossAmount_ORD); field_dt.Rows.Add(id, "TradingSymbol", "TickerSymbol", xei.TickerSymbol); field_dt.Rows.Add(id, "SecurityDescription", "Issue", xei.Issue); field_dt.Rows.Add(id, "OrdinaryGrossDividendPayoutRate", "PaidCurrency_ORD", xei.PaidCurrency_ORD); field_dt.Rows.Add(id, "FirstFilerFlag", "IsFirstFiler", xei.IsFirstFiler); field_dt.Rows.Add(id, "DepositaryName", "depoName", xei.depoName); field_dt.Rows.Add(id, "EventType", "EventType", xei.EventType); field_dt.Rows.Add(id, "identifier", "Sender", xei.Sender); field_dt.Rows.Add(id, "UniqueUniversalEventIdentifier", "XBRL_ReferenceNumber", xei.XBRL_ReferenceNumber); field_dt.Rows.Add(id, "AnnouncementType", "AnnouncementType", xei.AnnouncementType); field_dt.Rows.Add(id, "AnnouncementIdentifier", "AnnouncementIdentifier", xei.AnnouncementIdentifier); field_dt.Rows.Add(id, "AnnouncementDate", "AnnouncementDate", xei.AnnouncementDate); field_dt.Rows.Add(id, "EventCompleteness", "EventCompleteness", xei.EventCompleteness); return(field_dt); }
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 void Init_from_info(XBRL_event_info xei) { if (string.IsNullOrEmpty(xei.depoName)) { this.DepositaryName.Value = xei.Sender; } else { this.DepositaryName.Value = xei.depoName; } this.cusip.Value = xei.CUSIP; this.DepositoryReceiptSponsorIndicator.Value = xei.Sponsored; this.UnderlyingSecurityIssuerCountryofIncorporation.Value = xei.ISO2CntryCode; this.RecordDate.Value = xei.RecordDate_ADR; this.UniqueUniversalEventIdentifier.Value = xei.XBRL_ReferenceNumber; this.AnnouncementDate.Value = xei.AnnouncementDate; this.AnnouncementType.Value = xei.AnnouncementType; this.EventCompleteness.Value = xei.EventCompleteness; }
/// <summary> /// Get all info from XBRL into a dataSet to show on Grid /// </summary> public DataSet Get_XBRLinfo_DS() { DataSet ds = new DataSet(); DataTable main_dt = this.Get_main_DT(); ds.Tables.Add(main_dt); XBRL_event_info xei = new XBRL_event_info(this.XBRLobj); DataTable field_dt = this.Get_field_DT(xei); ds.Tables.Add(field_dt); DataTable fee_dt = this.Get_fee_DT(xei); ds.Tables.Add(fee_dt); ds.Relations.Add(main_dt.Columns["ID"], field_dt.Columns["ID"]); ds.Relations.Add(main_dt.Columns["ID"], fee_dt.Columns["ID"]); return(ds); }
public static Dividend ApproveXBRL(int xbrl_id) { XBRL_SavedFile xsf = Helper_XBRL_approval.ApproveXBRL0_get_xsFile(xbrl_id); XBRL_event_info xei = new XBRL_event_info(xsf.XBRLobj); Security sec = SecurityMaster.XBRL_Create_or_Get_Security(xei, true); if (sec == null) { MessageBox.Show("Helper_XBRL error 0: no Security info in either XBRL or Security Master"); return(null); } Dividend existing_dvd = Helper_XBRL_approval.ApproveXBRL0_find_existingDividend(xei); if (xei.IsCancellation_flag) { return(Helper_XBRL_approval.ApproveXBRL1_cancellation_XBRL(existing_dvd, xsf)); } Action next_step = XBRL_event_matrix.ApproveXBRL_action(xei, existing_dvd); Dividend approved_dvd = null; if (next_step == Action.Create_New_Event) { approved_dvd = Helper_XBRL_approval.ApproveXBRL2_CreateNewDividend(xei, sec); Helper_XBRL_approval.ApproveXBRL4_InsertDvdXBRL(xei, approved_dvd); if (approved_dvd != null) { if (existing_dvd == null) { MessageBox.Show("New Dividend " + approved_dvd.DividendIndex + " created"); } else { MessageBox.Show("Another Dividend " + approved_dvd.DividendIndex + " created with existing Dividend " + existing_dvd.DividendIndex); } } } else if (next_step == Action.Update_Existing_event) { approved_dvd = Helper_XBRL_approval.ApproveXBRL2_UpdateDividend(xei, existing_dvd, sec); Helper_XBRL_approval.ApproveXBRL4_InsertDvdXBRL(xei, approved_dvd); if (approved_dvd != null) { MessageBox.Show("Existing Dividend " + approved_dvd.DividendIndex + " is updated"); } } else if (next_step == Action.Add_Ref_to_Current) { approved_dvd = Helper_XBRL_approval.ApproveXBRL4_InsertDvdXBRL(xei, existing_dvd); if (approved_dvd != null) { MessageBox.Show("XBRL ref# is added to existing Dividend " + approved_dvd.DividendIndex); } } if (approved_dvd != null)//Mark [XBRL_SavedFile] as approved { xsf.processState.Value = 1; xsf.DividendIndex.Value = approved_dvd.DividendIndex; xsf.Update_to_DB();/*Commented out for testing by Steven if needed*/ } return(approved_dvd); }
public static Action ApproveXBRL_action(XBRL_event_info xei, Dividend existing_dvd) { if (xei == null) { return(Action.None); } if (existing_dvd == null) { return(Action.Create_New_Event); } bool diffRef_sameDepo_flag = XBRL_event_matrix.DifferentRef_from_sameDepo(xei, existing_dvd); if (diffRef_sameDepo_flag) { return(Action.Create_New_Event); } if (xei.IsCompleteEvent_flag) { if (existing_dvd.IsCompleteEvent_flag) { if (xei.Sponsored) { return(Action.Update_Existing_event); } else //Unsponsored XBRL { if (xei.IsFirstFiler) { return(Action.Update_Existing_event); } else { return(Action.Add_Ref_to_Current); } } } else //In-complete Existing Event { return(Action.Update_Existing_event); } } else // In-complete XBRL { if (existing_dvd.IsCompleteEvent_flag) { return(Action.Add_Ref_to_Current); } else //In-complete Existing Event { if (xei.Sponsored) { return(Action.Update_Existing_event); } else //Unsponsored XBRL { if (xei.IsFirstFiler) { return(Action.Update_Existing_event); } else { return(Action.Add_Ref_to_Current); } } } } }