public void TryRemoveAddress_IfAddressIsNotTransfered_ThenTheAddressWillBeDeletedAndMessageWillNotBeGenerated() { //arrange RouteList routeListSourceMock = Substitute.For <RouteList>(); routeListSourceMock.Id.Returns(999); RouteListItem routeListItemRemovingMock = Substitute.For <RouteListItem>(); routeListItemRemovingMock.WasTransfered.Returns(false); routeListItemRemovingMock.Order = Substitute.For <Order>(); IUnitOfWork uow = Substitute.For <IUnitOfWork>(); IRouteListItemRepository routeListItemRepository = Substitute.For <IRouteListItemRepository>(); RouteList routeListUnderTest = new RouteList { UoW = uow }; routeListUnderTest.Addresses.Add(routeListItemRemovingMock); // act routeListUnderTest.TryRemoveAddress(routeListItemRemovingMock, out string msg, routeListItemRepository); // assert Assert.That(routeListUnderTest.Addresses.Count, Is.EqualTo(0)); Assert.That(string.IsNullOrEmpty(msg), Is.True); }
public bool AnotherRouteListItemForOrderExist(IUnitOfWork uow, RouteListItem routeListItem) { if (routeListItem.Status == RouteListItemStatus.Transfered) { return(false); } RouteListItemStatus[] undeliveryStatus = RouteListItem.GetUndeliveryStatuses(); foreach (var status in undeliveryStatus) { if (routeListItem.Status == status) { return(false); } } var anotherRouteListItem = uow.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id == routeListItem.Order.Id) .And(x => x.Id != routeListItem.Id) .And(x => x.Status != RouteListItemStatus.Transfered) .And(!Restrictions.In(Projections.Property <RouteListItem>(x => x.Status), undeliveryStatus)) .And(x => x.RouteList.Id != routeListItem.RouteList.Id) .Take(1).List().FirstOrDefault(); return(anotherRouteListItem != null); }
string GetTransferText(RouteListItem item) // Дубликат метода в RouteListItem, надо переделать метод вызова попапа и убрать. { if (item.Status == RouteListItemStatus.Transfered) { if (item.TransferedTo != null) { return(String.Format("Заказ был перенесен в МЛ №{0} водителя {1}.", item.TransferedTo.RouteList.Id, item.TransferedTo.RouteList.Driver.ShortName )); } else { return("ОШИБКА! Адрес имеет статус перенесенного в другой МЛ, но куда он перенесен не указано."); } } if (item.WasTransfered) { var transferedFrom = Repository.Logistics.RouteListItemRepository.GetTransferedFrom(UoW, item); if (transferedFrom != null) { return(String.Format("Заказ из МЛ №{0} водителя {1}.", transferedFrom.RouteList.Id, transferedFrom.RouteList.Driver.ShortName )); } else { return("ОШИБКА! Адрес помечен как перенесенный из другого МЛ, но строка откуда он был перенесен не найдена."); } } return(null); }
public ShortOrderDTO(RouteListItem item) { Id = item.Order.Id; DeliverySchedule = item.Order?.DeliverySchedule?.DeliveryTime ?? String.Empty; OrderStatus = item.Status.GetEnumTitle(); Counterparty = item.Order?.Client?.FullName ?? String.Empty; Address = item.Order?.DeliveryPoint?.ShortAddress ?? String.Empty; }
private IList <FastDeliverySalesReportRow> GenerateReportRows() { if (!IsHasDates) { return(new List <FastDeliverySalesReportRow>()); } RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; Order orderAlias = null; OrderItem orderItemAlias = null; Nomenclature nomenclatureAlias = null; DeliverySchedule deliveryScheduleAlias = null; Employee driverAlias = null; DeliveryPoint deliveryPointAlias = null; District districtAlias = null; FastDeliverySalesReportRow resultAlias = null; var itemsQuery = UoW.Session.QueryOver(() => orderItemAlias) .JoinAlias(() => orderItemAlias.Order, () => orderAlias) .JoinEntityAlias(() => routeListItemAlias, () => routeListItemAlias.Order.Id == orderAlias.Id) .JoinAlias(() => routeListItemAlias.RouteList, () => routeListAlias) .JoinAlias(() => routeListAlias.Driver, () => driverAlias) .JoinAlias(() => orderItemAlias.Nomenclature, () => nomenclatureAlias) .JoinAlias(() => orderAlias.DeliveryPoint, () => deliveryPointAlias) .JoinAlias(() => orderAlias.DeliverySchedule, () => deliveryScheduleAlias) .JoinAlias(() => deliveryPointAlias.District, () => districtAlias) .Where(() => orderAlias.IsFastDelivery) .And(() => orderAlias.CreateDate >= CreateDateFrom.Value.Date && orderAlias.CreateDate <= CreateDateTo.Value.Date.Add(new TimeSpan(0, 23, 59, 59))); var amountPrjection = Projections.Conditional(Restrictions.IsNull( Projections.Property(() => orderItemAlias.ActualCount)), Projections.Property(() => orderItemAlias.Count), Projections.Property(() => orderItemAlias.ActualCount)); var sumProjection = Projections.SqlFunction(new SQLFunctionTemplate(NHibernateUtil.Decimal, "(?1 * ?2 - ?3)"), NHibernateUtil.Decimal, Projections.Property(() => orderItemAlias.Price), amountPrjection, Projections.Property(() => orderItemAlias.DiscountMoney)); return(itemsQuery .SelectList(list => list .Select(() => orderAlias.Id).WithAlias(() => resultAlias.OrderId) .Select(() => orderAlias.CreateDate).WithAlias(() => resultAlias.OrderCreateDateTime) .Select(() => routeListItemAlias.RouteList.Id).WithAlias(() => resultAlias.RouteListId) .Select(() => driverAlias.LastName).WithAlias(() => resultAlias.DriverLastName) .Select(() => driverAlias.Name).WithAlias(() => resultAlias.DriverName) .Select(() => driverAlias.Patronymic).WithAlias(() => resultAlias.DriverPatronymic) .Select(() => districtAlias.DistrictName).WithAlias(() => resultAlias.District) .Select(() => orderAlias.TimeDelivered).WithAlias(() => resultAlias.DeliveredDateTime) .Select(() => nomenclatureAlias.Name).WithAlias(() => resultAlias.Nomenclature) .Select(amountPrjection).WithAlias(() => resultAlias.Amount) .Select(sumProjection).WithAlias(() => resultAlias.Sum) ).OrderBy(() => orderAlias.CreateDate).Desc .TransformUsing(Transformers.AliasToBean <FastDeliverySalesReportRow>()) .List <FastDeliverySalesReportRow>()); }
public RouteListItem GetRouteListItemForOrder(IUnitOfWork uow, Domain.Orders.Order order) { RouteListItem routeListItemAlias = null; return(uow.Session.QueryOver(() => routeListItemAlias) .Where(rli => rli.Status != RouteListItemStatus.Transfered) .Where(() => routeListItemAlias.Order.Id == order.Id) .SingleOrDefault()); }
public string WaterToClientString(RouteListItem item, int id) { var planned = item.GetGoodsAmountForColumn(id); var actual = item.GetGoodsActualAmountForColumn(id); var formatString = actual < planned ? "<b>{0:N0}</b>({1:N0})" : "<b>{0:N0}</b>"; return(String.Format(formatString, actual, planned - actual)); }
public RouteListItem GetTransferedFrom(IUnitOfWork uow, RouteListItem item) { if (!item.WasTransfered) { return(null); } return(uow.Session.QueryOver <RouteListItem>() .Where(rli => rli.TransferedTo.Id == item.Id) .Take(1) .SingleOrDefault()); }
public RouteList GetRouteListByOrder(IUnitOfWork uow, Domain.Orders.Order order) { RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; return(uow.Session.QueryOver(() => routeListAlias) .Left.JoinAlias(() => routeListAlias.Addresses, () => routeListItemAlias) .Where(() => routeListItemAlias.Order.Id == order.Id) .List() .FirstOrDefault()); }
Gdk.Pixbuf GetRowIcon(RouteListItem item) { if (item.Status == RouteListItemStatus.Transfered) { return(TransferFromIcon); } if (item.WasTransfered) { return(TransferInIcon); } return(null); }
private RouteListAddressDto convertToAPIRouteListAddress(RouteListItem routeListAddress) { return(new RouteListAddressDto() { Id = routeListAddress.Id, Status = _routeListAddressStatusConverter.convertToAPIRouteListAddressStatus(routeListAddress.Status), DeliveryIntervalStart = routeListAddress.Order.DeliveryDate + routeListAddress.Order.DeliverySchedule.From ?? DateTime.MinValue, DeliveryIntervalEnd = routeListAddress.Order.DeliveryDate + routeListAddress.Order.DeliverySchedule.To ?? DateTime.MinValue, OrderId = routeListAddress.Order.Id, Address = _deliveryPointConverter.ExtractAPIAddressFromDeliveryPoint(routeListAddress.Order.DeliveryPoint) }); }
public OrderDTO(RouteListItem item) { Id = item.Order.Id; Title = item.Order.Title; CityDistrict = item.Order.DeliveryPoint?.CityDistrict; StreetDistrict = item.Order.DeliveryPoint?.StreetDistrict; Latitude = item.Order.DeliveryPoint?.Latitude; Longitude = item.Order.DeliveryPoint?.Longitude; DeliveryPointComment = item.Order.DeliveryPoint?.Comment; Address = item.Order.DeliveryPoint?.CompiledAddress; DeliverySchedule = item.Order.DeliverySchedule.DeliveryTime; RouteListItemStatus = item.Status.GetEnumTitle(); OrderComment = item.Order.Comment; Counterparty = item.Order.Client.FullName; BottlesReturn = item.DriverBottlesReturned == null ? null :item.DriverBottlesReturned.ToString(); if (item.Order.DeliveryPoint != null && item.Order.DeliveryPoint.Contacts.Count > 0) { //FIXME Сделать обработку нескольких контантных лиц. DPContact = item.Order.DeliveryPoint.Contacts[0].FullName; } else { DPContact = "Контактные лица не указаны"; } //FIXME Чисто временное решение, так как необходимо обновлять Анройд клиент. DPPhone = String.Join("\n", item.Order.DeliveryPoint.Phones.Select(x => x.LongText)); DPPhone2 = new List <string> (); foreach (Phone phone in item.Order.DeliveryPoint.Phones) { DPPhone2.Add(String.Format("{0}: {1}", phone.NumberType?.Name, phone.Number)); } CPPhones = new List <string> (); foreach (Phone phone in item.Order.Client.Phones) { CPPhones.Add(String.Format("{0}: {1}", phone.NumberType?.Name, phone.Number)); } OrderItems = new List <string> (); foreach (OrderItem orderItem in item.Order.OrderItems) { OrderItems.Add(String.Format("{0}: {1} {2}", orderItem.NomenclatureString, orderItem.Count, orderItem.Nomenclature.Unit == null ? String.Empty : orderItem.Nomenclature.Unit.Name)); } OrderEquipment = new List <string> (); foreach (OrderEquipment equipment in item.Order.OrderEquipments) { OrderEquipment.Add(String.Format("{0}: {1}", equipment.NameString, equipment.DirectionString)); } }
private OrganisationCashMovementOperation CreateOrganisationCashMovementOperation( IUnitOfWork uow, RouteListItem address) { var hasReceipt = orderRepository.OrderHasSentReceipt(uow, address.Order.Id); return(new OrganisationCashMovementOperation { OperationTime = DateTime.Now, Organisation = hasReceipt ? address.Order.Contract.Organization : cashDistributionCommonOrganisationProvider.GetCommonOrganisation(uow) }); }
public RouteList GetActualRouteListByOrder(IUnitOfWork uow, VodovozOrder order) { RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; return(uow.Session.QueryOver(() => routeListAlias) .Left.JoinAlias(() => routeListAlias.Addresses, () => routeListItemAlias) .Where(() => routeListItemAlias.Order.Id == order.Id) .And(() => routeListItemAlias.Status != RouteListItemStatus.Transfered) .Fetch(SelectMode.ChildFetch, routeList => routeList.Addresses) .List() .FirstOrDefault()); }
public static IList <int> GetListOfUndeliveryIdsForDriver(IUnitOfWork uow, Employee driver) { Order orderAlias = null; RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; var query = uow.Session.QueryOver <RouteListItem>(() => routeListItemAlias) .Left.JoinAlias(() => routeListItemAlias.RouteList, () => routeListAlias) .Where(() => routeListAlias.Driver == driver) .Left.JoinQueryOver(() => routeListItemAlias.Order, () => orderAlias); var q = query.List().Select(i => i.Order.Id); return(q.ToList()); }
protected void OnButtonRevertClicked(object sender, EventArgs e) { var toRevert = ytreeviewRLTo .GetSelectedObjects <RouteListItemNode>() .Where(x => x.WasTransfered) .Select(x => x.RouteListItem) .ToList(); foreach (var address in toRevert) { if (address.Status == RouteListItemStatus.Transfered) { MessageDialogHelper.RunWarningDialog(string.Format("Адрес {0} сам перенесен в МЛ №{1}. Отмена этого переноса не возможна. Сначала нужно отменить перенос в {1} МЛ.", address?.Order?.DeliveryPoint.ShortAddress, address.TransferedTo?.RouteList.Id)); continue; } RouteListItem pastPlace = (yentryreferenceRLFrom.Subject as RouteList) ?.Addresses ?.FirstOrDefault(x => x.TransferedTo != null && x.TransferedTo.Id == address.Id) ?? new RouteListItemRepository().GetTransferedFrom(UoW, address); if (pastPlace != null) { pastPlace.SetStatusWithoutOrderChange(address.Status); pastPlace.DriverBottlesReturned = address.DriverBottlesReturned; pastPlace.TransferedTo = null; if (pastPlace.RouteList.ClosingFilled) { pastPlace.FirstFillClosing(UoW, _wageParameterService); } UpdateTranferDocuments(pastPlace.RouteList, address.RouteList); UoW.Save(pastPlace); } address.RouteList.ObservableAddresses.Remove(address); UoW.Save(address.RouteList); } foreach (var routeListItem in toRevert) { routeListItem.RecalculateTotalCash(); } UoW.Commit(); UpdateNodes(); }
public string FromClientString(RouteListItem item) { var stringParts = new List <string>(); if (item.PlannedCoolersFromClient > 0) { var formatString = item.CoolersFromClient < item.PlannedCoolersFromClient ? "Кулеры:<b>{0}</b>({1})" : "Кулеры:<b>{0}</b>"; var coolerString = String.Format(formatString, item.CoolersFromClient, item.PlannedCoolersFromClient - item.CoolersFromClient ); stringParts.Add(coolerString); } if (item.PlannedPumpsFromClient > 0) { var formatString = item.PumpsFromClient < item.PlannedPumpsFromClient ? "Помпы:<b>{0}</b>({1})" : "Помпы:<b>{0}</b>"; var pumpString = String.Format(formatString, item.PumpsFromClient, item.PlannedPumpsFromClient - item.PumpsFromClient ); stringParts.Add(pumpString); } //Оборудование не из товаров var equipList = item.Order.OrderEquipments .Where(x => x.OrderItem == null //&& x.Nomenclature.Category != NomenclatureCategory.water && x.Direction == Domain.Orders.Direction.PickUp); foreach (var orderEquip in equipList) { stringParts.Add(orderEquip.IsFullyDelivered ? string.Format("{0}:{1} ", orderEquip.NameString, orderEquip.ActualCount ?? 0) : string.Format("{0}:{1}({2:-0})", orderEquip.NameString, orderEquip.ActualCount ?? 0, orderEquip.Count - orderEquip.ActualCount ?? 0) ); } //Если это старый заказ со старой записью оборудования в виде строки, то выводим только его if (!String.IsNullOrWhiteSpace(item.Order.FromClientText)) { return(item.Order.FromClientText); } return(String.Join(",", stringParts)); }
public decimal GetDistributedAmountOnRouteList(IUnitOfWork uow, int routeListId) { RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; RouteListItemCashDistributionDocument docAlias = null; var query = uow.Session.QueryOver(() => docAlias) .Left.JoinAlias(() => docAlias.RouteListItem, () => routeListItemAlias) .Left.JoinAlias(() => routeListItemAlias.RouteList, () => routeListAlias) .Where(() => routeListAlias.Id == routeListId) .Select(Projections.Sum(() => docAlias.Amount)) .SingleOrDefault <decimal>(); return(query); }
public IList <RouteListItem> GetRouteListItemAtDay(IUnitOfWork uow, DateTime date, RouteListItemStatus?status) { RouteListItem routeListItemAlias = null; RouteList routelistAlias = null; var query = uow.Session.QueryOver(() => routeListItemAlias) .JoinQueryOver(rli => rli.RouteList, () => routelistAlias) .Where(() => routelistAlias.Date == date); if (status != null) { query.Where(() => routeListItemAlias.Status == status.Value); } return(query.List()); }
public IList <Order> GetOrdersForWayBillDocuments(IUnitOfWork uow, DateTime startDate, DateTime endDate) { RouteListItem routeListItemAlias = null; RouteList routeListAlias = null; Order orderAlias = null; return(uow.Session.QueryOver <Order>(() => orderAlias) .JoinEntityAlias(() => routeListItemAlias, () => orderAlias.Id == routeListItemAlias.Order.Id, JoinType.InnerJoin) .JoinEntityAlias(() => routeListAlias, () => routeListItemAlias.RouteList.Id == routeListAlias.Id, JoinType.InnerJoin) .Where(() => routeListAlias.Status == RouteListStatus.Closed) .And(() => routeListAlias.Date >= startDate) .And(() => routeListAlias.Date <= endDate) .And(() => orderAlias.OrderStatus == OrderStatus.Closed) .And(() => orderAlias.PaymentType == PaymentType.cashless) .List()); }
private IList <FastDeliveryAdditionalLoadingReportRow> GenerateReportRows() { if (!IsHasDates) { return(new List <FastDeliveryAdditionalLoadingReportRow>()); } RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; Order orderAlias = null; Nomenclature nomenclatureAlias = null; FastDeliveryAdditionalLoadingReportRow resultAlias = null; AdditionalLoadingDocumentItem additionalLoadingDocumentItemAlias = null; AdditionalLoadingDocument additionalLoadingDocumentAlias = null; var itemsQuery = UoW.Session.QueryOver(() => additionalLoadingDocumentItemAlias) .JoinAlias(() => additionalLoadingDocumentItemAlias.AdditionalLoadingDocument, () => additionalLoadingDocumentAlias) .JoinEntityAlias(() => routeListAlias, () => routeListAlias.AdditionalLoadingDocument.Id == additionalLoadingDocumentAlias.Id) .JoinAlias(() => additionalLoadingDocumentItemAlias.Nomenclature, () => nomenclatureAlias) .Where(() => routeListAlias.Date >= CreateDateFrom.Value.Date && routeListAlias.Date <= CreateDateTo.Value.Date.Add(new TimeSpan(0, 23, 59, 59))); var ownOrdersAmountSubquery = QueryOver.Of(() => routeListItemAlias) .JoinAlias(() => routeListItemAlias.Order, () => orderAlias) .WhereRestrictionOn(() => routeListItemAlias.Status).Not.IsIn(new RouteListItemStatus[] { RouteListItemStatus.Canceled, RouteListItemStatus.Overdue, RouteListItemStatus.Transfered }) .And(() => routeListItemAlias.RouteList.Id == routeListAlias.Id) .And(() => !orderAlias.IsFastDelivery) .Select(Projections.Count(Projections.Id())); return(itemsQuery .SelectList(list => list .Select(() => routeListAlias.Date).WithAlias(() => resultAlias.RouteListDate) .Select(() => routeListAlias.Id).WithAlias(() => resultAlias.RouteListId) .SelectSubQuery(ownOrdersAmountSubquery).WithAlias(() => resultAlias.OwnOrdersCount) .Select(() => nomenclatureAlias.Name).WithAlias(() => resultAlias.AdditionaLoadingNomenclature) .Select(() => additionalLoadingDocumentItemAlias.Amount).WithAlias(() => resultAlias.AdditionaLoadingAmount) ).OrderBy(() => routeListAlias.Date).Desc .ThenBy(() => routeListAlias.Id).Desc .TransformUsing(Transformers.AliasToBean <FastDeliveryAdditionalLoadingReportRow>()) .List <FastDeliveryAdditionalLoadingReportRow>()); }
public bool CurrentRouteListHasOrderDuplicate(IUnitOfWork uow, RouteListItem routeListItem, int [] actualRouteListItemIds) { if (routeListItem.Status == RouteListItemStatus.Transfered) { return(false); } var currentRouteListOrderDuplicate = uow.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id == routeListItem.Order.Id) .And(x => x.Id != routeListItem.Id) .And(x => x.RouteList.Id == routeListItem.RouteList.Id) .And(Restrictions.In(Projections.Property <RouteListItem>(x => x.Id), actualRouteListItemIds)) .And(x => x.Status != RouteListItemStatus.Transfered) .Take(1).List().FirstOrDefault(); return(currentRouteListOrderDuplicate != null); }
private RouteListItemCashDistributionDocument CreateRouteListItemCashDistributionDocument( OrganisationCashMovementOperation operation, RouteListItem address, Expense expense) { return(new RouteListItemCashDistributionDocument { Organisation = operation.Organisation, CreationDate = DateTime.Now, LastEditedTime = DateTime.Now, Author = expense.Casher, LastEditor = expense.Casher, RouteListItem = address, Employee = expense.Employee, Expense = expense, OrganisationCashMovementOperation = operation, Amount = operation.Amount }); }
public string GetEmployeePushTokenByOrderId(IUnitOfWork uow, int orderId) { Vodovoz.Domain.Orders.Order vodovozOrder = null; RouteListItem routeListAddress = null; RouteList routeList = null; Employee employee = null; return(uow.Session.QueryOver <RouteListItem>(() => routeListAddress) .Inner.JoinAlias(() => routeListAddress.RouteList, () => routeList) .Inner.JoinAlias(() => routeListAddress.Order, () => vodovozOrder) .Inner.JoinAlias(() => routeList.Driver, () => employee) .Where(Restrictions.Eq(Projections.Property(() => vodovozOrder.Id), orderId)) .And(Restrictions.Not(Restrictions.Eq(Projections.Property(() => routeListAddress.Status), RouteListItemStatus.Transfered))) .And(Restrictions.IsNull(Projections.Property(() => routeListAddress.TransferedTo))) .Select(Projections.Property(() => employee.AndroidToken)) .SingleOrDefault <string>()); }
protected void OnButtonRevertClicked(object sender, EventArgs e) { var toRevert = ytreeviewRLTo .GetSelectedObjects <RouteListItemNode>() .Where(x => x.WasTransfered) .Select(x => x.RouteListItem) .ToList(); foreach (var address in toRevert) { if (address.Status == RouteListItemStatus.Transfered) { MessageDialogHelper.RunWarningDialog(string.Format("Адрес {0} сам перенесен в МЛ №{1}. Отмена этого переноса не возможна. Сначала нужно отменить перенос в {1} МЛ.", address?.Order?.DeliveryPoint.ShortAddress, address.TransferedTo?.RouteList.Id)); continue; } RouteListItem pastPlace = (yentryreferenceRLFrom.Subject as RouteList) ?.Addresses ?.FirstOrDefault(x => x.TransferedTo != null && x.TransferedTo.Id == address.Id) ?? _routeListItemRepository.GetTransferedFrom(UoW, address); var previousRouteList = pastPlace?.RouteList; if (pastPlace != null) { previousRouteList.RevertTransferAddress(_wageParameterService, pastPlace, address); pastPlace.NeedToReload = address.NeedToReload; pastPlace.WasTransfered = true; UpdateTranferDocuments(pastPlace.RouteList, address.RouteList); pastPlace.RecalculateTotalCash(); UoW.Save(pastPlace); address.RouteList.TransferAddressTo(address, pastPlace); address.WasTransfered = false; } address.RouteList.CalculateWages(_wageParameterService); address.RecalculateTotalCash(); UoW.Save(address.RouteList); } UoW.Commit(); UpdateNodes(); }
public bool RefreshPaymentStatus(int orderId) { try { if (orderId < 1) { logger.Warn($"Передан неверный номер заказа ({orderId}) при попытке обновить статус платежа"); return(false); } using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { RouteListItem routeListItemAlias = null; RouteList routeListAlias = null; Order orderAlias = null; var routeLists = uow.Session.QueryOver <RouteList>(() => routeListAlias) .Left.JoinAlias(() => routeListAlias.Addresses, () => routeListItemAlias) .Left.JoinAlias(() => routeListItemAlias.Order, () => orderAlias) .Where(() => orderAlias.Id == orderId) .Where(() => !routeListItemAlias.WasTransfered) .Where(() => routeListItemAlias.Status == RouteListItemStatus.EnRoute) .List(); if (!routeLists.Any()) { logger.Warn($"При обновлении статуса платежа для заказа ({orderId}) не был найден МЛ"); return(false); } RouteList rl = routeLists.First(); string token = rl.Driver.AndroidToken; if (string.IsNullOrWhiteSpace(token)) { logger.Warn($"Водителю ({rl.Driver.GetPersonNameWithInitials()}. Id:{rl.Driver.Id}) не присвоен Token для уведомлений."); return(false); } driverNotificator.SendOrderPaymentStatusChangedMessage(token, "Веселый водовоз", "Обновлен статус платежа"); } return(true); } catch (Exception ex) { logger.Error(ex); return(false); } }
private bool NeedPremiumRaskatGAZelleInRouteListDate(IUnitOfWork uow) { if (routeList.RecalculatedDistance >= premiumRaskatGAZelleParametersProvider.MinRecalculatedDistanceForPremiumRaskatGAZelle && routeList.Car.IsRaskat && routeList.Car.TypeOfUse == CarTypeOfUse.DriverCar && routeList.Car.RaskatType == RaskatType.RaskatGazelle) { RouteListItem routeListAdressesAlias = null; Order orderAlias = null; DeliveryPoint deliveryPointAlias = null; District districtAlias = null; PremiumItem premiumItemAlias = null; PremiumRaskatGAZelle premiumRaskatGAZelleAlias = null; // Ищем премию var premiumRaskatGAZelleQuery = uow.Session.QueryOver(() => premiumItemAlias) .JoinAlias(() => premiumItemAlias.Premium, () => premiumRaskatGAZelleAlias) .Where(() => ( // Если МЛ переоткрыли в другой день и повторно его закрывают (premiumRaskatGAZelleAlias.RouteList.Id == routeList.Id) || // Если на дату закрытия у водителя уже есть премии (premiumRaskatGAZelleAlias.Date == DateTime.Today && premiumItemAlias.Employee == routeList.Driver) ) && premiumRaskatGAZelleAlias.GetType() == typeof(PremiumRaskatGAZelle) ) .Take(1).SingleOrDefault(); // Ищем заказ в пригороде var wageDistrictQuery = uow.Session.QueryOver(() => routeListAdressesAlias) .JoinAlias(() => routeListAdressesAlias.Order, () => orderAlias) .JoinAlias(() => orderAlias.DeliveryPoint, () => deliveryPointAlias) .JoinAlias(() => deliveryPointAlias.District, () => districtAlias) .Where(() => districtAlias.WageDistrict.Id == wageParametersProvider.GetSuburbWageDistrictId && routeListAdressesAlias.RouteList.Id == routeList.Id) .Take(1).SingleOrDefault(); return(premiumRaskatGAZelleQuery == null && wageDistrictQuery != null); } else { return(false); } }
public Dictionary <int, IEnumerable <int> > GetAllRouteListsForOrders(IUnitOfWork UoW, IEnumerable <VodovozOrder> orders) { VodovozOrder orderAlias = null; RouteList routeListAlias = null; RouteListItem routeListItemAlias = null; var rls = UoW.Session.QueryOver <RouteListItem>(() => routeListItemAlias) .Left.JoinAlias(() => routeListItemAlias.Order, () => orderAlias) .Left.JoinAlias(() => routeListItemAlias.RouteList, () => routeListAlias) .Where(Restrictions.In(Projections.Property(() => routeListItemAlias.Order.Id), orders.Select(x => x.Id).ToArray())) .SelectList(list => list .Select(() => orderAlias.Id) .Select(() => routeListAlias.Id) ) .TransformUsing(Transformers.PassThrough) .List <object[]>() .GroupBy(x => (int)x[0]).ToDictionary(x => x.Key, x => x.Select(y => (int)y[1])); return(rls); }
public void Check_Bottle_Movement_Operation_Creation(List <OrderItem> orderItems, int delivered, int returned) { //arrange RouteListItem testRLItem = new RouteListItem(); IUnitOfWork uow = Substitute.For <IUnitOfWork>(); testRLItem.Order = new Order(); testRLItem.Order.UoW = uow; testRLItem.Order.OrderItems = orderItems; testRLItem.Order.DeliveryDate = DateTime.Now; var standartNom = Substitute.For <IStandartNomenclatures>(); standartNom.GetForfeitId().Returns(33); // act testRLItem.Order.UpdateBottleMovementOperation(uow, standartNom, testRLItem.BottlesReturned); // assert Assert.AreEqual(returned, testRLItem.Order.BottlesMovementOperation.Returned); Assert.AreEqual(delivered, testRLItem.Order.BottlesMovementOperation.Delivered); }
public IEnumerable <KeyValuePair <string, int> > GetDeliveryItemsToReturn(IUnitOfWork unitOfWork, int routeListsId) { RouteListItem routeListItemAlias = null; VodovozOrder orderAlias = null; OrderEquipment orderEquipmentAlias = null; Nomenclature nomenclatureAlias = null; KeyValuePair <string, int> keyValuePairAlias = new KeyValuePair <string, int>(); return(unitOfWork.Session.QueryOver(() => routeListItemAlias) .Inner.JoinAlias(() => routeListItemAlias.Order, () => orderAlias) .Inner.JoinAlias(() => orderAlias.OrderEquipments, () => orderEquipmentAlias) .Inner.JoinAlias(() => orderEquipmentAlias.Nomenclature, () => nomenclatureAlias) .Where(Restrictions.Or( Restrictions.And( Restrictions.Eq(Projections.Property(() => orderAlias.OrderStatus), OrderStatus.Shipped), Restrictions.Eq(Projections.Property(() => orderEquipmentAlias.Direction), Direction.PickUp) ), Restrictions.And( Restrictions.Eq(Projections.Property(() => orderAlias.OrderStatus), OrderStatus.NotDelivered), Restrictions.Eq(Projections.Property(() => orderEquipmentAlias.Direction), Direction.Deliver) ) )) .And(Restrictions.Eq(Projections.Property(() => routeListItemAlias.RouteList.Id), routeListsId)) .SelectList(list => list.Select(Projections.GroupProperty(Projections.Property(() => nomenclatureAlias.Name)).WithAlias(() => keyValuePairAlias.Key)) .Select(Projections.Sum( Projections.Conditional( Restrictions.Eq(Projections.Property(() => orderEquipmentAlias.Direction), Direction.PickUp), Projections.Property(() => orderEquipmentAlias.ActualCount), Projections.Conditional( Restrictions.Eq(Projections.Property(() => orderEquipmentAlias.Direction), Direction.Deliver), Projections.Property(() => orderEquipmentAlias.Count), Projections.Constant(0)) ) ) ).WithAlias(() => keyValuePairAlias.Value) ).TransformUsing(Transformers.AliasToBean <KeyValuePair <string, int> >()).List <KeyValuePair <string, int> >()); }