コード例 #1
0
        private void OnValidEvaluate(object sender, EvaluateInternalEventArgs evaluateInternalEventArgs)
        {
            var request = Context.Parent;

            var documentRepo = ServiceProvider.GetService <IRepository <Olma.Document> >();
            var mapper       = ServiceProvider.GetService <IMapper>();

            var query = documentRepo
                        .FindAll()
                        .AsNoTracking();

            #region convert search request

            #endregion

            #region ordering

            query = query.OrderByDescending(d => d.IssuedDateTime);

            #endregion


            var projectedQuery = query.ProjectTo <Document>(mapper.ConfigurationProvider);

            Context.DocumentPagination = projectedQuery.ToPaginationResult(request);
        }
コード例 #2
0
        private void OnValidEvaluate(object sender, EvaluateInternalEventArgs evaluateInternalEventArgs)
        {
            var bookingsRepo = ServiceProvider.GetService <IRepository <Ltms.Bookings> >();

            var query = bookingsRepo.FindAll().Where(b =>
                                                     !b.DeleteTime.HasValue && b.BookingTypeId != "POOL" && b.BookingTypeId != "STORNO").AsNoTracking();
            var mapper = ServiceProvider.GetService <IMapper>();

            var accountingRecords = query.ProjectTo <IEnumerable <AccountingRecord> >(mapper.ConfigurationProvider);

            var _context = ServiceProvider.GetService <Dal.OlmaDbContext>();

            var _ltmsReferenceLookupService = ServiceProvider.GetService <ILtmsReferenceLookupService>();
            var authData = ServiceProvider.GetService <IAuthorizationDataService>();
            AccountingRecordsSearchRequest request = Context.Parent.Parent;

            var isDplEmployee     = authData.GetUserRole() == UserRole.DplEmployee;
            var postingAccountIds = authData.GetPostingAccountIds().ToArray();
            var accountIds        = _ltmsReferenceLookupService.GetLtmsAccountIds(postingAccountIds).Select(i => i.Value);

            var ltmsPalletInfos = _ltmsReferenceLookupService
                                  .GetLtmsPalletInfos();

            // Using SQL is neccessary as efcore does not support full outer joins
            // We could move this into a view but right now this is the only place where it is needed
            IQueryable <LtmsAccoutingRecord> queryOld = _context.LtmsAccoutingRecords.FromSqlRaw(@"
SELECT
	CASE WHEN B.Id is not null THEN 'B' + CAST(B.Id AS VARCHAR(50)) ELSE 'P' + CAST(PR.Id AS VARCHAR(50)) END AS Id,
	B.Id as BookingId,
	PR.Id as PostingRequestId
FROM LTMS.Bookings B
FULL OUTER JOIN dbo.PostingRequests PR on B.RowGuid = PR.RowGuid and PR.Status <> 1
WHERE B.DeleteTime IS NULL AND B.BookingType_ID != 'POOL' AND B.BookingType_ID != 'STORNO' AND (B.Account_ID IN (" +
                                                                                                 string.Join(",", accountIds.Select(n => n.ToString()).ToArray()) +
                                                                                                 "))") //TODO: add isDplEmployee -statement
                                                        .Include(i => i.Booking).ThenInclude(i => i.Transaction).ThenInclude(i => i.Process)
                                                        .Include(i => i.Booking).ThenInclude(i => i.ReportBookings).ThenInclude(i => i.Report)
                                                        .Include(i => i.Booking).ThenInclude(i => i.OlmaPostingAccount)
                                                        .Include(i => i.PostingRequest).ThenInclude(i => i.DplNote)
                                                        .IgnoreQueryFilters()
                                                        //.Where(i => i.Booking == null || (i.Booking.DeleteTime == null &&( isDplEmployee || accountIds.Contains(i.Booking.AccountId))))
                                                        .Where(i => i.PostingRequest == null || (isDplEmployee ||
                                                                                                 (postingAccountIds.Contains(i.PostingRequest
                                                                                                                             .PostingAccountId) ||
                                                                                                  accountIds.Contains(
                                                                                                      i.PostingRequest.SourceRefLtmsAccountId) ||
                                                                                                  accountIds.Contains(i.PostingRequest
                                                                                                                      .DestinationRefLtmsAccountId))))
            ;


            var queryCount = queryOld.Count();


            Context.AccountingRecordPaginationResult = null;
        }
コード例 #3
0
        // Main BL
        private void OnValidEvaluate(object sender, EvaluateInternalEventArgs evaluateInternalEventArgs)
        {
            var ltmsBookingsRepo           = ServiceProvider.GetService <IRepository <Ltms.Bookings> >();
            var ltmsReferenceLookupService = ServiceProvider.GetService <ILtmsReferenceLookupService>();

            var booking = ltmsBookingsRepo.FindAll()
                          .Include(i => i.Transaction)
                          .Include(i => i.ReportBookings).ThenInclude(r => r.Report)
                          .AsNoTracking()
                          .SingleOrDefault();

            if (booking == null)
            {
                throw new Exception("There is no Booking");
            }

            var mapper = ServiceProvider.GetService <IMapper>();

            var record = mapper.Map <AccountingRecord>(booking);

            #region Map Cross DB properties

            var accountMap = ltmsReferenceLookupService.GetOlmaPostingAccountIds(new[] { booking.AccountId });

            var articleAndQuality = Tuple.Create(booking.ArticleId, booking.QualityId);
            var loadCarrierMap    = ltmsReferenceLookupService.GetOlmaLoadCarrierIds(new[] { articleAndQuality });

            record.PostingAccountId = accountMap[booking.AccountId];
            record.LoadCarrierId    = loadCarrierMap[articleAndQuality];

            #endregion

            Context.AccountingRecord = record;

            AddMessage(Context.AccountingRecord == null, ResourceName, Message);
        }
コード例 #4
0
        private void OnValidEvaluate(object sender, EvaluateInternalEventArgs evaluateInternalEventArgs)
        {
            var mapper  = ServiceProvider.GetService <IMapper>();
            var request = Context.Request;

            var documentTypesService  = ServiceProvider.GetService <IDocumentTypesService>();
            var expressCodeRepository = ServiceProvider.GetService <IRepository <Olma.ExpressCode> >();
            var dbContext             = ServiceProvider.GetService <Dal.OlmaDbContext>();
            var orderLoadRepository   = ServiceProvider.GetService <IRepository <Olma.OrderLoad> >();

            var documentType = DocumentTypeEnum.LoadCarrierReceiptExchange;

            switch (request.Type)
            {
            case LoadCarrierReceiptType.Delivery:
                documentType = DocumentTypeEnum.LoadCarrierReceiptDelivery;
                break;

            case LoadCarrierReceiptType.Pickup:
                documentType = DocumentTypeEnum.LoadCarrierReceiptPickup;
                break;

            case LoadCarrierReceiptType.Exchange:
                documentType = DocumentTypeEnum.LoadCarrierReceiptExchange;
                break;
            }

            Context.DocumentType       = documentType;
            Context.LoadCarrierReceipt = mapper.Map <Olma.LoadCarrierReceipt>(Context.Request);

            var typeId = documentTypesService.GetIdByDocumentType(documentType);

            Context.LoadCarrierReceipt.Document = new Olma.Document()
            {
                Number             = null, // assign by action
                TypeId             = typeId,
                StateId            = 1,
                CustomerDivisionId = request.CustomerDivisionId,
                IssuedDateTime     = DateTime.UtcNow,
                LanguageId         = request.PrintLanguageId,
            };
            Context.LoadCarrierReceipt.PostingAccountId = Context.CustomerDivision.PostingAccountId;
            Context.IsSupply = request.Type == LoadCarrierReceiptType.Pickup;
            Context.LoadCarrierReceipt.Trigger = LoadCarrierReceiptTrigger.Manual;

            Context.TargetRefLtmsAccountId = 12321; // Konto unbekannt

            if (Context.LoadCarrierReceipt.DigitalCode == null)
            {
                if (dbContext != null)
                {
                    Context.TargetRefLtmsAccountId = dbContext.PostingAccounts
                                                     .Where(i => i.Id == request.TargetPostingAccountId)
                                                     // TODO SECURE usage fo ignore query filters
                                                     .IgnoreQueryFilters()
                                                     .Select(pa => pa.RefLtmsAccountId)
                                                     .Single();
                }
            }
            else
            {
                var lmsAvail2deliRepository = ServiceProvider.GetService <IRepository <Olma.Lms.LmsAvail2deli> >();
                var avail2deli = lmsAvail2deliRepository.FindAll()
                                 .Where(ad => ad.ExpressCode == Context.LoadCarrierReceipt.DigitalCode &&
                                        ad.State == 2 &&
                                        ad.FrachtpapiereErstellt.Value &&
                                        ad.DeletionDate == null
                                        )
                                 .Include(ad => ad.Availability)
                                 .Include(ad => ad.Delivery).AsNoTracking().FirstOrDefault();

                if (avail2deli != null)
                {
                    Context.LmsAvail2deli        = avail2deli;
                    Context.RefLtmsTransactionId = avail2deli.RefLtmsTransactionRowGuid;
                    Context.LoadCarrierReceipt.TargetPostingAccount = null;
                    Context.IsSelfService = avail2deli.Lieferkategorie == (int)RefLmsDeliveryCategory.SelfPickup;
                    Context.LoadCarrierReceipt.Trigger = LoadCarrierReceiptTrigger.OrderMatch;

                    switch (request.Type)
                    {
                    case LoadCarrierReceiptType.Delivery:
                        if (avail2deli.Availability.LtmsAccountId != null)
                        {
                            Context.TargetRefLtmsAccountId = avail2deli.Availability.LtmsAccountId.Value;
                        }
                        break;

                    case LoadCarrierReceiptType.Pickup:
                        if (avail2deli.Delivery.LtmsAccountId != null)
                        {
                            Context.TargetRefLtmsAccountId = avail2deli.Delivery.LtmsAccountId.Value;
                        }
                        break;
                    }

                    var orderLoad = orderLoadRepository
                                    .FindByCondition(i => i.Order.DivisionId == request.CustomerDivisionId &&
                                                     (i.Order.Type == OrderType.Supply
                                                  ? i.SupplyOrderMatch.DigitalCode ==
                                                      Context.LoadCarrierReceipt.DigitalCode
                                                  : i.DemandOrderMatch.DigitalCode ==
                                                      Context.LoadCarrierReceipt.DigitalCode))
                                    .Include(o => o.Detail)
                                    .Include(o => o.Order)
                                    .Include(o => o.SupplyOrderMatch).ThenInclude(sm => sm.Demand).ThenInclude(d => d.Detail)
                                    .ThenInclude(lc => lc.LoadCarrierReceipt).ThenInclude(dt => dt.PostingRequests)
                                    .Include(o => o.DemandOrderMatch).ThenInclude(sm => sm.Supply).ThenInclude(d => d.Detail)
                                    .ThenInclude(lc => lc.LoadCarrierReceipt).ThenInclude(dt => dt.PostingRequests)
                                    .Include(o => o.Order.PostingAccount)
                                    .IgnoreQueryFilters()
                                    .SingleOrDefault();

                    if (orderLoad == null)
                    {
                        return;
                    }
                    orderLoad.Detail.Status = OrderLoadStatus.Fulfilled;
                    orderLoad.Detail.ActualFulfillmentDateTime = DateTime.UtcNow;

                    Context.OrderLoad = orderLoad;
                    Context.LoadCarrierReceipt.OrderLoadDetailId = orderLoad.Detail.Id;
                    Context.IsSupply = orderLoad.Order.Type == OrderType.Supply;
                }
                else
                {
                    var expressCode = expressCodeRepository?.FindAll()
                                      .Where(c => c.DigitalCode == Context.LoadCarrierReceipt.DigitalCode)
                                      .Include(c => c.PartnerPresets)
                                      .ThenInclude(p => p.Partner)
                                      .ThenInclude(pa => pa.DefaultPostingAccount).Where(p => !p.IsDeleted).IgnoreQueryFilters()
                                      .SingleOrDefault();

                    var recipientPartner = expressCode?.PartnerPresets.SingleOrDefault(pp => pp.Type == Olma.ExpressCodePresetType.Recipient);
                    if (recipientPartner != null)
                    {
                        Context.TargetRefLtmsAccountId =
                            recipientPartner.Partner.DefaultPostingAccount.RefLtmsAccountId;
                    }
                }
            }
        }
コード例 #5
0
        private void OnValidEvaluate(object sender, EvaluateInternalEventArgs evaluateInternalEventArgs)
        {
            var loadCarrierReceiptRepo = ServiceProvider.GetService <IRepository <Olma.LoadCarrierReceipt> >();

            Context.LoadCarrierReceipt = loadCarrierReceiptRepo.GetById <Olma.LoadCarrierReceipt, Contracts.Models.LoadCarrierReceipt>(Context.LoadCarrierReceiptId);
        }