public void UpdateTrwSubjects(IObjectSpace os) { foreach (TrwSubject trw_subj in os.GetObjects <TrwSubject>()) { trw_subj.Period = trw_subj.Period; trw_subj.Subjects.Clear(); trw_subj.Subjects.Add(trw_subj.Subject); // IList <TrwSubjectDealSale> deal_sales = new List <TrwSubjectDealSale>(trw_subj.DealsSale); foreach (TrwSubjectDealSale deal_sale in deal_sales) { if (deal_sale.DealBudget == null) { deal_sale.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_REAL; if (deal_sale.Deal != null) { deal_sale.CrmContractDeals.Add(deal_sale.Deal); } } else { os.Delete(deal_sale); } } TrwSubjectDealSale deal_sale_other = os.CreateObject <TrwSubjectDealSale>(); trw_subj.DealsSale.Add(deal_sale_other); deal_sale_other.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER; os.Delete(trw_subj.DealOtherSale); trw_subj.DealOtherSale = deal_sale_other.DealBudget; deal_sale_other.PersonInternal = TrwSettings.GetInstance(os).PersonOtherSale; // deal_sale_other.UpdateConsolidateDeal(true); // IList <TrwSubjectDealBay> deal_bays = new List <TrwSubjectDealBay>(trw_subj.DealsBay); foreach (TrwSubjectDealBay deal_bay in deal_bays) { if (deal_bay.DealBudget == null) { deal_bay.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_REAL; if (deal_bay.Deal != null) { deal_bay.CrmContractDeals.Add(deal_bay.Deal); } } else { os.Delete(deal_bay); } } TrwSubjectDealBay deal_bay_other = os.CreateObject <TrwSubjectDealBay>(); trw_subj.DealsBay.Add(deal_bay_other); deal_bay_other.DealType = TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER; os.Delete(trw_subj.DealOtherBay); trw_subj.DealOtherBay = deal_bay_other.DealBudget; deal_bay_other.PersonInternal = TrwSettings.GetInstance(os).PersonOtherBay; // deal_bay_other.UpdateConsolidateDeal(true); // } }
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; } } } } }