예제 #1
0
        public CardPaymentFactory(
            IRepository <Account> accounts,
            IRepository <UserPaymentProfile> paymentProfiles,
            IRepository <Currency> currencies,
            IQueryRepository <CorrespondentAccount> correspondentAccounts,
            TransactionReferenceBook transactionReferenceBook,
            MoneyConverter moneyConverter,
            PaymentFormFactory paymentFormFactory)
        {
            Argument.NotNull(accounts, "accounts");
            Argument.NotNull(paymentProfiles, "paymentProfiles");
            Argument.NotNull(currencies, "currencies");
            Argument.NotNull(correspondentAccounts, "correspondentAccounts");
            Argument.NotNull(transactionReferenceBook, "transactionReferenceBook");
            Argument.NotNull(moneyConverter, "moneyConverter");
            Argument.NotNull(paymentFormFactory, "paymentFormFactory");

            _settings                 = new BankSettings();
            _currencies               = currencies;
            _correspondentAccounts    = correspondentAccounts;
            _paymentProfiles          = paymentProfiles;
            _accounts                 = accounts;
            _transactionReferenceBook = transactionReferenceBook;
            _moneyConverter           = moneyConverter;
            _paymentFormFactory       = paymentFormFactory;
        }
예제 #2
0
 public Money(int one, int two)
 {
     PairOne = one;
     PairTwo = two;
     InUSD   = MoneyConverter.MoneyConvert(one * 100 + two, "usd");
     InEuro  = MoneyConverter.MoneyConvert(one * 100 + two, "eur");
 }
예제 #3
0
 void CreateInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #4
0
    public void CalculateNextUpgradeCost()
    {
        var controller = UpgradesController.Instance;

        if (Upgrade.Equals(Upgrade.Upgrade2) &&
            UpgradesController.Instance.UpgradesDictionary[Upgrade.Upgrade2] >= 20)
        {
            UpdateText();
            _upgradeButton.GetComponentInChildren <Text>().text = "MAX";
            UpgradeLevel.text = "Level MAX";
            return;
        }

        int currentLevel = controller.UpgradesDictionary[Upgrade];

        _nextUpgradeCost =
            UpgradesConsts.Exponent(_upgradeValues.BaseCost, _upgradeValues.CostMultiplier, currentLevel);

        _upgradeButton.GetComponentInChildren <Text>().text = "$" + MoneyConverter.ConvertNumber(_nextUpgradeCost);

        UpgradeLevel.text = "Level " + controller.UpgradesDictionary[Upgrade];

        ToggleButtonFade();
        UpdateSlider();
        GameController.Instance.UpdateMiningPowerText();
        UpdateText();
    }
예제 #5
0
 public ChuckNorrisPolicy(MoneyConverter converter, IRepository <UserBankOperation> userBankOperationRepository)
 {
     Argument.NotNull(converter, "converter");
     Argument.NotNull(userBankOperationRepository, "userBankOperationRepository");
     _converter = converter;
     _userBankOperationRepository = userBankOperationRepository;
 }
예제 #6
0
        static void Main(string[] args)
        {
            // 1. Skriv ett program som läser in en fil med växlingskurser och
            // sedan konverterar en inmatad valuta till svenska kronor.

            // 2. Skapa sedan ett uppslagsverk med valutanamn och skriv ut namnen på valutorna konverteringen sker emellan.
            // (Valutor lagras på RegionInfo, en egenskap på CultureInfo)

            // 3. Lägg till ett ytterligare val för valuta att konvertera till (förutom SEK).


            MoneyConverter moneyConverter = new MoneyConverter("Resources\\Riksbanken_2020-10-13.csv", "SEK");

            Console.Write("Skriv in önskad växlings-valuta och mängd (tex 100 usd): ");
            string input = Console.ReadLine();

            Console.WriteLine("Skriv vilken valuta du vill växla till (tex, GBP)");
            string currencyInput = Console.ReadLine();

            Money enteredMoney   = MoneyParser.Parse(input);
            Money convertedMoney = moneyConverter.ConvertToTargetCurrency(enteredMoney);

            if (currencyInput != "SEK")
            {
                convertedMoney = moneyConverter.ConvertFromTargetCurrency(convertedMoney.Amount, currencyInput);
            }

            Console.WriteLine($"Dina {enteredMoney} ({GetCurrencyName(enteredMoney)}) blir {convertedMoney} ({GetCurrencyName(convertedMoney)})");
        }
예제 #7
0
 void CreateInstance()
 {
     //if its a need of an instance otherwise it will create one
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #8
0
 public void CalculateNextLevelCost()
 {
     _nextLevelCost = BasicEconomyValues.Exponent(BasicEconomyValues.BaseAscendCost,
                                                  BasicEconomyValues.AscendBias,
                                                  BasicEconomyValues.AscendExponentialMultiplier,
                                                  _maxLevel);
     AscendCostDisplay.text = "$" + MoneyConverter.ConvertNumber(_nextLevelCost);
 }
예제 #9
0
        private void metroFlow1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MoneyConverter converter = new MoneyConverter();
            selectedPerson = metroFlow1.SelectedColumnIndex;
            listBox1.ItemsSource = peopleCollection[selectedPerson].Transactions;
            updateTotal();
 
        }
예제 #10
0
        public void Should_convert_to_monetary()
        {
            var moneyConverter = new MoneyConverter();

            var result = moneyConverter.ConvertToMonetary("234");

            Assert.Equal(234, result);
        }
예제 #11
0
        public void Should_convert_with_comma_on_cents_house()
        {
            var moneyConverter = new MoneyConverter();

            var result = moneyConverter.ConvertToMonetary("234.4");

            Assert.Equal(234.4m, result);
        }
예제 #12
0
    public void UpdateMiningPowerText()
    {
        double DPS = Math.Round(GetAutoStrength() / GetMiningSpeed()) *
                     AutoMiner.Instance.GetMiningSpeedMultiplier();

        MiningPowerDisplay.text =
            MoneyConverter.ConvertNumber(DPS) + " DPS";
    }
예제 #13
0
 public void Scientific()
 {
     MoneyConverter.ChangeNotation(MoneyConverter.Type.Scientific);
     DisableButton(ScientificButton);
     EnableButton(NormalButton);
     EnableButton(SimpleButton);
     UpdateText();
 }
예제 #14
0
        public void TestCalculaRatesRestantes()
        {
            List <Rate> rates = new List <Rate>();
            Rate        rate1 = new Rate
            {
                from = "CAD",
                to   = "EUR",
                rate = "0.51"
            };

            rates.Add(rate1);
            Rate rate2 = new Rate
            {
                from = "EUR",
                to   = "CAD",
                rate = "1.96"
            };

            rates.Add(rate2);
            Rate rate3 = new Rate
            {
                from = "CAD",
                to   = "AUD",
                rate = "0.85"
            };

            rates.Add(rate3);
            Rate rate4 = new Rate
            {
                from = "AUD",
                to   = "CAD",
                rate = "1.18"
            };

            rates.Add(rate4);
            Rate rate5 = new Rate
            {
                from = "EUR",
                to   = "USD",
                rate = "1.1"
            };

            rates.Add(rate5);
            Rate rate6 = new Rate
            {
                from = "USD",
                to   = "EUR",
                rate = "0.91"
            };

            rates.Add(rate6);

            rates = MoneyConverter.GetMissingRates(rates);

            Assert.AreEqual(12, rates.Count);
        }
예제 #15
0
    private void CreateRewardWindow()
    {
        transform.localScale = Vector3.one;
        foreach (Transform child in transform)
        {
            if (child.CompareTag("ExitButton"))
            {
                child.gameObject.GetComponent <Button>().interactable = true;
            }
            if (child.CompareTag("Text"))
            {
                Destroy(child.gameObject);
            }
        }

        double idleTime = GameController.Instance.GetIdleTime();

        KeyValuePair <double, Dictionary <Ore, int> > rewardMoneyOres;

        if (idleTime > 0)
        {
            rewardMoneyOres = IdleReward(idleTime);
        }
        else
        {
            throw new NotSupportedException("Negative idle time");
        }

        double moneyReward = rewardMoneyOres.Key;
        Dictionary <Ore, int> oreReward = rewardMoneyOres.Value;

        Text.text = "<br><size=%27>While you were away<br>you mined:</size><br><br> ";
        if (moneyReward < 1 && oreReward.Count == 0)
        {
            Text.text += "Nothing!<br> ";
        }
        else
        {
            if (moneyReward >= 1)
            {
                Text.text += "<color=#FFFF00><b>+$" + MoneyConverter.ConvertNumber(moneyReward) + "</b></color><br> ";
            }

            if (oreReward.Count != 0)
            {
                foreach (var element in oreReward)
                {
                    Text.text += "<color=#" + ColorUtility.ToHtmlStringRGB(element.Key.DropTextColor) + ">+" +
                                 element.Value + " " + element.Key.Name + "</color><br> ";
                }
            }
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate(transform as RectTransform);
    }
        internal BaseOperationProcessor(BaseOperationProcessorDependencies baseDependencies)
        {
            Argument.NotNull(baseDependencies, "baseDependencies");
            baseDependencies.EnsureIsResolved();
            Logger = LogManager.GetLogger(GetType().FullName);

            MoneyConverter           = baseDependencies.MoneyConverter;
            TransactionRepository    = baseDependencies.TransactionRepository;
            TransactionReferenceBook = baseDependencies.TransactionReferenceBook;
            Settings = new BankSettings();
        }
예제 #17
0
 public CardTransferFactory(IRepository <OperationCategory> operationCategories,
                            TransactionReferenceBook transactionReferenceBook,
                            MoneyConverter moneyConverter)
 {
     Argument.NotNull(operationCategories, "operationCategories");
     Argument.NotNull(transactionReferenceBook, "transactionReferenceBook");
     Argument.NotNull(moneyConverter, "moneyConverter");
     _operationCategories      = operationCategories;
     _transactionReferenceBook = transactionReferenceBook;
     _moneyConverter           = moneyConverter;
     _settings = new BankSettings();
 }
예제 #18
0
        public Startup(IConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            this.network = ZcoinNetworks.Instance.GetNetwork(config.GetZcoinSection().Network.Type);
            this.bitcoinAddressConverter = new BitcoinAddressConverter(this.network);
            this.moneyConverter          = new MoneyConverter();
            this.propertyAmountConverter = new PropertyAmountConverter(config.GetZcoinSection().Property.Type);
            this.uint256Converter        = new UInt256Converter();
        }
예제 #19
0
    private void UpdateText()
    {
        var prestigeBonus = GameController.Instance.GetPrestigeCrystals() *
                            GameController.Instance.GetPrestigeCrystalsMultiplier();

        var productivity = _upgradeValues.Productivity * UpgradesController.CalculateMultiplier(Upgrade);

        productivity += productivity * prestigeBonus;

        if (Upgrade.Equals(Upgrade.Upgrade1))
        {
            var strength = GameController.Instance.GetStrength();

            UpgradeDescription.text =
                "Increases <b>DMG</b> by <b>" + MoneyConverter.ConvertNumber(productivity) + "</b>.";
            ActualProductivity.text = "Current <b>DMG</b> is <b>" + MoneyConverter.ConvertNumber(strength) + "</b>.";

            if (!UpgradesController.Instance.UpgradesDictionary.ContainsKey(Upgrade))
            {
                return;
            }

            NextMultiplier.text =
                "x" + UpgradesController.GetClosestMultiplier(Upgrade);
        }
        else if (Upgrade.Equals(Upgrade.Upgrade2))
        {
            UpgradeDescription.text = "Shortens auto mining interval by <b>" + _upgradeValues.Productivity + "s</b>.";
            ActualProductivity.text =
                "Current mining interval is <b>" + GameController.Instance.GetMiningSpeed() + "s</b>.";
            NextMultiplier.text = "";
        }
        else
        {
            var autoStrength = UpgradesController.CalculateUpgradeProductivity(Upgrade);
            autoStrength += autoStrength * prestigeBonus;

            UpgradeDescription.text =
                "Increases <b>DPS</b> by <b>" + MoneyConverter.ConvertNumber(productivity) + "</b>.";
            ActualProductivity.text =
                "Current <b>DPS</b> is <b>" + MoneyConverter.ConvertNumber(autoStrength) + "</b>.";

            if (!UpgradesController.Instance.UpgradesDictionary.ContainsKey(Upgrade))
            {
                return;
            }

            NextMultiplier.text =
                "x" + UpgradesController.GetClosestMultiplier(Upgrade);
        }
    }
예제 #20
0
    public void UpdateReward()
    {
        var controller = GameController.Instance;
        var reward     = CalculateReward();

        RewardedAmount.text         = "+" + MoneyConverter.ConvertNumber(reward);
        PrestigeButton.interactable = !(reward < 1);
        MultiplierText.text         = "Your current global multiplier x" +
                                      Math.Round(1 + 1 * controller.GetPrestigeCrystals() * controller.GetPrestigeCrystalsMultiplier(),
                                                 2) +
                                      " will increase to x" +
                                      Math.Round(1 + 1 * reward * controller.GetPrestigeCrystalsMultiplier() +
                                                 1 * controller.GetPrestigeCrystals() * controller.GetPrestigeCrystalsMultiplier(), 2);
    }
예제 #21
0
        // GET: api/Rates
        public async Task <HttpResponseMessage> Get()
        {
            try
            {
                //Obtener todas las conversiones de moneda
                String rates = await MoneyConverter.GetAllRates();

                //Generar respuesta
                HttpResponseMessage respuesta = this.Request.CreateResponse(HttpStatusCode.OK);
                respuesta.Content = new StringContent(rates, Encoding.UTF8, "application/json");
                return(respuesta);
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);

                HttpResponseMessage respuesta = this.Request.CreateResponse(HttpStatusCode.Conflict);
                respuesta.Content = new StringContent(e.Message, Encoding.UTF8, "application/text");
                return(respuesta);
            }
        }
        static void Main(string[] args)
        {
            // 1. Skriv ett program som läser in en fil med växlingskurser och
            // sedan konverterar en inmatad valuta till svenska kronor.

            // Exempelvis: 100 USD, eller 50 GBP

            // Exempelvis ut: 900 SEK

            // 2. Skapa sedan ett uppslagsverk med valutanamn och skriv ut namnen på valutorna konverteringen sker emellan.
            // (Valutor lagras på RegionInfo, en egenskap på CultureInfo)

            // Alla CultureInfo-objekt kan hämtas via CultureInfo.GetCultures(CultureTypes.SpecificCultures)

            // 3. Lägg till ett ytterligare val för valuta att konvertera till (förutom SEK).

            // Exempelvis: 100 USD -> GBP eller AUD

            string         targetCurrency = "SEK";
            string         targetPath     = "Resources\\Riksbanken_2020-10-13.csv";
            MoneyConverter moneyConverter = new MoneyConverter(targetPath, targetCurrency);

            Console.WriteLine("Skriv in önskad växlings-valuta och mängd (t.ex. 100 USD)");
            string input = Console.ReadLine();

            Console.WriteLine("Skriv vilken valuta du vill växla till (t.ex. GBP)");
            string currencyInput = Console.ReadLine();

            Money enteredMoney   = MoneyParser.Parse(input);
            Money convertedMoney = moneyConverter.ConvertToTargetCurrency(enteredMoney);

            if (currencyInput != targetCurrency)
            {
                convertedMoney = moneyConverter.ConvertFromTargetCurrency(convertedMoney.Amount, currencyInput);
            }

            Console.WriteLine($"Dina {enteredMoney} ({GetCurrencyName(enteredMoney)}) blir {convertedMoney} ({GetCurrencyName(convertedMoney)})");
        }
예제 #23
0
        private void dgShiftRequestQueryResult_LoadingDataSource(object sender, LoadingDataEventArgs e)
        {
            txtTotal.Text = string.Empty;
            PageView.QueryInfo.PagingInfo = new QueryFilter.Common.PagingInfo
            {
                PageIndex = e.PageIndex,
                PageSize  = e.PageSize,
                SortBy    = e.SortField
            };

            #region 获取自己能访问到的PM
            PageView.QueryInfo.UserSysNo   = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.LoginUser.UserSysNo;
            PageView.QueryInfo.UserName    = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.LoginUser.LoginName;
            PageView.QueryInfo.CompanyCode = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;
            if (AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_SeniorPM_Query))
            {
                PageView.QueryInfo.PMQueryRightType = BizEntity.Common.PMQueryType.AllValid;
            }
            else if (AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_IntermediatePM_Query))
            {
                PageView.QueryInfo.PMQueryRightType = BizEntity.Common.PMQueryType.Team;
            }
            else if (AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_JuniorPM_Query))
            {
                PageView.QueryInfo.PMQueryRightType = BizEntity.Common.PMQueryType.Self;
            }
            else
            {
                PageView.QueryInfo.PMQueryRightType = null;
            }

            #endregion

            ExportQuery = PageView.QueryInfo.DeepCopy();
            QueryFacade.QueryShiftRequest(PageView.QueryInfo, (totalCount, vmList) =>
            {
                PageView.Result     = DynamicConverter <ShiftRequestVM> .ConvertToVMList(vmList);
                PageView.TotalCount = totalCount;
                dgShiftRequestQueryResult.ItemsSource = PageView.Result;
                dgShiftRequestQueryResult.TotalCount  = PageView.TotalCount;
                btnTotal.IsEnabled = btnBatchSpecial.IsEnabled = btnCancelBatchSpecial.IsEnabled
                                                                     = btnBatchLog.IsEnabled = totalCount > 0;
                if (totalCount > 0)
                {
                    QueryFacade.QueryShiftDataCount(PageView.QueryInfo, (countSender, countArgs) => {
                        if (countArgs.FaultsHandle())
                        {
                            return;
                        }

                        var listAll = countArgs.Result.ToList();
                        if (listAll.Count > 0)
                        {
                            int outStockSheetQuantity      = 0;
                            int inStockSheetQuantity       = 0;
                            decimal outStockAmount         = 0;
                            decimal inStockAmount          = 0;
                            int partlyInStockSheetQuantity = 0;
                            decimal partlyOutStockAmount   = 0;
                            decimal partlyInStockAmount    = 0;
                            decimal partlyTransferAmount   = 0;

                            foreach (var item in listAll[0].Rows)
                            {
                                if (((int)item["status"]) == 3)
                                {
                                    outStockSheetQuantity = (int)item["TotalNum"];
                                    outStockAmount        = (decimal)item["TotalCost"];
                                }
                                //in stock
                                else
                                {
                                    inStockSheetQuantity = (int)item["TotalNum"];
                                    inStockAmount        = (decimal)item["TotalCost"];
                                }
                            }
                            if (listAll.Count > 1 && listAll[1].Rows.ToList().Count > 0)
                            {
                                partlyInStockSheetQuantity = (int)listAll[1].Rows[0]["partlyNum"];
                                partlyInStockAmount        = (decimal)listAll[1].Rows[0]["inCost"];
                                partlyOutStockAmount       = (decimal)listAll[1].Rows[0]["outCost"];
                                partlyTransferAmount       = (decimal)listAll[1].Rows[0]["inWayCost"];
                            }
                            txtTotal.Text = string.Format(ResShiftRequestQuery.Msg_Format_CountData
                                                          , outStockSheetQuantity
                                                          , MoneyConverter.ConvertToString(outStockAmount)
                                                          , inStockSheetQuantity
                                                          , MoneyConverter.ConvertToString(inStockAmount)
                                                          , partlyInStockSheetQuantity
                                                          , MoneyConverter.ConvertToString(partlyOutStockAmount)
                                                          , MoneyConverter.ConvertToString(partlyInStockAmount)
                                                          , MoneyConverter.ConvertToString(partlyTransferAmount)
                                                          );
                        }
                    });
                }

                if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Inventory_ShiftRequestQuery_Total))
                {
                    btnTotal.IsEnabled = false;
                }
                if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Inventory_ShiftRequestQuery_BatchSpecial))
                {
                    btnBatchSpecial.IsEnabled = false;
                }
                if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Inventory_ShiftRequestQuery_CancelBatchSpecial))
                {
                    btnCancelBatchSpecial.IsEnabled = false;
                }
                if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Inventory_ShiftRequestQuery_BatchLog))
                {
                    btnBatchLog.IsEnabled = false;
                }
            });
        }
예제 #24
0
 private void UpdateSlider()
 {
     _slider.value       = Convert.ToSingle(Health / MaxHealth);
     _hpLeftDisplay.text =
         MoneyConverter.ConvertNumber(Health) + " / " + MoneyConverter.ConvertNumber(MaxHealth);
 }
예제 #25
0
        private void CreateMoneyRewardText(double money)
        {
            string moneyRewardString = "+$" + MoneyConverter.ConvertNumber(money);

            CreateRewardText(moneyRewardString, Color.yellow);
        }
예제 #26
0
 public void UpdateOwnedAmount()
 {
     OwnedAmount.text = MoneyConverter.ConvertNumber(GameController.Instance.GetPrestigeCrystals());
 }
 public void Setup()
 {
     _moneyConverter = new MoneyConverter();
 }
        private Packet CreateCashTransaction35(Transaction transaction, bool online, ManualCashBox manualCashBox, Card card, Tariff tariff)
        {
            Packet p = new Packet(PacketType.Long);

            p.LongCommand = (byte)LongCommands.CashTransaction;

            byte[] data = p.Data;


            //networkAddress
            data[0] = (byte)manualCashBox.NetworkAddress;
            //version
            data[1] = 1;
            //type
            data[2] = (byte)CashMessageType.Transaction;
            //timeStamp
            Utils.PackDateTime(data, 3, transaction.Time, false);
            //isOnline
            data[9] = (byte)(online ? 1 : 0);
            //lastSessionOpenTime
            Utils.PackDateTime(data, 10, DataContract.DefaultDateTime, false);

            //transactionType
            //    CashTransactionType transactionType = IsOneOf(50) ? RuntimeHelper.GetRandomValue<CashTransactionType>() : CashTransactionType.Payment;
            data[16] = (byte)transaction.Type;
            //paymentMethod
            data[17] = (byte)transaction.PaymentMethod;
            //sessionID
            //sessionID
            data[18] = 0;
            data[19] = 0;
            //amount
            int amount = MoneyConverter.FromMoney(transaction.Payment);

            Int32ToBuffer(data, 20, amount);

            //amount = amountInCurrentZone + debt - discount + fine - prepayment
            //int amount = 0;
            //int amountInCurrentZone = GenerateMoney(50, 5000);
            //int debt = IsOneOf(5) ? 0 : GenerateMoney(50, 5000);
            //amount = amountInCurrentZone + debt;
            //int discount = (IsOneOf(10) ? amount : (IsOneOf(10) ? (int)(amount * Math.Min(MathHelper.Rnd.NextDouble(), 0.5)) : 0)) / MoneyDiscrete;
            //discount *= MoneyDiscrete;
            //amount -= discount;
            //int fine = IsOneOf(10) ? 0 : GenerateMoney(50, 1000);
            //amount += fine;
            //int prepayment = IsOneOf(10) ? 0 : GenerateMoney(200, 2000);
            //amount -= prepayment;
            //amount = Math.Max(0, amount);
            //BufferHelper.Int32ToBuffer(data, 20, MoneyConverter.FromMoney(amount));

            //completed
            data[24] = 0;

            //long cardID = BufferHelper.BufferToInt32(transaction.Data, 8);
            //if (((CardType)transaction.Data[13]).IsLightweight())
            //    cardID = DataExtensions.ConvertLightweightCardID(cardID);

            //Card card = GetService<ICardManager>()[cardID];
            //if (card != null)
            //{
            //    //customerFacilityID
            //    data[25] = (byte)card.Type;
            //    //customerParams
            //    BufferHelper.Int32ToBuffer(data, 26, (int)(card.ID & 0xFFFFFFFF));
            //    //BufferHelper.IntToBuffer(data, 30, (int)(card.ID >> 32));
            //    //customerType
            //    data[46] = (byte)card.CustomerType;
            //    //customerGroupID
            //    data[47] = (byte)(card.CustomerGroupID & 0xFF);
            //}

            //customerFacilityID
            data[25] = (card != null) ? (byte)card.Type : (byte)0;
            //customerParams
            long cardID = transaction.CardID;

            Int32ToBuffer(data, 26, (int)(cardID & 0xFFFFFFFF));
            Int32ToBuffer(data, 30, (int)(cardID >> 32));
            //customerType
            data[46] = (byte)transaction.CustomerType;
            //customerGroupID
            data[47] = (byte)(transaction.CustomerGroupID & 0xFF);

            if (tariff != null)
            {
                var tariff30 = tariff as Tariff30;
                if (tariff30 != null)
                {
                    //tariffType
                    data[48] = (byte)tariff30.Type;
                    //tariffGroup
                    data[49] = (byte)tariff30.Class;
                }
                //tariffID
                data[50] = (byte)(tariff.ID & 0xFF);
            }

            ////timeEntry
            //DateTime dte = Utils.UnpackDateTime(transaction.Data, 40);
            //Utils.PackDateTime(data, 51, dte, false);
            ////timePayment
            //DateTime dtp = dte.AddMinutes(MathHelper.Rnd.Next(5, 300));
            //Utils.PackDateTime(data, 57, dtp, false);
            ////timeExit
            //Utils.PackDateTime(data, 63, IsOneOf(2) ? dtp : dtp.AddMinutes(-dtp.Minute).AddHours(1), false);
            ////amountInCurrentZone
            //BufferHelper.Int32ToBuffer(data, 69, MoneyConverter.FromMoney(amountInCurrentZone));
            ////debt
            //BufferHelper.Int32ToBuffer(data, 73, MoneyConverter.FromMoney(debt));
            ////discount
            //BufferHelper.Int32ToBuffer(data, 77, MoneyConverter.FromMoney(discount));
            ////fine
            //BufferHelper.Int32ToBuffer(data, 81, MoneyConverter.FromMoney(fine));
            ////prepayment
            //BufferHelper.Int32ToBuffer(data, 85, MoneyConverter.FromMoney(prepayment));
            ////income
            //int income = ((m == PaymentMethod.Cash) ? (IsOneOf(10) ? (int)(amount * 1.5) : amount) : amount) / MoneyDiscrete;
            //income *= MoneyDiscrete;
            //BufferHelper.Int32ToBuffer(data, 89, MoneyConverter.FromMoney(income));
            ////change
            //int change = income - amount;
            //BufferHelper.Int32ToBuffer(data, 93, MoneyConverter.FromMoney(change));
            ////amountLeftOnError
            //int amountLeftOnError = ((m == PaymentMethod.Cash) ? (IsOneOf(100) ? (int)(change * Math.Min(MathHelper.Rnd.NextDouble(), 0.5)) : 0) : 0) / MoneyDiscrete;
            //amountLeftOnError *= MoneyDiscrete;
            //BufferHelper.Int32ToBuffer(data, 97, MoneyConverter.FromMoney(amountLeftOnError));

            ////receiptState
            //EjectionResult receiptState = (IsOneOf(20) ? RuntimeHelper.GetRandomValue<EjectionResult>() : EjectionResult.OK);
            //data[101] = (byte)receiptState;
            ////bankingCardState
            //EjectionResult bankingCardState = ((m == PaymentMethod.BankingCard) ? (IsOneOf(20) ? RuntimeHelper.GetRandomValue<EjectionResult>() : EjectionResult.OK) : EjectionResult.Unknown);
            //data[102] = (byte)bankingCardState;
            ////ticketState
            //EjectionResult ticketState = (IsOneOf(20) ? RuntimeHelper.GetRandomValue<EjectionResult>() : EjectionResult.OK);
            //data[103] = (byte)ticketState;
            ////errorCode
            //byte errorCode = (byte)(((receiptState == EjectionResult.NotEjected) || (bankingCardState == EjectionResult.NotEjected) || (ticketState == EjectionResult.NotEjected)) ? MathHelper.Rnd.Next(1, 255) : 0);
            //data[104] = errorCode;


            //timeEntry
            Utils.PackDateTime(data, 51, transaction.TimeEntry, false);
            //timePayment
            Utils.PackDateTime(data, 57, transaction.TimePayment, false);
            //timeExit
            Utils.PackDateTime(data, 63, transaction.TimeExit, false);
            //amountInCurrentZone
            Int32ToBuffer(data, 69, amount);
            //debt
            Int32ToBuffer(data, 73, MoneyConverter.FromMoney(transaction.Debt));
            //discount
            Int32ToBuffer(data, 77, MoneyConverter.FromMoney(transaction.Discounts.Sum(d => d.Amount)));
            //fine
            Int32ToBuffer(data, 81, MoneyConverter.FromMoney(0));
            //prepayment
            Int32ToBuffer(data, 85, MoneyConverter.FromMoney(0));
            //income
            Int32ToBuffer(data, 89, amount);
            //change
            Int32ToBuffer(data, 93, MoneyConverter.FromMoney(0));
            //amountLeftOnError
            Int32ToBuffer(data, 97, MoneyConverter.FromMoney(0));

            //receiptState
            data[101] = (byte)EjectionResult.OK;
            //bankingCardState
//        EjectionResult bankingCardState = ((m == PaymentMethod.BankingCard) ? EjectionResult.OK : EjectionResult.Unknown);
            data[102] = (byte)EjectionResult.Unknown;
            //ticketState
            data[103] = (byte)EjectionResult.OK;
            //errorCode
            data[104] = 0;


            //if (m == PaymentMethod.Cash)
            //{
            //    IEnumerable<int> wb = null;
            //    IEnumerable<int> wc = null;
            //    int j = 105;
            //    if (amount > 0)
            //    {
            //        //banknotes
            //        int banknoteAmount = IsOneOf(10) ? (3 * amount / 5) : amount;
            //        int coinAmount = amount - banknoteAmount;
            //        int r;
            //        wb = MoneyConverter.BanknoteNominals.Weigh(banknoteAmount, out r);
            //        foreach (int n in wb)
            //            data[j++] = (byte)n;

            //        j += 2; //reserved
            //        coinAmount += r;

            //        CashFiscalState f = SafeGetFiscalState(c.ID);
            //        f.UpdateBanknotes(wb);

            //        //coins
            //        if (coinAmount > 0)
            //        {
            //            wc = MoneyConverter.CoinNominals.Weigh(MoneyConverter.FromMoney(coinAmount));
            //            foreach (int n in wc)
            //            {
            //                data[j] = (byte)n;
            //                j += 2;
            //            }

            //            f.UpdateCoins(wc);
            //        }
            //    }

            //    //upperDispenserCassetteOutput
            //    //BufferHelper.Int16ToBuffer(data, j, (wb != null) ? wb.Sum() : 0);
            //    j += 2;
            //    //middleDispenserCassetteOutput
            //    j += 2;
            //    //lowerDispenserCassetteOutput
            //    j += 2;
            //    //nearHopperOutput
            //    //BufferHelper.Int16ToBuffer(data, j, (wc != null) ? wc.Sum() : 0);
            //    j += 2;
            //    //farHopperOutput
            //    //j += 2;

            //    p.DataLength = 138;
            //}
            //else if (m == PaymentMethod.BankingCard)
            //{
            //    //referenceNumber
            //    StringBuilder sb = new StringBuilder(12);
            //    for (int i = 0; i < 3; i++)
            //        sb.AppendFormat("{0:0000}", MathHelper.Rnd.Next(1, 9999));

            //    byte[] ba = CashMessageEncoding.GetBytes(sb.ToString());
            //    Buffer.BlockCopy(ba, 0, data, 105, 12);

            //    //answerCode
            //    ba = CashMessageEncoding.GetBytes("00");
            //    Buffer.BlockCopy(ba, 0, data, 117, 2);

            //    //card info
            //    sb.Length = 0;
            //    for (int i = 0; i < 4; i++)
            //        sb.AppendFormat("{0:0000}", MathHelper.Rnd.Next(1, 9999));
            //    string cn = sb.ToString();
            //    sb.Length = 0;
            //    sb.AppendFormat("{1}{0}{2}{0}{3}{0}{4}{0}", (char)0x1B,
            //      MathHelper.Rnd.Next(1, 9999999), cn, "VISA", String.Empty);
            //    ba = CashMessageEncoding.GetBytes(sb.ToString());
            //    Buffer.BlockCopy(ba, 0, data, 119, ba.Length);

            //    p.DataLength = (byte)(119 + ba.Length);
            //}

            ////update counters for extended status
            //c.Update(m, amount, income, change, amountLeftOnError);
            return(p);
        }
예제 #29
0
        public async Task TestMethodConvertAmountAsync()
        {
            Assert.AreEqual("10", await MoneyConverter.ConvertAmount("CAD", "CAD", "10")); // Monto sin tratamiento

            Assert.IsNotNull(await MoneyConverter.ConvertAmount("CAD", "EUR", "10"));
        }
 public override string ToString()
 {
     return(String.Format("ResponseCode = {0}\r\nGSCCode = {1}\r\nReceiptID = {2}\r\nAmount = {3}\r\nTotal = {4}\r\nPAN = {5}", ResponseCode, GCSCode, ReceiptID,
                          DataFormatter.FormatMoney(MoneyConverter.ToMoney(Amount)), DataFormatter.FormatMoney(MoneyConverter.ToMoney(Total)), PAN));
 }
예제 #31
0
 private void SetMoneyText()
 {
     MoneyDisplay.text = "$" + MoneyConverter.ConvertNumber(_money);
 }