Thứ Năm, 21 tháng 5, 2020

Create X-Z Report Receipt Service Request By CRT

Create X-Z Report Receipt Service Request in CRT

Song Nghia - Technical Consultant

private GetReceiptServiceRequest CreateXZReportReceiptServiceRequest(GetXAndZReportReceiptRequest request)
 ThrowIf.Null(request, nameof(request));
 long shiftId = request.ShiftId;
 ReceiptType receiptType = request.ReceiptType;
 switch (receiptType)
  case ReceiptType.XReport:
  case ReceiptType.ZReport:
   Shift entity;
   if (receiptType == ReceiptType.XReport)
    string shiftTerminalId = request.ShiftTerminalId;
    entity = this.Context.Execute>((Request)new GetShiftDataRequest(shiftTerminalId, shiftId)).Entity;
    if (entity == null || entity.Status != ShiftStatus.Open && entity.Status != ShiftStatus.BlindClosed)
     throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ShiftNotFound, string.Format("No open shift information can be found using the shift Id {0} on terminal {1} for X report.", (object)shiftId, (object)shiftTerminalId));
    LAW_ShiftCalculator.Calculate(this.Context, entity, entity.TerminalId, entity.ShiftId);
    string terminalId = this.Context.GetTerminal().TerminalId;
    entity = this.Context.Execute>((Request)new GetLastClosedShiftDataRequest(terminalId)).Entity;
    if (entity == null || entity.Status != ShiftStatus.Closed)
     throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ShiftNotFound, string.Format("No closed shift information can be found using the shift Id {0} on terminal {1} for Z report.", (object)shiftId, (object)terminalId));
   return new GetReceiptServiceRequest(entity, new List()
     }.AsReadOnly(), request.HardwareProfileId);
   throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ReceiptTypeNotSupported, "Only receipt types for X or Z reports are expected.");