Example #1
0
 protected void ReloadDealInfos(DealInfoDealType deal_type, crmContractDeal deal, crmPaymentPlan plan)
 {
     foreach (crmPaymentUnit unit in plan.PaymentUnits)
     {
         ReloadDealInfos(deal_type, deal, DealInfoNomType.DEAL_INFO_PAYMENT, unit, new ListConverter <crmObligation, crmPaymentItem>(unit.PaymentItems));
     }
 }
Example #2
0
 protected void ReloadDealInfos(DealInfoDealType deal_type, crmContractDeal deal, DealInfoNomType nom_type, crmObligationUnit unit, IList <crmObligation> items)
 {
     foreach (crmObligation obl in items)
     {
         var deal_info = _DealInfos.FirstOrDefault(
             x => x.Deal == deal &&
             x.DealType == deal_type &&
             x.NomType == nom_type &&
             x.Order == obl.Order &&
             x.Valuta == obl.Valuta &&
             x.Date == unit.DatePlane
             );
         if (deal_info == null)
         {
             deal_info = new DealInfo(this.Session)
             {
                 DealType = deal_type,
                 Deal     = deal,
                 NomType  = nom_type,
                 Subject  = obl.Order != null ? obl.Order.Subject : null,
                 Order    = obl.Order,
                 Valuta   = obl.Valuta,
                 Date     = unit.DatePlane
             };
             _DealInfos.Add(deal_info);
         }
         deal_info.SummCost += obl.SummCost;
         deal_info.SummVat  += obl.SummNDS;
         deal_info.SummFull += obl.SummFull;
     }
 }
Example #3
0
 protected void ReloadDealInfos(DealInfoDealType deal_type, crmContractDeal deal, crmDeliveryPlan plan)
 {
     foreach (crmDeliveryUnit unit in plan.DeliveryUnits)
     {
         ReloadDealInfos(deal_type, deal, DealInfoNomType.DEAL_INFO_DELIVERY, unit, new ListConverter <crmObligation, crmDeliveryItem>(unit.DeliveryItems));
     }
 }
Example #4
0
        public static IList <crmContractDeal> GetDeals2(TrwSubject trw_subj, DealInfoDealType deal_type, TrwSubjectImportDealParameters parms)
        {
            IDictionary <crmContractDeal, Decimal> dict = new Dictionary <crmContractDeal, Decimal>();

            foreach (fmCSubject subj in trw_subj.Subjects)
            {
                foreach (fmCSubject.DealInfo info in subj.DealInfos)
                {
                    if (info.DealType != deal_type ||
                        info.Subject != trw_subj.Subject ||
                        info.Year != trw_subj.Period.Year ||
                        info.NomType != DealInfoNomType.DEAL_INFO_DELIVERY)
                    {
                        continue;
                    }
                    if (dict.ContainsKey(info.Deal))
                    {
                        dict[info.Deal] += info.DeliverySummCost;
                    }
                    else
                    {
                        dict[info.Deal] = info.DeliverySummCost;
                    }
                }
            }
            return(new List <crmContractDeal>(dict.Keys));
        }
Example #5
0
 //        protected void ReloadDealInfos(DealInfoDealType deal_type, crmDealWithStage deal) {
 protected void ReloadDealInfos(DealInfoDealType deal_type, crmContractDeal deal)
 {
     foreach (crmStage stage in deal.Current.StageStructure.Stages)
     {
         ReloadDealInfos(deal_type, deal, stage.DeliveryPlan);
         ReloadDealInfos(deal_type, deal, stage.PaymentPlan);
     }
 }
Example #6
0
        public static IList <crmContractDeal> GetDeals(TrwSubject trw_subj, DealInfoDealType deal_type, TrwSubjectImportDealParameters parms)
        {
            IDictionary <crmContractDeal, Decimal> dict = new Dictionary <crmContractDeal, Decimal>();

            foreach (fmCSubject subj in trw_subj.Subjects)
            {
                foreach (fmCSubject.DealInfo info in subj.DealInfos)
                {
                    if (info.DealType != deal_type ||
                        info.Subject != trw_subj.Subject ||
                        info.Year != trw_subj.Period.Year ||
                        info.NomType != DealInfoNomType.DEAL_INFO_DELIVERY)
                    {
                        continue;
                    }
                    if (dict.ContainsKey(info.Deal))
                    {
                        dict[info.Deal] += info.DeliverySummCost;
                    }
                    else
                    {
                        dict[info.Deal] = info.DeliverySummCost;
                    }
                }
            }
            IOrderedEnumerable <crmContractDeal> deals = dict.Keys.OrderBy(x => - dict[x]);
            IList <crmContractDeal> result             = new List <crmContractDeal>(parms.MaxCount);
            Decimal all_summ      = dict.Values.Sum();
            Decimal current_summ  = 0;
            Int32   current_count = 0;

            foreach (crmContractDeal deal in deals)
            {
                current_summ += dict[deal];
                current_count++;
                result.Add(deal);
                if (parms.MaxCount > 0 && current_count >= parms.MaxCount)
                {
                    break;
                }
                if (parms.VolumePercent > 0 && current_summ / all_summ >= parms.VolumePercent)
                {
                    break;
                }
            }
            return(result);
        }
Example #7
0
 protected void ReloadDealInfos(DealInfoDealType deal_type, crmDealWithoutStage deal)
 {
     ReloadDealInfos(deal_type, deal, ((crmDealWithoutStageVersion)deal.Current).DeliveryPlan);
     ReloadDealInfos(deal_type, deal, ((crmDealWithoutStageVersion)deal.Current).PaymentPlan);
 }