Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested answer

Can not get object Shift in GetCustomReceiptsRequest request

(0) ShareShare
ReportReport
Posted on by

Hello all,

I have a request to get data of current Shift when print report to change some details in CustomReceipt7.

I create Request Handler: SingleRequestHandler<GetCustomReceiptsRequest, GetReceiptResponse>


I try to use this method to get shift, but AccountLines, TenderLines, TaxLines can not get, because in this time in database do not exist line of transaction.

private Shift GetShift()
{
long channelId = request.RequestContext.GetPrincipal().ChannelId;
long shiftId = request.RequestContext.GetPrincipal().ShiftId;
string terminalId = request.RequestContext.GetTerminalId().ToString();

GetShiftDataDataRequest shiftDataDataRequest = new GetShiftDataDataRequest(new ShiftDataQueryCriteria()
{
ChannelId = new long?(channelId),
TerminalId = terminalId,
ShiftId = new long?(shiftId),
SearchByTerminalId = true,
IncludeSharedShifts = true
}, QueryResultSettings.SingleRecord);
Shift entity = request.RequestContext.Runtime.Execute<EntityDataServiceResponse<Shift>>((Request)shiftDataDataRequest, request.RequestContext).PagedEntityCollection.FirstOrDefault<Shift>();
if (entity != null)
{
PagedResult<ShiftTenderLine> shiftEntity1 = this.GetShiftEntity<ShiftTenderLine>(string.Empty, "SHIFTTENDERLINESVIEW", terminalId, shiftId, (Request)request, false);
PagedResult<ShiftAccountLine> shiftEntity2 = this.GetShiftEntity<ShiftAccountLine>(string.Empty, "SHIFTACCOUNTSVIEW", terminalId, shiftId, (Request)request, false);
PagedResult<ShiftTaxLine> shiftEntity3 = this.GetShiftEntity<ShiftTaxLine>(string.Empty, "SHIFTTAXLINESVIEW", terminalId, shiftId, (Request)request, false);
entity.AccountLines = (IList<ShiftAccountLine>)shiftEntity2.Results.ToList<ShiftAccountLine>();
entity.TenderLines = (IList<ShiftTenderLine>)shiftEntity1.Results.ToList<ShiftTenderLine>();
entity.TaxLines = (IList<ShiftTaxLine>)shiftEntity3.Results.ToList<ShiftTaxLine>();
RetailLogger.Log.CrtDataServiceSqlServerGetShiftDataRequestSucceeded(entity.ShiftId, entity.TerminalId, entity.CashDrawer, entity.CurrentTerminalId, entity.StaffId, entity.CurrentStaffId, entity.IsShared.ToString(), entity.Status.ToString());
}
return entity;
}

Thanks for support.

  • Community Member Profile Picture
    on at
    RE: Can not get object Shift in GetCustomReceiptsRequest request

    Finally, I found code in decompile dll.

    This method inside of request to call XZ Report.

    This really final solution I choosed.

    public static void Calculate(

      RequestContext context,

      Shift currentShift,

      string shiftTerminalId,

      long shiftId)

    {

     GetEndOfDayShiftDetailsDataRequest detailsDataRequest = new GetEndOfDayShiftDetailsDataRequest(shiftTerminalId, shiftId, context.GetChannelConfiguration().PriceIncludesSalesTax);

     Shift entity1 = context.Runtime.Execute>((Request)detailsDataRequest, context).Entity;

     LAW_ShiftCalculator.SetShiftSalesTotals(currentShift, entity1);

     LAW_ShiftCalculator.SetShiftTenderLine(currentShift, entity1);

     LAW_ShiftCalculator.SetShiftAccountLines(currentShift, entity1);

     GetShiftTransactionsCountDataRequest countDataRequest = new GetShiftTransactionsCountDataRequest(shiftTerminalId, shiftId);

     Shift entity2 = context.Runtime.Execute>((Request)countDataRequest, context).Entity;

     LAW_ShiftCalculator.SetRetailTransactionCount(currentShift, entity2);

     GetShiftTenderedAmountDataRequest amountDataRequest = new GetShiftTenderedAmountDataRequest(shiftTerminalId, shiftId, QueryResultSettings.AllRecords);

     ReadOnlyCollection results = context.Runtime.Execute>((Request)amountDataRequest, context).PagedEntityCollection.Results;

     LAW_ShiftCalculator.SetShiftTenderLineTenderAmounts(currentShift, (IEnumerable)results);

     if (context.GetChannelConfiguration().CountryRegionISOCode != CountryRegionISOCode.SE)

      return;

     GetEndOfDayShiftDetailsSwedenDataRequest swedenDataRequest = new GetEndOfDayShiftDetailsSwedenDataRequest(currentShift.StoreId, shiftTerminalId, shiftId, context.GetChannelConfiguration().PriceIncludesSalesTax);

     Shift entity3 = context.Runtime.Execute>((Request)swedenDataRequest, context).Entity;

     LAW_ShiftCalculator.SetShiftSalesTotals_SE(currentShift, entity3);

     LAW_ShiftCalculator.SetShiftTaxLine(currentShift, entity3);

    }

    private static void SetShiftSalesTotals(Shift currentShift, Shift shiftTotals)

    {

     currentShift.SalesTotal = shiftTotals.SalesTotal;

     currentShift.ReturnsTotal = shiftTotals.ReturnsTotal;

     currentShift.DiscountTotal = shiftTotals.DiscountTotal;

     currentShift.TaxTotal = shiftTotals.TaxTotal;

     currentShift.PaidToAccountTotal = shiftTotals.PaidToAccountTotal;

     currentShift.SuspendedTransactionCount = shiftTotals.SuspendedTransactionCount;

     currentShift.DepositCollected = shiftTotals.DepositCollected;

     currentShift.DepositRedeemed = shiftTotals.DepositRedeemed;

     currentShift.DepositRefunded = shiftTotals.DepositRefunded;

     currentShift.CancellationCharges = shiftTotals.CancellationCharges;

     currentShift.CustomerOrdersPlaced = shiftTotals.CustomerOrdersPlaced;

     currentShift.CustomerOrdersCanceled = shiftTotals.CustomerOrdersCanceled;

     currentShift.CustomerOrdersVoidedLines = shiftTotals.CustomerOrdersVoidedLines;

     currentShift.CustomerOrdersEdited = shiftTotals.CustomerOrdersEdited;

     currentShift.GiftCardsTotal = shiftTotals.GiftCardsTotal;

     currentShift.GiftCardCashOutTotal = shiftTotals.GiftCardCashOutTotal;

     currentShift.VoidedSalesTotal = shiftTotals.VoidedSalesTotal;

     currentShift.ChargeTotal = shiftTotals.ChargeTotal;

    }

    private static void SetShiftSalesTotals_SE(Shift currentShift, Shift shiftTotals)

    {

     currentShift.ReceiptsCount = shiftTotals.ReceiptsCount;

     currentShift.ReturnsCount = shiftTotals.ReturnsCount;

     currentShift.GoodsSoldQty = shiftTotals.GoodsSoldQty;

     currentShift.ServicesSoldQty = shiftTotals.ServicesSoldQty;

     currentShift.ReceiptCopiesCount = shiftTotals.ReceiptCopiesCount;

     currentShift.ReceiptCopiesTotal = shiftTotals.ReceiptCopiesTotal;

     currentShift.PriceOverrideTotal = shiftTotals.PriceOverrideTotal;

     currentShift.SuspendedTotal = shiftTotals.SuspendedTotal;

     currentShift.SalesTotalIncludingTax = shiftTotals.SalesTotalIncludingTax;

     currentShift.SalesTotalExcludingTax = shiftTotals.SalesTotalExcludingTax;

     currentShift.SalesGrandTotal = shiftTotals.SalesGrandTotal;

     currentShift.ReturnsGrandTotal = shiftTotals.ReturnsGrandTotal;

    }

    private static void SetShiftTenderLine(Shift currentShift, Shift endOfDayShiftDetails)

    {

     currentShift.TenderLines.AddRange((IEnumerable)endOfDayShiftDetails.TenderLines);

    }

    private static void SetShiftAccountLines(Shift currentShift, Shift endOfDayShiftDetails)

    {

     currentShift.AccountLines.AddRange((IEnumerable)endOfDayShiftDetails.AccountLines);

    }

    private static void SetShiftTaxLine(Shift currentShift, Shift endOfDayShiftDetails)

    {

     currentShift.TaxLines.AddRange((IEnumerable)endOfDayShiftDetails.TaxLines);

    }

    private static void SetShiftTenderLineTenderAmounts(

      Shift currentShift,

      IEnumerable shiftTenderLines)

    {

     foreach (ShiftTenderLine shiftTenderLine in shiftTenderLines)

     {

      ShiftTenderLine orCreate = currentShift.TenderLines.FindOrCreate(shiftTenderLine);

      orCreate.CountingRequired = shiftTenderLine.CountingRequired;

      orCreate.TenderCurrency = shiftTenderLine.TenderCurrency;

      orCreate.ChangeLine = shiftTenderLine.ChangeLine;

      if (orCreate.ChangeLine)

      {

       orCreate.ChangeAmountOfTenderCurrency = Decimal.Negate(shiftTenderLine.TenderedAmountOfTenderCurrency);

       orCreate.ChangeAmountOfStoreCurrency = Decimal.Negate(shiftTenderLine.TenderedAmountOfStoreCurrency);

      }

      else

      {

       orCreate.TenderedAmountOfTenderCurrency = shiftTenderLine.TenderedAmountOfTenderCurrency;

       orCreate.TenderedAmountOfStoreCurrency = shiftTenderLine.TenderedAmountOfStoreCurrency;

       orCreate.Count = shiftTenderLine.Count;

      }

     }

    }

    private static ShiftTenderLine FindOrCreate(

      this IList shiftTenderLines,

      ShiftTenderLine tenderLine)

    {

     string tenderTypeId = tenderLine.TenderTypeId;

     string tenderCurrency = tenderLine.TenderCurrency;

     string tenderTypeName = tenderLine.TenderTypeName;

     ShiftTenderLine shiftTenderLine = shiftTenderLines.FirstOrDefault((Func)(p =>

     {

      if (p.TenderTypeId == tenderTypeId)

       return p.TenderCurrency == tenderCurrency;

      return false;

     }));

     if (shiftTenderLine == null)

     {

      shiftTenderLine = new ShiftTenderLine()

      {

       TenderTypeId = tenderTypeId,

       CardTypeId = string.Empty,

       TenderCurrency = tenderCurrency,

       TenderTypeName = tenderTypeName

      };

      shiftTenderLines.Add(shiftTenderLine);

     }

     return shiftTenderLine;

    }

    private static void SetRetailTransactionCount(Shift currentShift, Shift endOfDayShift)

    {

     currentShift.VoidTransactionCount = endOfDayShift.VoidTransactionCount;

     currentShift.NoSaleTransactionCount = endOfDayShift.NoSaleTransactionCount;

     currentShift.RoundedAmountTotal = endOfDayShift.RoundedAmountTotal;

     currentShift.TransactionCount = endOfDayShift.TransactionCount;

     currentShift.CustomerCount = endOfDayShift.CustomerCount;

     currentShift.SaleTransactionCount = endOfDayShift.SaleTransactionCount;

    }

  • Omar Hesham Shehab Profile Picture
    on at
    RE: Can not get object Shift in GetCustomReceiptsRequest request

    i would suggest in case the above mentioned piece of code didn't help to solve the issue i'll suggest you to open a service request in order to get into deeper investigation

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Can not get object Shift in GetCustomReceiptsRequest request

    Hi all,

    Currently, I have a solution, in GetEndOfDayShiftDetailsDataRequest,

    we can get object shift with current data in TaxLines and TenderLines, ActiveLines.

    Thanks all for following.

    {

    long channelId = request.RequestContext.GetPrincipal().ChannelId;

    long shiftId = request.RequestContext.GetPrincipal().ShiftId;

    string terminalId = request.RequestContext.GetTerminalId().ToString();

    string hardwareProfileId = request.RequestContext.GetTerminal().HardwareProfile;

    GetEndOfDayShiftDetailsDataRequest detailsDataRequest = new GetEndOfDayShiftDetailsDataRequest(terminalId, shiftId, this.Context.GetChannelConfiguration().PriceIncludesSalesTax);

    Shift entity1 = this.Context.Runtime.Execute<SingleEntityDataServiceResponse<Shift>>((Request)detailsDataRequest, this.Context).Entity;

    }

  • Abigail Profile Picture
    550 on at
    RE: Can not get object Shift in GetCustomReceiptsRequest request

    1. PostOpenShiftTrigger - Non-cancelable - This trigger is executed after the new shift is opened.

    2. PreCloseShiftTrigger - Cancelable - This trigger is executed before the shift is closed.

    Use the second command to make changes in the customer Receipt and get that data before you close that shift.

  • Omar Hesham Shehab Profile Picture
    on at
    RE: Can not get object Shift in GetCustomReceiptsRequest request

    Hi,

    can you please provide some details  regarding to the method "Getshift" and what are you actually trying to achieve using this code

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,983 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans