/// <summary>
            /// Gets the object of non sales tender operation.
            /// </summary>
            /// <param name="context">The request context.</param>
            /// <param name="shiftId">The shift identifier.</param>
            /// <param name="shiftTerminalId">The shift terminal identifier.</param>
            /// <param name="tenderType">The non sale tender type.</param>
            /// <returns>The non sales tender operation object.</returns>
            internal static NonSalesTransaction ConvertToNonSalesTenderTransaction(RequestContext context, string shiftId, string shiftTerminalId, TransactionType tenderType)
            {
                var transaction = new NonSalesTransaction
                {
                    ShiftId         = shiftId,
                    TransactionType = tenderType,
                    TenderTypeId    = StoreOperationServiceHelper.GetCashTenderTypeIdentifier(context), // Default it to cash.
                    StoreId         = context.GetOrgUnit().OrgUnitNumber,
                    StaffId         = context.GetPrincipal().UserId,
                    TerminalId      = context.GetTerminal().TerminalId,
                    ShiftTerminalId = string.IsNullOrWhiteSpace(shiftTerminalId) ? context.GetPrincipal().ShiftTerminalId : shiftTerminalId
                };

                return(transaction);
            }
            /// <summary>
            /// Gets the object of non sales tender operation.
            /// </summary>
            /// <param name="context">The request context.</param>
            /// <param name="nonSaleTenderServiceRequest">The non-sale shift tender operation request.</param>
            /// <returns>The non sales tender operation object.</returns>
            internal static NonSalesTransaction ConvertToNonSalesTenderTransaction(RequestContext context, SaveNonSaleTenderServiceRequest nonSaleTenderServiceRequest)
            {
                string channelCurrency = context.GetChannelConfiguration().Currency;
                var    transaction     = new NonSalesTransaction
                {
                    Id                          = nonSaleTenderServiceRequest.TransactionId,
                    ShiftId                     = nonSaleTenderServiceRequest.ShiftId,
                    ShiftTerminalId             = string.IsNullOrWhiteSpace(nonSaleTenderServiceRequest.ShiftTerminalId) ? context.GetPrincipal().ShiftTerminalId : nonSaleTenderServiceRequest.ShiftTerminalId,
                    Description                 = nonSaleTenderServiceRequest.Description,
                    TransactionType             = nonSaleTenderServiceRequest.TransactionType,
                    TenderTypeId                = StoreOperationServiceHelper.GetCashTenderTypeIdentifier(context), // Default it to cash.
                    StoreId                     = context.GetOrgUnit().OrgUnitNumber,
                    StaffId                     = context.GetPrincipal().UserId,
                    TerminalId                  = context.GetTerminal().TerminalId,
                    ChannelCurrencyExchangeRate = StoreOperationServiceHelper.GetExchangeRate(context),
                    Amount                      = nonSaleTenderServiceRequest.Amount,        // amount in store currency
                    ForeignCurrency             = string.IsNullOrWhiteSpace(nonSaleTenderServiceRequest.Currency) ? channelCurrency : nonSaleTenderServiceRequest.Currency,
                    ChannelCurrency             = context.GetChannelConfiguration().Currency // channel currency code
                };

                // Retrieve the amount in foreign currency with the exchange rate between foreign and channel currency
                Tuple <decimal, decimal> foreignCurrencyValues = StoreOperationServiceHelper.GetForeignCurrencyValues(context, transaction.Amount, transaction.ForeignCurrency);

                transaction.AmountInForeignCurrency     = foreignCurrencyValues.Item1;      // foreign currency amount
                transaction.ForeignCurrencyExchangeRate = foreignCurrencyValues.Item2;      // foreign currency exchange rate

                // Retrieve the amount in company currency with the exchange rate between foreign and company currency
                Tuple <decimal, decimal> companyCurrencyValues = StoreOperationServiceHelper.GetCompanyCurrencyValues(context, transaction.AmountInForeignCurrency, transaction.ForeignCurrency);

                transaction.AmountInCompanyCurrency     = companyCurrencyValues.Item1;  // amount MST
                transaction.CompanyCurrencyExchangeRate = companyCurrencyValues.Item2;  // exchange rate MST

                if (nonSaleTenderServiceRequest.ReasonCodeLines != null && nonSaleTenderServiceRequest.ReasonCodeLines.Any())
                {
                    // Read reason code details from service request for open drawer operation
                    transaction.ReasonCodeLines = new Collection <ReasonCodeLine>();
                    foreach (var reasonCodeLine in nonSaleTenderServiceRequest.ReasonCodeLines)
                    {
                        transaction.ReasonCodeLines.Add(reasonCodeLine);
                    }
                }

                return(transaction);
            }