private CreditSlipSpecification FillCreditSlipSpecification(PlanReceiptOrderPersonalAccount x, CreditSlip creditSlip) { var tax = _repositoryTax.Specify().Where(a => a.TaxBand == x.PlaneCertificate.TaxBand).Future().First().Value; var planCertificate = x.PlaneCertificate; var creditSlipSpecification = new CreditSlipSpecification { CreditSlip = creditSlip, NomenclatureNumberModification = planCertificate.ModificationNomenclature, TaxBand = planCertificate.TaxBand, PLANQUANT = (decimal)x.CountByDocument, FACTQUANT = (decimal)x.CountFact, //тут надо смотреть основную единицу измерения и пересчитавать PLANQUANTALT = 0, FACTQUANTALT = 0, Price = (decimal)planCertificate.Price, PRICEMEAS = false, PRICECALCRULE = true, ACCPRICE = (decimal)planCertificate.Price, ACCPRICEMEAS = false, ACCSUMM = CreditSlipDomainAlgorithmsOfCalculation.SumWithoutNDS((decimal)x.CountFact, (decimal)planCertificate.Price), PLANSUM = CreditSlipDomainAlgorithmsOfCalculation.SumWithoutNDS((decimal)x.CountByDocument, (decimal)planCertificate.Price), PLANSUMTAX = CreditSlipDomainAlgorithmsOfCalculation.SumWithNDS((decimal)x.CountByDocument, (decimal)planCertificate.Price, tax), PLANSUMNDS = CreditSlipDomainAlgorithmsOfCalculation.SumNDS((decimal)x.CountByDocument, (decimal)planCertificate.Price, tax), FACTSUM = CreditSlipDomainAlgorithmsOfCalculation.SumWithoutNDS((decimal)x.CountFact, (decimal)planCertificate.Price), FACTSUMTAX = CreditSlipDomainAlgorithmsOfCalculation.SumWithNDS((decimal)x.CountFact, (decimal)planCertificate.Price, tax), FACTSUMNDS = CreditSlipDomainAlgorithmsOfCalculation.SumNDS((decimal)x.CountFact, (decimal)planCertificate.Price, tax), AUTOCALCSIGN = true, SerNumb = planCertificate.CertificateQuality.Cast }; creditSlip.CreditSlipSpecifications.Add(creditSlipSpecification); return(creditSlipSpecification); }
private void Remove() { if (!RemoveEntities.Any()) { return; } var rnCertificateQualities = RemoveEntities.Select(x => x.PlaneCertificate.CertificateQuality.Rn).Distinct().ToArray(); var rnDoclinks = _repositoryLink.Specify() .IsInEmpty(x => x.InDocument, rnCertificateQualities) .And(x => x.InUnitCode == NamesOfSectionSystem.CertificateQuality) .And(x => x.OutUnitCode == NamesOfSectionSystem.CreditSlipSpecification) .Select(x => x.OutDocument) .Future <long>(); var creditSlipSpecs = _repositoryCreditSlipSpecs.Specify() .IsInEmpty(x => x.Rn, rnDoclinks.ToArray()) .Future <CreditSlipSpecification>(); creditSlipSpecs.DoForEach( creditSlipSpec => creditSlipSpec.CreditSlip.CreditSlipSpecifications.Remove(creditSlipSpec)); var creditSlips = creditSlipSpecs.Select(x => x.CreditSlip); creditSlips.DoForEach( creditSlip => { if (creditSlip.CreditSlipSpecifications.Any()) { _repositoryCreditSlip.Update(creditSlip); } else { _repositoryCreditSlip.Delete(creditSlip); } }); }