/// <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 tendered amount details of the shift. /// </summary> /// <param name="request">The get shift tendered amount data request.</param> /// <returns>A entity data service response.</returns> private EntityDataServiceResponse <ShiftTenderLine> GetShiftTenderedAmount(GetShiftTenderedAmountDataRequest 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; PagedResult <ShiftTenderLine> pagedResults; using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request)) { pagedResults = sqlServerDatabaseContext.ExecuteStoredProcedure <ShiftTenderLine>(GetShiftTenderedAmountSprocName, parameters); } return(new EntityDataServiceResponse <ShiftTenderLine>(pagedResults)); }