Exemple #1
0
            private NumberSequenceSeedData GetNumberSequenceDataByReceiptId(SalesTransaction salesTransaction)
            {
                ReceiptTransactionType receiptType = NumberSequenceSeedTypeHelper.GetReceiptTransactionType(salesTransaction.TransactionType, salesTransaction.NetAmountWithNoTax, salesTransaction.CustomerOrderMode);
                NumberSequenceSeedType seedType    = NumberSequenceSeedTypeHelper.GetNumberSequenceSeedType(receiptType);

                // get receipt mask from db
                string      functionalityProfileId = this.GetOrgUnit().FunctionalityProfileId;
                var         getReceiptMaskRequest  = new GetReceiptMaskDataRequest(functionalityProfileId, receiptType);
                ReceiptMask mask = this.Context.Runtime.Execute <SingleEntityDataServiceResponse <ReceiptMask> >(
                    getReceiptMaskRequest,
                    this.Context).Entity;

                // parse receipt number
                long numberSequenceId;

                // if mask is not available, try parsing it as a integer
                if (mask == null)
                {
                    if (!long.TryParse(salesTransaction.ReceiptId, out numberSequenceId))
                    {
                        string message = string.Format("Receipt mask is not available for receipt type {0} when using functionality profile {1}. Parsing receipt identifier as a number failed.", receiptType, functionalityProfileId);
                        RetailLogger.Log.CrtWorkflowParsingReceiptIdentifierFailure(receiptType.ToString(), functionalityProfileId);
                        throw new ConfigurationException(ConfigurationErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidChannelConfiguration, ExceptionSeverity.Warning, message);
                    }
                }
                else
                {
                    numberSequenceId = ReceiptMaskFiller.GetNumberSequenceFromReceipt(mask.Mask, salesTransaction.ReceiptId);
                }

                // compose number sequence seed object
                return(new NumberSequenceSeedData {
                    DataType = seedType, DataValue = IncrementByOne(numberSequenceId)
                });
            }
Exemple #2
0
        public string GetNextReceiptId(IPosTransaction transaction)
        {
            try
            {
                RetailTransaction retailTrans = transaction as RetailTransaction;
                if ((retailTrans != null) && (retailTrans.EntryStatus == PosTransaction.TransactionStatus.Voided))
                {
                    return(string.Empty);
                }


                if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled())
                {
                    return(FiscalPrinter.FiscalPrinter.Instance.GetNextReceiptId(transaction));
                }

                ReceiptTransactionType transType = GetReceiptTransType(transaction);
                string storeId    = LSRetailPosis.Settings.ApplicationSettings.Terminal.StoreId;
                string terminalId = LSRetailPosis.Settings.ApplicationSettings.Terminal.TerminalId;
                string staffId    = transaction.OperatorId;

                // Get the template mask for this type of transaction
                string      mask;
                bool        isIndependent;
                string      funcProfileId = LSRetailPosis.Settings.FunctionalityProfiles.Functions.ProfileId;
                ReceiptData receiptData   = new ReceiptData(Application.Settings.Database.Connection, Application.Settings.Database.DataAreaID, funcProfileId);
                receiptData.GetReceiptMask((int)transType, out mask, out isIndependent);

                // Get the next receipt seed (sequential numeric) value
                NumberSequenceSeedType seedType = NumberSequenceSeedType.ReceiptDefault;
                if (isIndependent)
                {
                    seedType = GetSeedType(transType);
                }
                string seedValue = GetAndIncrementTerminalSeed(seedType).ToString();

                return(ReceiptMaskFiller.FillMask(mask, seedValue, storeId, terminalId, staffId));
            }
            catch (Exception ex)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), ex);
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// Increments the terminal seed value for the type
        /// </summary>
        /// <param name="type">Seed type ID (from SeedTypes class)</param>
        public void IncrementTerminalSeed(NumberSequenceSeedType type)
        {
            SeedValueData seedData = CreateSeedValueData(true);

            seedData.IncrementTerminalSeed(type);
        }
Exemple #4
0
        /// <summary>
        /// Returns the current terminal seed value for the type
        /// </summary>
        /// <param name="type">Seed type ID (from SeedTypes class)</param>
        /// <returns>Seed value</returns>
        public long GetTerminalSeed(NumberSequenceSeedType type)
        {
            SeedValueData seedData = CreateSeedValueData(true);

            return(seedData.GetTerminalSeed(type));
        }
Exemple #5
0
        /// <summary>
        /// Returns the current store seed value for the type, then increments in the database
        /// </summary>
        /// <param name="type">Seed type ID (from SeedTypes class)</param>
        /// <returns>Seed value</returns>
        public long GetAndIncrementStoreSeed(NumberSequenceSeedType type)
        {
            SeedValueData seedData = CreateSeedValueData(false);

            return(seedData.GetAndIncrementStoreSeed(type));
        }