Exemplo n.º 1
0
        private void XBRL_button_Click(object sender, EventArgs e)
        {
            int            id_savedFile = (int)this.XBRL_numericUpDown.Value;
            XBRL_SavedFile sf           = new XBRL_SavedFile(id_savedFile);

            sf.Init_from_DB(false);

            XBRL_event_info xei = new XBRL_event_info(sf.savedfile);
            Security        sec = SecurityMaster.XBRL_Create_or_Get_Security(xei, false);
            Dividend        dvd = new Dividend();

            dvd.Init_from_XBRL(xei, sec);
            dvd.PrintAllAttributeValues();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deal with StatutoryRate and DTC Position Model number
        /// </summary>
        private void XBRL_StatRate_DTCposModel(XBRL_event_info xei)
        {
            //Get Statutory Rate
            StatutoryRate_edi rt = RateMaster_edi.GetRate_from_country(this.ISO2CntryCode.Value, this.RecordDate_ADR.Value);

            if (rt != null)
            {
                this.StatutoryRate.Value = rt.statry_rt.Value;
            }

            //Get DTC position model number
            DTC_Model.DTCPositionModelNumber_Mapping dm =
                DTC_Model.DTC_model_master.GetMapping_country(this.Country.Value, this.Issue.Value, this.RecordDate_ADR.Value, this.SecurityTypeID.Value);
            if (dm != null)
            {
                this.DTCPosition_ModelNumber.Value = dm.ModelNumber.Value;
            }

            //Get amounts based on Statutary Rate
            if (xei != null && xei.fee_list.Count > 0)
            {
                FeeInfo WHrate_fi = xei.fee_list[0];
                foreach (FeeInfo fi in xei.fee_list)
                {
                    if (fi.WithholdingTaxPercentage == this.StatutoryRate.Value)
                    {
                        WHrate_fi = fi;
                        break;
                    }
                }

                this.DivNetAmount_ADR.Value = WHrate_fi.PayoutAmountNetOfTax;

                if (xei.IsCompleteEvent_flag)
                {
                    this.FinalDivGrossAmount_ADR.Value = WHrate_fi.PayoutAmount;
                }
                else
                {
                    this.ApproxDivGrossAmount_ADR.Value = WHrate_fi.PayoutAmount;
                }
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        /*---------------------------------------XBRL----------------------------------------------------*/
        /// <summary>
        /// Create new Security or Get existing Security from DB
        /// </summary>
        /// <param name="xbrl">XML</param>
        /// <param name="autoSaveNew_flag">If automatically save new security to DB</param>
        /// <returns></returns>
        public static Security XBRL_Create_or_Get_Security(XBRL_event_info xei, bool autoSaveNew_flag)
        {
            if (xei == null)
            {
                return(null);
            }

            Security existing_sec = SecurityMaster.GetSecurity_cusip(xei.CUSIP, xei.RecordDate_ADR);
            Security xbrl_sec     = SecurityMaster.CreateSecurity_fromXBRL(xei);

            if (existing_sec == null)
            {
                if (xbrl_sec == null)
                {
                    return(null);
                }
                else
                {
                    xbrl_sec.EffectiveDate.Value = Utility.MinDate;
                    if (autoSaveNew_flag)
                    {
                        if (xbrl_sec.Country.IsValueEmpty)
                        {
                            xbrl_sec.Country.Value = SecurityMaster.InputAttr_FromUI(xbrl_sec, "Country");
                        }
                        if (xbrl_sec.Country.IsValueEmpty)
                        {
                            return(null);
                        }
                        else
                        {
                            xbrl_sec.Insert_to_DB();
                        }
                    }
                    return(xbrl_sec);
                }
            }
            else
            {
                if (xbrl_sec == null)
                {
                    return(existing_sec);
                }
                else
                {
                    if (SecurityMaster.XBRL_isSameSecurity(existing_sec, xbrl_sec))
                    {
                        return(existing_sec);
                    }
                    else
                    {
                        xbrl_sec.EffectiveDate.Value = xei.RecordDate_ADR;
                        if (xbrl_sec.TickerSymbol.IsValueEmpty)
                        {
                            xbrl_sec.TickerSymbol.Value = existing_sec.TickerSymbol.Value;
                        }
                        if (xbrl_sec.ISIN.IsValueEmpty)
                        {
                            xbrl_sec.ISIN.Value = existing_sec.ISIN.Value;
                        }

                        if (autoSaveNew_flag)
                        {
                            string newSec_info      = "New: " + xbrl_sec.GetInfo_str();
                            string existingSec_info = "Old: " + existing_sec.GetInfo_str();

                            MessageBox.Show("New Security is created!!" + HssStr.WinNextLine + newSec_info + HssStr.WinNextLine + existingSec_info);
                            xbrl_sec.Insert_to_DB();
                        }

                        return(xbrl_sec);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void Init_from_XBRL(XBRL_event_info xei, Security sec)
        {
            if (xei == null || sec == null)
            {
                return;
            }

            this.XBRL_from_Security(sec);

            if (this.ISO2CntryCode.IsValueEmpty)
            {
                this.ISO2CntryCode.Value = xei.ISO2CntryCode;
            }
            if (!string.IsNullOrEmpty(xei.EventCompleteness))
            {
                this.PlaceOfSafekeeping.Value = xei.EventCompleteness;
            }

            if (xei.PayDate_ADR > Utility.MinDate)
            {
                this.PayDate_ADR.Value = xei.PayDate_ADR;
            }
            if (xei.ExDate > Utility.MinDate)
            {
                this.ExDate.Value = xei.ExDate;
            }
            if (xei.PayDate_ORD > Utility.MinDate)
            {
                this.PayDate_ORD.Value = xei.PayDate_ORD;
            }
            if (xei.RecordDate_ADR > Utility.MinDate)
            {
                this.RecordDate_ADR.Value = xei.RecordDate_ADR;
            }
            if (xei.RecordDate_ORD > Utility.MinDate)
            {
                this.RecordDate_ORD.Value = xei.RecordDate_ORD;
            }

            if (xei.FXrate_US_to_foreign > 0)
            {
                if (xei.IsCompleteEvent_flag)
                {
                    this.FinalFXRate.Value = xei.FXrate_US_to_foreign;
                }
                else
                {
                    this.ApproximateFXRate.Value = xei.FXrate_US_to_foreign;
                }
            }

            if (xei.IsCompleteEvent_flag)
            {
                this.FinalDivGrossAmount_ORD.Value = xei.DivGrossAmount_ORD;
            }
            else
            {
                this.ApproxDivGrossAmount_ORD.Value = xei.DivGrossAmount_ORD;
            }

            if (!string.IsNullOrEmpty(xei.PaidCurrency_ORD))
            {
                this.PaidCurrency_ORD.Value = xei.PaidCurrency_ORD;
            }
            this.PaidCurrency.Value = "USD";
            this.EventType.Value    = xei.EventType;

            this.XBRL_StatuteOfLimitation(xei.RecordDate_ADR);
            this.XBRL_StatRate_DTCposModel(xei);
            this.XBRL_CtyProType();
            this.XBRL_fees_DSC();
        }