Example #1
0
        public string this[string columnName]
        {
            get
            {
                error = null;
                if (columnName == "Quantity")
                {
                    if (Quantity <= 0 || string.IsNullOrWhiteSpace(Quantity.ToString()))
                    {
                        error = "Favor ingresar una cantidad correcta";
                    }
                }
                if (columnName == "TransactionAmount")
                {
                    if (TransactionAmount <= 0 || string.IsNullOrWhiteSpace(TransactionAmount.ToString()))
                    {
                        error = "Favor ingresar una cantidad correcta";
                    }
                }

                if (columnName == "Justification")
                {
                    if (string.IsNullOrWhiteSpace(Justification))
                    {
                        error = "Favor ingresar una justificacion";
                    }
                }
                return(error);
            }

            #endregion
        }
        private async Task CreateTransactionAsync()
        {
            if (IsBusy)
            {
                return;
            }

            if (TransactionAmount.Validate() == false)
            {
                return;
            }

            if (CounteragentView == null)
            {
                DialogService.ShowInformationUserMessage(this, "Counteragent not set", "Cancel");
                return;
            }

            if (TransactionAmount.Value > UserBalance)
            {
                DialogService.ShowInformationUserMessage(this, "Transaction amount greater than user balance.", "Cancel");
                return;
            }

            if (Description == null)
            {
                Description = "";
            }

            IsBusy = true;

            try
            {
                var authToken = _settingsService.AuthAccessToken;
                await _transactionsService.PostTransaction(authToken, CounteragentView.Value.UserId, TransactionAmount.Value, Description);

                DialogService.ShowInformationUserMessage(this, "Transfer Completed", "Ok");

                await NavigationService.NavigationToBackAsync();
            }
            catch (ServiceAuthenticationException ex)
            {
                Debug.WriteLine($"[RetrieveData] Error Retrieve Data: {ex}");
                await LogoutAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[RetrieveData] Error Retrieve Data: {ex}");
                DialogService.ShowInformationUserMessage(this, "Unable to connect service, check for Internet availability", "Cancel");
            }
            finally
            {
                IsBusy = false;
            }
        }
        public override int GetHashCode()
        {
            var hashCode = 1253119681;

            hashCode = hashCode * -1521134295 + Type.GetHashCode();
            hashCode = hashCode * -1521134295 + DatePosted.GetHashCode();
            hashCode = hashCode * -1521134295 + TransactionAmount.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Memo);

            return(hashCode);
        }
Example #4
0
 public override string ToString()
 {
     return("[TransactionLog: " +
            " ID = " + ID.ToString() +
            " UserID = " + UserID +
            " ReferenceNumber = " + ReferenceNumber +
            " Transactions = " + Transactions +
            " TransactionDate = " + TransactionDate +
            " TransactionType = " + TransactionType +
            " FromAccount = " + FromAccount +
            " ToAccount = " + ToAccount +
            " TransactionAmount = " + TransactionAmount.ToString() +
            " Remarks = " + Remarks + "]");
 }
Example #5
0
        public void TransactionConstructorTest_DefaultConstructor_EqualsNewObject()
        {
            var expectedObject = new TransactionAmount();

            expectedObject.CallNonPublicSetter(x => x.CopperTotal, 0);
            expectedObject.CallNonPublicSetter(x => x.PlatinumAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.GoldAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.SilverAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.CopperAmount, 0);

            var actualObject = new TransactionAmount();

            Assert.AreEqual(expectedObject, actualObject);
        }
Example #6
0
        public void TransactionConstructorTest_ProvideTotalCopperInConstructor_EqualNewObject(int totalCopper, int platAmount, int goldAmount, int silverAmount, int copperAmount)
        {
            var expectedObject = new TransactionAmount();

            expectedObject.CallNonPublicSetter(x => x.CopperTotal, totalCopper);
            expectedObject.CallNonPublicSetter(x => x.PlatinumAmount, platAmount);
            expectedObject.CallNonPublicSetter(x => x.GoldAmount, goldAmount);
            expectedObject.CallNonPublicSetter(x => x.SilverAmount, silverAmount);
            expectedObject.CallNonPublicSetter(x => x.CopperAmount, copperAmount);

            var actualObject = new TransactionAmount(totalCopper);

            Assert.AreEqual(expectedObject, actualObject);
        }
Example #7
0
        public void GetHashCodeTest()
        {
            var expectedObject = new TransactionAmount();

            expectedObject.CallNonPublicSetter(x => x.CopperTotal, 10);
            expectedObject.CallNonPublicSetter(x => x.PlatinumAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.GoldAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.SilverAmount, 0);
            expectedObject.CallNonPublicSetter(x => x.CopperAmount, 10);

            var actualObject = new TransactionAmount(10);

            Assert.AreEqual(expectedObject.GetHashCode(), actualObject.GetHashCode());
        }
Example #8
0
        public void EqualsTest_ExpectedObjectReferencesActualObject_ExpectTrue()
        {
            //// Arrange

            TransactionAmount expectedObject = new TransactionAmount(100);

            //// Act

            TransactionAmount actualObject = expectedObject;

            //// Assert

            Assert.IsTrue(actualObject.Equals(expectedObject));
            Assert.IsTrue(actualObject == expectedObject);
        }
Example #9
0
        public void EqualsTest_ExpectedObjectComparedToNull_ExpectUnequal()
        {
            //// Arrange

            TransactionAmount expectedObject = null;

            //// Act

            TransactionAmount actualObject = new TransactionAmount(10);

            //// Assert

            Assert.IsFalse(actualObject.Equals(expectedObject));
            Assert.IsTrue(expectedObject != actualObject);
        }
Example #10
0
        private TransactionAmount make_TransactionAmount(PaymentModel paymentModel)
        {
            TransactionAmount transactionAmount = new TransactionAmount();

            if (ConfigurationManager.AppSettings["PublishEnvironment"].ToString() == "SIT" || ConfigurationManager.AppSettings["PublishEnvironment"].ToString() == "UAT")
            {
                transactionAmount.paymentAmount = 100;
            }
            else
            {
                transactionAmount.paymentAmount = (int.Parse(paymentModel.PayableAmount) * 100);
            }
            transactionAmount.currency = "LKR";

            return(transactionAmount);
        }
Example #11
0
        public async Task <EstimationDto> CreateEstimationAsync(string from, string to, decimal transferAmount, CancellationToken cxlToken)
        {
            if (!await _countryService.IsSupportedCountryAsync(from, to, cxlToken))
            {
                throw new ArgumentException("Country not supported");
            }

            TransactionAmount allowedAmount = await _paymentService.TransactionRangeAsync(from);

            if (transferAmount < allowedAmount.MinAmount || transferAmount > allowedAmount.MaxAmount)
            {
                throw new ArgumentException($"Transfer amount must be between {allowedAmount.MinAmount} and {allowedAmount.MaxAmount}");
            }

            var fees = await _taxAndFeeService.GetFeeAsync(from, to, transferAmount, cxlToken);

            var applicableRate = await _exchangeService.GetExchangeRateAsync(from, to, cxlToken);

            var recieveAmount = Math.Round(applicableRate * transferAmount, Accuracy, MidpointRounding.AwayFromZero);

            var applicablePaymentModes = await _paymentService.GetPaymentModesAsync(from);

            var applicableTaxes = await _taxAndFeeService.GetTaxAsync(from, transferAmount, cxlToken);

            var estimation = new EstimationDto
            {
                EstimationId    = Guid.NewGuid().ToString(),
                ExchangeRate    = applicableRate,
                AmountToSend    = transferAmount,
                AmountToRecieve = recieveAmount,
                Fees            = fees,
                PaymentModes    = applicablePaymentModes,
                Taxes           = applicableTaxes
            };
            await _estimationRepository.SaveEstimationAsync(estimation.EstimationId, EstimationDto.ToString(estimation));

            return(estimation);
        }
Example #12
0
 //display transaction amount and type and date when converting to string
 public override string ToString()
 {
     return(TransactionAmount.ToString() + " " + TransactionType + " " + TransactionDate.ToShortDateString());
 }
Example #13
0
        private void RaiseDisplayChanged()
        {
            var sb = new StringBuilder();

            if (_state == ControlUnitState.Maintenance)
            {
                sb.AppendLine("OUT OF ORDER");
                sb.AppendLine("Sales report: ");

                double total = 0;                 // calculate sales report
                for (int i = 0; i < ControlUnit.Instance.VendingProcessor.ProductSlots.Length; i++)
                {
                    var p = ControlUnit.Instance.VendingProcessor.ProductSlots[i];
                    total += p.Price * p.TotalSold;
                    sb.AppendLine(p.Name + ", sold " + p.TotalSold + "= £" + (p.Price * p.TotalSold).ToString("#0.00"));
                }

                sb.AppendLine("Total = £" + total.ToString("#0.00"));
            }
            else if (_state == ControlUnitState.Ready)
            {
                if (String.IsNullOrEmpty(Error))
                {
                    sb.AppendLine("CHOOSE DRINK");
                }
                else
                {
                    sb.AppendLine(Error);
                }
            }
            else if (_state == ControlUnitState.Release || _state == ControlUnitState.Finalize)
            {
                sb.AppendLine("THANK YOU. . .");
            }
            else if (_state == ControlUnitState.Transaction)
            {
                if (NoChange)
                {
                    sb.AppendLine("NO CHANGE");
                }
                else
                {
                    if (String.IsNullOrEmpty(Error))
                    {
                        sb.AppendLine("INSERT COINS PLEASE");
                    }
                    else
                    {
                        sb.AppendLine(Error);
                    }
                }
            }
            else
            {
                sb.AppendLine("ERROR!");
            }

            if (_state == ControlUnitState.Transaction)              // Show product name, cost, and current transaction amount
            {
                sb.AppendLine(ChosenProduct.Name);
                sb.AppendLine("Cost: £" + ChosenProduct.Price.ToString("#0.00"));
                sb.AppendLine("Cash Inserted : £" + TransactionAmount.ToString("#0.00"));
            }

            if (OnDisplayChanged != null)
            {
                OnDisplayChanged(sb.ToString());
            }
        }
Example #14
0
 /// <summary>
 /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </returns>
 public override string ToString()
 {
     return(string.Format(Resources.Culture, Resources.InvestmentTransactionDisplay, Date.ToString("d", CultureInfo.CurrentCulture), TextFirstLine, TransactionAmount.ToString("C2", CultureInfo.CurrentCulture)));
 }