// protected void Load(IObjectSpace os, TrwSubjectDealSale trw_deal_sale, IDictionary <TrwBudgetKey, IList <TrwBudgetValue> > keys) { LineKey key = new LineKey(); key.TrwSubject = trw_deal_sale.TrwSubject; // This property set from trw_deal_sale // key.Subject = trw_deal_sale.Subject; key.Deal = trw_deal_sale.Deal; key.Party = key.Deal.Customer; if (trw_deal_sale.DealBudget != null) { key.TrwContract = trw_deal_sale.DealBudget; } if (key.Deal != null) { key.TrwOrder = key.Subject.TrwOrders.FirstOrDefault(x => x.Deal == key.Deal); Load(os, key.Deal, key, keys); } }
private static void LoadTrwSubject(TrwBudgetPeriodDocDeal doc, IObjectSpace os, Dictionary <fmCOrder, OrderValue> rsp, TrwSubject trw_subj) { TrwSubjectDealSale other_sale = trw_subj.DealsSale.FirstOrDefault(x => x.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER); TrwSubjectDealBay other_bay = trw_subj.DealsBay.FirstOrDefault(x => x.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER); foreach (fmCSubject fm_subj in trw_subj.Subjects) { foreach (fmCOrder fm_order in fm_subj.Orders) { rsp[fm_order] = new OrderValue(); rsp[fm_order].Order = fm_order; foreach (TrwSubjectDealBay trw_deal_bay in trw_subj.DealsBay) { TrwBudgetPeriodDocDeal.LineDeal line_deal = os.CreateObject <TrwBudgetPeriodDocDeal.LineDeal>(); line_deal.TrwSubjectDealBay = trw_deal_bay; rsp[fm_order].DealLines.Add(line_deal); doc.DocDealLines.Add(line_deal); if (trw_deal_bay.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER) { rsp[fm_order].OtherBayDealLine = line_deal; } } // rsp[fm_order].OtherSaleDeal = other_sale; // rsp[fm_order].OtherBayDeal = other_bay; } foreach (var deal_info in fm_subj.DealInfos) { if (deal_info.Order == null || deal_info.Subject != fm_subj) { continue; } if (deal_info.DealType == DealInfoDealType.DEAL_INFO_PROCEEDS) { } else if (deal_info.DealType == DealInfoDealType.DEAL_INFO_EXPENDITURE && deal_info.NomType == DealInfoNomType.DEAL_INFO_DELIVERY) { //if (!rsp.ContainsKey(deal_info.Order)) { // rsp[deal_info.Order] = new OrderValue(); // rsp[deal_info.Order].Order = deal_info.Order; //} TrwSubjectDealBay deal_bay = CheckDealBase <TrwSubjectDealBay>(trw_subj.DealsBay, deal_info.Deal); TrwBudgetPeriodDocDeal.LineDeal line_deal = rsp[deal_info.Order].DealLines.FirstOrDefault(x => x.TrwSubjectDealBay == deal_bay); //if (line_deal == null) { // line_deal = os.CreateObject<TrwBudgetPeriodDocDeal.LineDeal>(); // line_deal.TrwSubjectDealBay = deal_bay; // rsp[deal_info.Order].DealLines.Add(line_deal); // doc.DocDealLines.Add(line_deal); //} if (deal_info.Year == doc.Period.Year) { line_deal[deal_info.Month] += Decimal.Round(CheckSumm(doc.Period, deal_info.Valuta, deal_info.SummCost), 2); } else if (deal_info.Year > doc.Period.Year) { line_deal[13] += deal_info.SummCost; } else if (deal_info.Year < doc.Period.Year) { line_deal[0] += deal_info.SummCost; } } } } }