/// <summary> /// Calculate the totals, number of transactions happened in the current shift. /// </summary> /// <param name="context">Request context.</param> /// <param name="currentShift">Current shift object.</param> /// <param name="shiftTerminalId">Shift terminal Identifier.</param> /// <param name="shiftId">Shift identifier.</param> public static void Calculate(RequestContext context, Shift currentShift, string shiftTerminalId, long shiftId) { GetEndOfDayShiftDetailsDataRequest getEndOfDayShiftDetailsDataRequest = new GetEndOfDayShiftDetailsDataRequest(shiftTerminalId, shiftId, context.GetChannelConfiguration().PriceIncludesSalesTax); Shift endOfDayShiftDetails = context.Runtime.Execute <SingleEntityDataServiceResponse <Shift> >(getEndOfDayShiftDetailsDataRequest, context).Entity; // Sets the sales totals. SetShiftSalesTotals(currentShift, endOfDayShiftDetails); // Set the tender lines. SetShiftTenderLine(currentShift, endOfDayShiftDetails); // Set the account lines. SetShiftAccountLines(currentShift, endOfDayShiftDetails); // Calculates the shift counts. GetShiftTransactionsCountDataRequest getShiftTransactionCountsDataRequest = new GetShiftTransactionsCountDataRequest(shiftTerminalId, shiftId); Shift shiftCounts = context.Runtime.Execute <SingleEntityDataServiceResponse <Shift> >(getShiftTransactionCountsDataRequest, context).Entity; // Set the retail transaction counts. SetRetailTransactionCount(currentShift, shiftCounts); // Calculates the tender line tender amounts. GetShiftTenderedAmountDataRequest getShiftTenderedAmountDataRequest = new GetShiftTenderedAmountDataRequest(shiftTerminalId, shiftId, QueryResultSettings.AllRecords); var shiftTenderAmount = context.Runtime.Execute <EntityDataServiceResponse <ShiftTenderLine> >(getShiftTenderedAmountDataRequest, context).PagedEntityCollection.Results; // Set the tender line tender amounts. SetShiftTenderLineTenderAmounts(currentShift, shiftTenderAmount); }
/// <summary> /// Get shift transactions. /// </summary> /// <param name="request">The get shift transaction counts data request.</param> /// <returns>The Shift collection object.</returns> private SingleEntityDataServiceResponse <Shift> GetShiftTransactionsCounts(GetShiftTransactionsCountDataRequest request) { ThrowIf.Null(request, "request"); ThrowIf.Null(request.TerminalId, "request.TerminalId"); ParameterSet parameters = new ParameterSet(); parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId; parameters[TerminalIdVariableName] = request.TerminalId; parameters[ShiftIdVariableName] = request.ShiftId; Shift shift; using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request)) { shift = sqlServerDatabaseContext.ExecuteStoredProcedure <Shift>(GetShiftTransactionsSprocName, parameters).Results.FirstOrDefault(); } return(new SingleEntityDataServiceResponse <Shift>(shift)); }