コード例 #1
0
        private void FillRelationshipBetweenDocuments(long inDocument, long outDocument)
        {
            var documentLink = new RelationshipBetweenDocuments
            {
                InDocument  = inDocument,
                OutDocument = outDocument,
                InUnitCode  = NamesOfSectionSystem.CertificateQuality,
                OutUnitCode = NamesOfSectionSystem.CreditSlipSpecification
            };

            _repositoryLink.Insert(documentLink);
        }
コード例 #2
0
        // Установка связи между Сертификатом качества и Разрешением на условный допуск
        public void SetDocumentLinks(long rnCertificateQuality, long rnPermissionMaterial)
        {
            var repositoryDocumentLinks = _repositoryFactory.Create <RelationshipBetweenDocuments>();

            var documentLink = new RelationshipBetweenDocuments
            {
                InDocument  = rnCertificateQuality,
                OutDocument = rnPermissionMaterial,
                InUnitCode  = NamesOfSectionSystem.CertificateQuality,
                OutUnitCode = NamesOfSectionSystem.PermissionMaterial
            };

            repositoryDocumentLinks.Insert(documentLink);
        }
コード例 #3
0
        public ActSelectionOfProbeDto AddActSelectionOfProbe(long certificateQualite)
        {
            var repositoryLink = RepositoryFactory.Create <RelationshipBetweenDocuments>();
            var entity         = new ActSelectionOfProbe {
                Catalog = new Catalog(1210980309)
            };
            var actSelectionOfProbe = AddEntity <ActSelectionOfProbe, ActSelectionOfProbeDto>(entity);

            var documentLink = new RelationshipBetweenDocuments
            {
                InDocument  = certificateQualite,
                OutDocument = actSelectionOfProbe.Rn,
                InUnitCode  = NamesOfSectionSystem.CertificateQuality,
                OutUnitCode = NamesOfSectionSystem.ActSelectionOfProbe
            };

            repositoryLink.Insert(documentLink);
            return(actSelectionOfProbe);
        }
コード例 #4
0
        public long TakeMaterial(
            decimal quantity,
            DateTime dateOfBook,
            string numberOfBook,
            StoreGasStationOilDepot storeGasStationOilDepot,
            long certificateQualityUid,
            EmployeeDto controller,
            EmployeeDto customer)
        {
            var repositoryCertificateQuality          = _repositoryFactory.Create <CertificateQuality>();
            var repositoryExpInvoice                  = _repositoryFactory.Create <ExpenditureInvoice>();
            var repositoryDocumentLinks               = _repositoryFactory.Create <RelationshipBetweenDocuments>();
            var repositoryWarehouseQualityCertificate = _repositoryFactory.Create <WarehouseQualityCertificate>();
            var repositoryCreditSlipSpecs             = _repositoryFactory.Create <CreditSlipSpecification>();
            var repositoryGoodsSupply                 = _repositoryFactory.Create <GoodsSupply>();

            var certificateQuality = repositoryCertificateQuality.Get(certificateQualityUid);
            var doclinksUid        =
                repositoryDocumentLinks.Specify()
                .Where(x => x.InDocument == certificateQuality.Rn)
                .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, doclinksUid.ToArray())
                .Future <CreditSlipSpecification>();

            var measure = creditSlipSpecs.First().NomenclatureNumberModification.NomenclatureNumber.DicmuntUmeasMain;

            var goodsSupplies =
                repositoryGoodsSupply.Specify()
                .IsInEmpty(x => x.Rn, creditSlipSpecs.Select(x => x.GOODSSUPPLY).ToArray())
                .Future <GoodsSupply>();

            var store = goodsSupplies.First().StoreGasStationOilDepot;

            var sumRest = goodsSupplies.Sum(x => x.RESTFACT);

            if (sumRest < quantity)
            {
                throw new DepartmentOrderException(
                          Resource.EIS_0.StringFormat(
                              certificateQuality.FullRepresentation,
                              certificateQuality.NomerCertificata,
                              sumRest,
                              measure.Code,
                              quantity));
            }


            var rest = quantity;
            var dictionaryGoodsSupply = new Dictionary <GoodsSupply, decimal>();

            foreach (var elem in goodsSupplies)
            {
                if (elem.RESTFACT - rest >= 0)
                {
                    dictionaryGoodsSupply.Add(elem, rest);
                    break;
                }

                if (elem.RESTFACT - rest <= 0)
                {
                    dictionaryGoodsSupply.Add(elem, elem.RESTFACT);
                    rest = rest - elem.RESTFACT;
                }
            }


            var expenditureInvoice = new ExpenditureInvoice
            {
                Catalog     = new Catalog(49528001),
                LegalPerson = new LegalPerson {
                    Rn = LegalPerson.GPO
                },
                TypeOfDocument = new TypeOfDocument {
                    Rn = TypeOfDocument.ExpenditureInvoice
                },
                Pref    = store.Number.ShortYear(),
                Docdate = DateTime.Now,
                Stoper  = new KindOfWarehouseOperations {
                    Rn = KindOfWarehouseOperations.InternalMovingExpense
                },
                Store          = store,
                ViewShipment   = 246316267,
                NameOfCurrency = new NameOfCurrency {
                    Rn = NameOfCurrency.Rub
                },
                CurCours    = 1,
                CurBase     = 1,
                SummWithnds = 0,
                InStore     = storeGasStationOilDepot,
                InCurcours  = 1,
                InCurBase   = 1,
                TypeOfDocumentValidTypeOfDocument = new TypeOfDocument {
                    Rn = 246318164
                },
                ValidDocDate = dateOfBook,
                ValidDocNumb = numberOfBook,
            };



            dictionaryGoodsSupply.DoForEach(
                x =>
            {
                var expenditureInvoiceSpecification = new ExpenditureInvoiceSpecification
                {
                    ExpenditureInvoice             = expenditureInvoice,
                    NomenclatureNumberModification = x.Key.GoodsParty.NomenclatureNumberModification,
                    Price         = 0,
                    Quantity      = x.Value,
                    QuantityAlt   = 0,
                    Coeff         = 0,
                    CoeffValSign  = 0,
                    CoeffValcSign = 1,
                    PriceMeasure  = 0,
                    SummWithNDS   = 0,
                    GoodsParty    = x.Key.GoodsParty
                };
                expenditureInvoice.ExpenditureInvoiceSpecifications.Add(expenditureInvoiceSpecification);
            });


            repositoryExpInvoice.Insert(expenditureInvoice);
            expenditureInvoice.WorkDate = DateTime.Now;
            repositoryExpInvoice.ExecuteSPUniqueResult <ExpenditureInvoice>(
                new ExpenditureInvoiceSetStateSP(
                    expenditureInvoice,
                    InvoiceForTransmissionInUnitState.WorkFact,
                    InvoiceForTransmissionInUnitInState.Yes));

            var warehouseQualityCertificate = new WarehouseQualityCertificate
            {
                ControllerQuality = new Contractor {
                    Rn = controller.Rn
                },
                Customer = new Contractor {
                    Rn = customer.Rn
                },
                //Catalog = new Catalog(1007400827),
                Catalog = new Catalog(1195988283),

                ExpenditureInvoice = expenditureInvoice
            };
            var certificateUid = (long)repositoryWarehouseQualityCertificate.Insert(warehouseQualityCertificate);

            var documentLink = new RelationshipBetweenDocuments
            {
                InDocument  = certificateQuality.Rn,
                OutDocument = warehouseQualityCertificate.Rn,
                InUnitCode  = NamesOfSectionSystem.CertificateQuality,
                OutUnitCode = NamesOfSectionSystem.WarehouseQualityCertificate
            };

            repositoryDocumentLinks.Insert(documentLink);

            return(certificateUid);
        }