public static IList<AdditionalAgreement> GetActiveAgreementsForDeliveryPoint(IUnitOfWork uow, DeliveryPoint deliveryPoint) { AdditionalAgreement agreementAlias = null; var queryResult = uow.Session.QueryOver<AdditionalAgreement>(() => agreementAlias) .Where(() => agreementAlias.DeliveryPoint.Id == deliveryPoint.Id) .Where(() => !agreementAlias.IsCancelled) .List(); return queryResult; }
public static int GetBottlesAtDeliveryPoint(IUnitOfWork UoW, DeliveryPoint deliveryPoint, DateTime? before = null) { BottlesMovementOperation operationAlias = null; BottlesBalanceQueryResult result = null; var queryResult = UoW.Session.QueryOver<BottlesMovementOperation>(() => operationAlias) .Where(() => operationAlias.DeliveryPoint.Id == deliveryPoint.Id); if (before.HasValue) queryResult.Where(() => operationAlias.OperationTime < before); var bottles = queryResult.SelectList(list => list .SelectSum(()=>operationAlias.Delivered).WithAlias(()=>result.Delivered) .SelectSum(()=>operationAlias.Returned).WithAlias(()=>result.Returned) ) .TransformUsing(Transformers.AliasToBean<BottlesBalanceQueryResult>()).List<BottlesBalanceQueryResult>() .FirstOrDefault()?.BottlesDebt ?? 0; return bottles; }
public static IList<Equipment> GetEquipmentAtDeliveryPoint(IUnitOfWork uow, DeliveryPoint deliveryPoint) { return GetEquipmentAtDeliveryPointQuery(deliveryPoint.Counterparty, deliveryPoint) .GetExecutableQueryOver(uow.Session) .List(); }
public static QueryOver<Equipment> GetEquipmentAtDeliveryPointQuery(Counterparty client, DeliveryPoint deliveryPoint) { Equipment equipmentAlias=null; CounterpartyMovementOperation operationAlias = null; CounterpartyMovementOperation subsequentOperationAlias = null; var subsequentOperationsSubquery = QueryOver.Of<CounterpartyMovementOperation> (() => subsequentOperationAlias) .Where (() => operationAlias.Id < subsequentOperationAlias.Id && operationAlias.Equipment == subsequentOperationAlias.Equipment) .Select (op=>op.Id); var availableEquipmentIDsSubquery = QueryOver.Of<CounterpartyMovementOperation>(() => operationAlias) .WithSubquery.WhereNotExists(subsequentOperationsSubquery) .Where (() => operationAlias.IncomingCounterparty.Id == client.Id); if (deliveryPoint != null) availableEquipmentIDsSubquery .Where(() => operationAlias.IncomingDeliveryPoint.Id == deliveryPoint.Id); availableEquipmentIDsSubquery .Select(op=>op.Equipment.Id); return QueryOver.Of<Equipment> (() => equipmentAlias).WithSubquery.WhereProperty (() => equipmentAlias.Id).In (availableEquipmentIDsSubquery); }
public virtual void CreateOperation(Counterparty counterpartySrc, DeliveryPoint pointSrc, Counterparty counterpartyDst, DeliveryPoint pointDst, DateTime time) { WarehouseMovementOperation = null; CounterpartyMovementOperation = new CounterpartyMovementOperation { IncomingCounterparty = counterpartyDst, IncomingDeliveryPoint = pointDst, WriteoffCounterparty = counterpartySrc, WriteoffDeliveryPoint = pointSrc, Amount = Amount, OperationTime = time, Nomenclature = Nomenclature, Equipment = Equipment }; }
public static DeliveryPoint Create(Counterparty counterparty) { var point = new DeliveryPoint (); point.Counterparty = counterparty; counterparty.DeliveryPoints.Add(point); return point; }