public Result Add(string description, double amount, DateTime date, string note, PaymentType paymentType, BudgetType budgetType, FundType fundType, bool?giftAid = false) { Result <Note> incomeNote = Note.Create(note); Result <TransactionDescription> incomeDescription = TransactionDescription.Create(description); var incomeGiftAid = giftAid == null ? GiftAidStatus.NotSet : (bool)giftAid ? GiftAidStatus.GiftAid : GiftAidStatus.NotGiftAid; var result = Result.Combine(incomeNote, incomeDescription); if (result.IsSuccess) { var income = Income.Create( incomeDescription.Value, date, paymentType, amount, budgetType, incomeNote.Value, fundType); Add(income); return(Result.Ok()); } return(result); }
public void SaveTransaction(TransactionData transactionData, ApplicationDb context, int ownerID) { TransactionDescription transDesc = new TransactionDescription(); transDesc.Type = transactionData.Type; transDesc.Description = transactionData.Description; transDesc.Date = DateTime.Now; transDesc.ownerID = ownerID; context.Add(transDesc); context.SaveChanges(); var id = transDesc.ID; foreach (ProductsViewModel product in transactionData.Products) { Transaction trans = new Transaction(); trans.TransactionDescriptionID = id; trans.ProductID = product.ID; trans.UnitNetPrice = product.NetPrice; trans.UnitGrossPrice = product.GrossPrice; trans.ProductUnits = product.Units; trans.GrossPrice = product.GrossPrice * product.Units; trans.NetPrice = product.NetPrice * product.Units; context.Add(trans); context.SaveChanges(); } UpdateProductUnits(transactionData, context); }
public void LengthCannotBeMoreThan1024() { Assert.Throws <ArgumentOutOfRangeException>(() => { var description = string.Join("", new Faker().Random.Chars(count: 1025)); TransactionDescription.From(description); }); }
public void ConstructorWithDescription_WhenNoType_ShouldThrowInvalidOperationException() { // Arrange var description = new TransactionDescription("Test"); // Act Assert var action = new Action(() => new TransactionBuilder(TransactionType.All, new Money(500)).WithDescription(description).Build()); action.Should().Throw <InvalidOperationException>(); }
internal Transaction(AccountId accId, TransactionId id, TransactionLabel label, ITransactionAmount amount, TransactionMetadata meta, TransactionDescription descr, DateTime createdOn, DateTime updatedOn) { AccountId = accId; Id = id; Label = label; Amount = amount; Metadata = meta; Description = descr; CreatedOn = createdOn; UpdatedOn = updatedOn; }
public async Task <bool> TryBeginCommitAsync <R, TProcessor>(K[] keys, int transactionId, TProcessor processor) where TProcessor : IEntryProcessor <K, V, R> { if (LockKeys(keys)) { var desc = new TransactionDescription <R>(keys, processor); transactionsById.TryAdd(transactionId, desc); return(true); } else { return(false); } }
public void DescriptionToString_ShouldBeSame() { // Arrange var currency = Money.Fifty; var description = new TransactionDescription("Test"); var type = TransactionType.Deposit; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction(currency, description, type, provider); // Act Assert transaction.Description.ToString().Should().Be("Test"); }
private void InitialiseParameters() { DATERECIEVED = new DateTime(2018, 8, 7); DESCRIPTION = (TransactionDescription)"Builder and Sons"; AMOUNT = 520.00; PAYMENTTYPE_TOADD = PaymentType.Create("CHQ", "Cheque").Value; BUDGETTYPE_TOADD = BudgetType.Create("Building", "Building Maintenance"); FUNDTYPE_TOADD = FundType.Create("Building", "Building Fund"); SPENDTYPE_TOADD = SpendType.Create("Capital", "Capital"); NOTE = (Note)string.Empty; BANKCLEARED = false; CHEQUENUMBER = "000123"; }
private void InitialiseParameters() { DATERECIEVED = new DateTime(2018, 8, 7); DESCRIPTION = (TransactionDescription)"Offering 7/8/2018"; AMOUNT = 230.00; PAYMENTTYPE_TOADD = PaymentType.Create("CSH", "Cash").Value; BUDGETTYPE_TOADD = BudgetType.Create("GeneralIncome", "General Income"); FUNDTYPE_TOADD = FundType.Create("Revenue", "Revenue"); GIFTAIDSTATUS = GiftAidStatus.NotGiftAid; PAYINGINSLIP = "000124"; NOTE = (Note)"Offering taken in the evening"; BANKCLEARED = false; }
public TxDesc(TransactionDescription tx) { Height = tx.Height; IsReceive = tx.IsReceive; TimeStamp = (long)Math.Round(tx.TimeStamp .Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)) .TotalMilliseconds); SendAccountId = tx.SendAccountId; SendHash = tx.SendHash; RecvAccountId = tx.RecvAccountId; RecvHash = tx.RecvHash; Changes = tx.Changes?.ToDictionary(k => k.Key, k => k.Value.ToBalanceDecimal().ToString()); Balances = tx.Balances.ToDictionary(k => k.Key, k => k.Value.ToBalanceDecimal().ToString()); }
public void GetData() { var request = new HttpRequest(string.Empty, "http://localhost/", string.Empty); var stringWriter = new StringWriter(); var response = new HttpResponse(stringWriter); HttpContext.Current = new HttpContext(request, response); TransactionInstance instance = TransactionInstance.GetInstance(HttpContext.Current); TransactionDescription description = instance.StartTransaction(request.Url, string.Empty, string.Empty); var transactionTab = new TransactionTab(); var result = transactionTab.GetData(null) as TransactionDescription; Assert.AreEqual(result, description); }
private void btnDeposit_Click(object sender, EventArgs e) { if (acc == null) { API.Message("Please Search For an Account to Deposit To", MessageBoxIcon.Error); } else { double deposit = 0; try { deposit = Convert.ToDouble(txtDeposit.Text); } catch { API.Message("Please Input A Valid Number", MessageBoxIcon.Error); return; } try { if (MessageBox.Show("Confirm Deposit Of \n" + deposit + " To : {" + acc.Names + " : " + acc.Number + "}", "Deposit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Transaction transaction = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.DEPOSIT }; API.Controllers.Transaction.Create(transaction); transaction = API.Controllers.Transaction.FindByGUID(transaction.TransationGUId); TransactionDescription transactionDescription = new TransactionDescription { Description = "Over the Counter Deposit", GUID = Guid.NewGuid().ToString(), CreditAccount = acc, DebitAccount = acc }; API.Controllers.TransactionDescription.Create(transactionDescription); transactionDescription = API.Controllers.TransactionDescription.FindByGUID(transactionDescription.GUID); CreditDebit creditDebit = new CreditDebit { Credit = deposit, Transaction = transaction, TransactionDescription = transactionDescription, Account = acc, TransactionType = Transaction.TransactionTypes.DEPOSIT }; API.Controllers.CreditDebit.Create(creditDebit); API.Message("Transaction Successfull", MessageBoxIcon.Information); } } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); } } }
public void SetUp() { // setup fake model _dbAssetType = new AssetType { Id = 1, Name = "a", IsActive = true }; _dbAsset = new Asset { Id = 2, AssetTypeId = _dbAssetType.Id, Name = "b", IsActive = true }; _dbSettingType = new SettingType { Id = 3, Name = "c", IsActive = true }; _dbAssetSetting = new AssetSetting { Id = 4, AssetId = _dbAsset.Id, SettingTypeId = _dbSettingType.Id, Value = "d", IsActive = true }; _dbTransactionCategory = new TransactionCategory { Id = 5, Name = "e", IsActive = true }; _dbTransactionDescription = new TransactionDescription { Id = 6, Name = "f", IsActive = true }; _dbTransactionType = new TransactionType { Id = 7, Name = "g", IsActive = true }; _dbAssetTransaction = new AssetTransaction { Id = 8, TransactionCategoryId = _dbTransactionCategory.Id, TransactionDescriptionId = _dbTransactionDescription.Id, TransactionTypeId = _dbTransactionType.Id, CheckNumber = "123", DueDate = new DateTime(1234, 5, 6), ClearDate = new DateTime(1234, 7, 8), Amount = 123.45M, Note = "abcdef", IsActive = true }; // setup DbContext Setup_FakeDbContext(); // set up repository _repository = new AssetTransactionRepository(_fakeDbContext); }
public void MarkAsFailed_StatusPending_ShouldBeStatusFailed() { // Arrange var currency = Money.Fifty; var description = new TransactionDescription("Test"); var type = TransactionType.Deposit; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction( currency, description, type, provider); // Act transaction.MarkAsFailed(); // Assert transaction.Status.Should().Be(TransactionStatus.Failed); }
public void MarkAsCanceled_WhenTransactionStatusPending_ShouldBeStatusSucceded() { // Arrange var currency = Money.Twenty; var description = new TransactionDescription("Transaction to cancel"); var type = TransactionType.Withdraw; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction( currency, description, type, provider); // Act transaction.MarkAsCanceled(); // Assert transaction.Status.Should().Be(TransactionStatus.Canceled); }
public void Price_WithTransactionFromMoney_ShouldBePriceMoney() { // Arrange var currency = Money.Twenty; var description = new TransactionDescription("Price to check"); var type = TransactionType.Withdraw; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction( currency, description, type, provider); // Act Assert transaction.Price.Should().NotBeNull(); var price = transaction.Price; price.Amount.Should().Be(20); price.Type.Should().Be(CurrencyType.Money); }
public void Price_WithTransactionFromToken_ShouldBePriceMoney() { // Arrange var currency = Token.FiftyThousand; var description = new TransactionDescription("Price to check"); var type = TransactionType.Deposit; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction( currency, description, type, provider); // Act Assert transaction.Price.Should().NotBeNull(); var price = transaction.Price; price.Amount.Should().Be(500); price.Type.Should().Be(CurrencyType.Money); }
public void MarkAsFailed_WhenTransactionStatusSucceeded_ShouldThrowInvalidOperationException() { // Arrange var currency = Money.Fifty; var description = new TransactionDescription("Test"); var type = TransactionType.Deposit; var provider = new UtcNowDateTimeProvider(); var transaction = new Transaction( currency, description, type, provider); transaction.MarkAsSucceeded(); // Act var action = new Action(() => transaction.MarkAsFailed()); // Assert action.Should().Throw <InvalidOperationException>(); }
public Transaction To() { var descr = new TransactionDescription(); foreach (var kv in Description) { descr.Add(kv.Key, kv.Value); } var metadata = new TransactionMetadata(); foreach (var kv in Metadata) { metadata.Add(kv.Key, kv.Value); } var am = AmountFactory.New(AmountValue, AmountCurrency); ITransactionAmount amount = AmountType switch { _completedIncome => new AmountIncomeCompleted(am), _cancelledOutcome => new AmountOutcomeCancelled(am), _processingOutcome => new AmountOutcomeProcessing(am), _completedOutcome => new AmountOutcomeCompleted(am), _ => throw new InvalidOperationException("Invalid transaction status") }; return(new Transaction( new AccountId(new UniqId(AccountId)), new TransactionId(new UniqId(Id)), new TransactionLabel(Label), amount, metadata, descr, CreatedOn, UpdateOn )); }
// private private void Setup_FakeDb() { _dbAssetType = new AssetType { Id = 1, Name = "a", IsActive = true }; _dbAsset = new Asset { Id = 2, AssetTypeId = _dbAssetType.Id, Name = "b", IsActive = true }; _dbSettingType = new SettingType { Id = 3, Name = "c", IsActive = true }; _dbAssetSetting = new AssetSetting { Id = 4, AssetId = _dbAsset.Id, SettingTypeId = _dbSettingType.Id, Value = "d", IsActive = true }; _dbTransactionCategory = new TransactionCategory { Id = 5, Name = "e", IsActive = true }; _dbTransactionDescription = new TransactionDescription { Id = 6, Name = "f", IsActive = true }; _dbTransactionType = new TransactionType { Id = 7, Name = "g", IsActive = true }; _dbAssetTransaction = new AssetTransaction { Id = 8, TransactionCategoryId = _dbTransactionCategory.Id, TransactionDescriptionId = _dbTransactionDescription.Id, TransactionTypeId = _dbTransactionType.Id, CheckNumber = "123", DueDate = new DateTime(1234, 5, 6), ClearDate = new DateTime(1234, 7, 8), Amount = 123.45M, Note = "abcdef", IsActive = true }; }
public CreateTransaction To() { Console.WriteLine("My Value {0} {1} {2}", CreateAmountValue, CreateAmountCurrency, CreateAmountType); var am = AmountFactory.New(CreateAmountValue, CreateAmountCurrency); CreateAmount createAmount = CreateAmountType switch { _processingOutcome => new CreateAmountProcessingOutcome(am), _completedIncome => new CreateAmountCompletedIncome(am), _ => throw new InvalidOperationException("Invalid create transaction status") }; var descr = new TransactionDescription(); foreach (var kv in Description) { descr.Add(kv.Key, kv.Value); } var metadata = new TransactionMetadata(); foreach (var kv in Metadata) { metadata.Add(kv.Key, kv.Value); } return(new CreateTransaction( new AccountId(new UniqId(AccountId)), new TransactionId(new UniqId(Id)), new TransactionLabel(Label), createAmount, Signature, descr, metadata )); } }
public UpdateTransaction To() { var descr = new TransactionDescription(); foreach (var kv in Description) { descr.Add(kv.Key, kv.Value); } var metadata = new TransactionMetadata(); foreach (var kv in Metadata) { metadata.Add(kv.Key, kv.Value); } return(new UpdateTransaction( new TransactionId(new UniqId(Id)), Status == StatusCompleted ? UpdateStatus.Complete : UpdateStatus.Cancel, Signature, descr, metadata )); }
public void CanBeNull() { TransactionDescription description = null; Assert.Null(description); }
private void btnApplyAction_Click(object sender, EventArgs e) { try { if (cboAction.SelectedIndex + 1 == Loan.STATUS.APPROVED) { Account account = API.Controllers.Accounts.FetchByAccountNumber(0); //API.Message(account.Balance.ToString(), MessageBoxIcon.Asterisk); Transaction transaction = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.STANDING_CHARGE }; API.Controllers.Transaction.Create(transaction); transaction = API.Controllers.Transaction.FindByGUID(transaction.TransationGUId); TransactionDescription transDes = new TransactionDescription { GUID = Guid.NewGuid().ToString(), CreditAccount = account, DebitAccount = account, Description = "Loan Standing Charge , Loan{" + Loan.Id + "}, Charge {" + Loan.StandingCharge + "}" }; TransactionDescription debitSystemLoanAmount = new TransactionDescription { GUID = Guid.NewGuid().ToString(), CreditAccount = Account, DebitAccount = account, Description = "Loan Gifted , Loan{" + Loan.Id + "}, Amount {" + Loan.Principal + "}" }; API.Controllers.TransactionDescription.Create(transDes); transDes = API.Controllers.TransactionDescription.FindByGUID(transDes.GUID); API.Controllers.TransactionDescription.Create(debitSystemLoanAmount); debitSystemLoanAmount = API.Controllers.TransactionDescription.FindByGUID(debitSystemLoanAmount.GUID); CreditDebit debitSys = new CreditDebit { TransactionDescription = debitSystemLoanAmount, Transaction = transaction, Account = account, Debit = (double)Loan.Principal, Credit = 0, TransactionType = Transaction.TransactionTypes.WITHDRAW }; API.Controllers.CreditDebit.Create(debitSys); // API.Message("SystemOut", MessageBoxIcon.Information); CreditDebit credSys = new CreditDebit { TransactionDescription = transDes, Transaction = transaction, Account = API.Controllers.Accounts.FetchByAccountNumber(0), Credit = (double)Loan.StandingCharge, Debit = 0, TransactionType = Transaction.TransactionTypes.STANDING_CHARGE }; API.Controllers.CreditDebit.Create(credSys); //deposit the money to account Transaction transactiond = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.DEPOSIT }; API.Controllers.Transaction.Create(transactiond); transactiond = API.Controllers.Transaction.FindByGUID(transactiond.TransationGUId); TransactionDescription transactionDescription = new TransactionDescription { Description = "Loan Deposit Deposit", GUID = Guid.NewGuid().ToString(), CreditAccount = Account, DebitAccount = account }; API.Controllers.TransactionDescription.Create(transactionDescription); transactionDescription = API.Controllers.TransactionDescription.FindByGUID(transactionDescription.GUID); CreditDebit creditDebit = new CreditDebit { Credit = (double)Loan.Principal, Transaction = transactiond, TransactionDescription = transactionDescription, Account = Account, TransactionType = Transaction.TransactionTypes.DEPOSIT }; API.Controllers.CreditDebit.Create(creditDebit); API.Message("Standard Charge Successfully", MessageBoxIcon.Information); } API.Controllers.Loans.UpdateStatus(Loan, cboAction.SelectedIndex + 1); API.Message("Updated Successfully", MessageBoxIcon.Information); } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } }
public static void Initialize(ApplicationDb context) { context.Database.EnsureCreated(); if (!context.Voivodeships.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Voivodeships', RESEED, 0)"); var voivodeships = new Voivodeship[] { new Voivodeship { Name = "Dolnośląskie" }, new Voivodeship { Name = "Kujawsko-pomorskie" }, new Voivodeship { Name = "Lubelskie" }, new Voivodeship { Name = "Lubuskie" }, new Voivodeship { Name = "Łódzkie" }, new Voivodeship { Name = "Małopolskie" }, new Voivodeship { Name = "Mazowieckie" }, new Voivodeship { Name = "Opolskie" }, new Voivodeship { Name = "Podkarpackie" }, new Voivodeship { Name = "Podlaskie" }, new Voivodeship { Name = "Pomorskie" }, new Voivodeship { Name = "Śląskie" }, new Voivodeship { Name = "Świętokrzyskie" }, new Voivodeship { Name = "Warmińsko-mazurskie" }, new Voivodeship { Name = "Wielkopolskie" }, new Voivodeship { Name = "Zachodniopomorskie" } }; foreach (Voivodeship v in voivodeships) { context.Voivodeships.Add(v); } context.SaveChanges(); } if (!context.Countries.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Countries', RESEED, 0)"); var countries = new Country[] { new Country { CountryCode = "AF", Name = "Afghanistan" }, new Country { CountryCode = "AL", Name = "Albania" }, new Country { CountryCode = "DZ", Name = "Algeria" }, new Country { CountryCode = "DS", Name = "American Samoa" }, new Country { CountryCode = "AD", Name = "Andorra" }, new Country { CountryCode = "AO", Name = "Angola" }, new Country { CountryCode = "AI", Name = "Anguilla" }, new Country { CountryCode = "AQ", Name = "Antarctica" }, new Country { CountryCode = "AG", Name = "Antigua and Barbuda" }, new Country { CountryCode = "AR", Name = "Argentina" }, new Country { CountryCode = "AM", Name = "Armenia" }, new Country { CountryCode = "AW", Name = "Aruba" }, new Country { CountryCode = "AU", Name = "Australia" }, new Country { CountryCode = "AT", Name = "Austria" }, new Country { CountryCode = "AZ", Name = "Azerbaijan" }, new Country { CountryCode = "BS", Name = "Bahamas" }, new Country { CountryCode = "BH", Name = "Bahrain" }, new Country { CountryCode = "BD", Name = "Bangladesh" }, new Country { CountryCode = "BB", Name = "Barbados" }, new Country { CountryCode = "BY", Name = "Belarus" }, new Country { CountryCode = "BE", Name = "Belgium" }, new Country { CountryCode = "BZ", Name = "Belize" }, new Country { CountryCode = "BJ", Name = "Benin" }, new Country { CountryCode = "BM", Name = "Bermuda" }, new Country { CountryCode = "BT", Name = "Bhutan" }, new Country { CountryCode = "BO", Name = "Bolivia" }, new Country { CountryCode = "BA", Name = "Bosnia and Herzegovina" }, new Country { CountryCode = "BW", Name = "Botswana" }, new Country { CountryCode = "BV", Name = "Bouvet Island" }, new Country { CountryCode = "BR", Name = "Brazil" }, new Country { CountryCode = "IO", Name = "British Indian Ocean Territory" }, new Country { CountryCode = "BN", Name = "Brunei Darussalam" }, new Country { CountryCode = "BG", Name = "Bulgaria" }, new Country { CountryCode = "BF", Name = "Burkina Faso" }, new Country { CountryCode = "BI", Name = "Burundi" }, new Country { CountryCode = "KH", Name = "Cambodia" }, new Country { CountryCode = "CM", Name = "Cameroon" }, new Country { CountryCode = "CA", Name = "Canada" }, new Country { CountryCode = "CV", Name = "Cape Verde" }, new Country { CountryCode = "KY", Name = "Cayman Islands" }, new Country { CountryCode = "CF", Name = "Central African Republic" }, new Country { CountryCode = "TD", Name = "Chad" }, new Country { CountryCode = "CL", Name = "Chile" }, new Country { CountryCode = "CN", Name = "China" }, new Country { CountryCode = "CX", Name = "Christmas Island" }, new Country { CountryCode = "CC", Name = "Cocos (Keeling) Islands" }, new Country { CountryCode = "CO", Name = "Colombia" }, new Country { CountryCode = "KM", Name = "Comoros" }, new Country { CountryCode = "CG", Name = "Congo" }, new Country { CountryCode = "CK", Name = "Cook Islands" }, new Country { CountryCode = "CR", Name = "Costa Rica" }, new Country { CountryCode = "HR", Name = "Croatia (Hrvatska)" }, new Country { CountryCode = "CU", Name = "Cuba" }, new Country { CountryCode = "CY", Name = "Cyprus" }, new Country { CountryCode = "CZ", Name = "Czech Republic" }, new Country { CountryCode = "DK", Name = "Denmark" }, new Country { CountryCode = "DJ", Name = "Djibouti" }, new Country { CountryCode = "DM", Name = "Dominica" }, new Country { CountryCode = "DO", Name = "Dominican Republic" }, new Country { CountryCode = "TP", Name = "East Timor" }, new Country { CountryCode = "EC", Name = "Ecuador" }, new Country { CountryCode = "EG", Name = "Egypt" }, new Country { CountryCode = "SV", Name = "El Salvador" }, new Country { CountryCode = "GQ", Name = "Equatorial Guinea" }, new Country { CountryCode = "ER", Name = "Eritrea" }, new Country { CountryCode = "EE", Name = "Estonia" }, new Country { CountryCode = "ET", Name = "Ethiopia" }, new Country { CountryCode = "FK", Name = "Falkland Islands (Malvinas)" }, new Country { CountryCode = "FO", Name = "Faroe Islands" }, new Country { CountryCode = "FJ", Name = "Fiji" }, new Country { CountryCode = "FI", Name = "Finland" }, new Country { CountryCode = "FR", Name = "France" }, new Country { CountryCode = "FX", Name = "France, Metropolitan" }, new Country { CountryCode = "GF", Name = "French Guiana" }, new Country { CountryCode = "PF", Name = "French Polynesia" }, new Country { CountryCode = "TF", Name = "French Southern Territories" }, new Country { CountryCode = "GA", Name = "Gabon" }, new Country { CountryCode = "GM", Name = "Gambia" }, new Country { CountryCode = "GE", Name = "Georgia" }, new Country { CountryCode = "DE", Name = "Germany" }, new Country { CountryCode = "GH", Name = "Ghana" }, new Country { CountryCode = "GI", Name = "Gibraltar" }, new Country { CountryCode = "GK", Name = "Guernsey" }, new Country { CountryCode = "GR", Name = "Greece" }, new Country { CountryCode = "GL", Name = "Greenland" }, new Country { CountryCode = "GD", Name = "Grenada" }, new Country { CountryCode = "GP", Name = "Guadeloupe" }, new Country { CountryCode = "GU", Name = "Guam" }, new Country { CountryCode = "GT", Name = "Guatemala" }, new Country { CountryCode = "GN", Name = "Guinea" }, new Country { CountryCode = "GW", Name = "Guinea-Bissau" }, new Country { CountryCode = "GY", Name = "Guyana" }, new Country { CountryCode = "HT", Name = "Haiti" }, new Country { CountryCode = "HM", Name = "Heard and Mc Donald Islands" }, new Country { CountryCode = "HN", Name = "Honduras" }, new Country { CountryCode = "HK", Name = "Hong Kong" }, new Country { CountryCode = "HU", Name = "Hungary" }, new Country { CountryCode = "IS", Name = "Iceland" }, new Country { CountryCode = "IN", Name = "India" }, new Country { CountryCode = "IM", Name = "Isle of Man" }, new Country { CountryCode = "ID", Name = "Indonesia" }, new Country { CountryCode = "IR", Name = "Iran (Islamic Republic of)" }, new Country { CountryCode = "IQ", Name = "Iraq" }, new Country { CountryCode = "IE", Name = "Ireland" }, new Country { CountryCode = "IL", Name = "Israel" }, new Country { CountryCode = "IT", Name = "Italy" }, new Country { CountryCode = "CI", Name = "Ivory Coast" }, new Country { CountryCode = "JE", Name = "Jersey" }, new Country { CountryCode = "JM", Name = "Jamaica" }, new Country { CountryCode = "JP", Name = "Japan" }, new Country { CountryCode = "JO", Name = "Jordan" }, new Country { CountryCode = "KZ", Name = "Kazakhstan" }, new Country { CountryCode = "KE", Name = "Kenya" }, new Country { CountryCode = "KI", Name = "Kiribati" }, new Country { CountryCode = "KP", Name = "Korea, Democratic People''s Republic of" }, new Country { CountryCode = "KR", Name = "Korea, Republic of" }, new Country { CountryCode = "XK", Name = "Kosovo" }, new Country { CountryCode = "KW", Name = "Kuwait" }, new Country { CountryCode = "KG", Name = "Kyrgyzstan" }, new Country { CountryCode = "LA", Name = "Lao People''s Democratic Republic" }, new Country { CountryCode = "LV", Name = "Latvia" }, new Country { CountryCode = "LB", Name = "Lebanon" }, new Country { CountryCode = "LS", Name = "Lesotho" }, new Country { CountryCode = "LR", Name = "Liberia" }, new Country { CountryCode = "LY", Name = "Libyan Arab Jamahiriya" }, new Country { CountryCode = "LI", Name = "Liechtenstein" }, new Country { CountryCode = "LT", Name = "Lithuania" }, new Country { CountryCode = "LU", Name = "Luxembourg" }, new Country { CountryCode = "MO", Name = "Macau" }, new Country { CountryCode = "MK", Name = "Macedonia" }, new Country { CountryCode = "MG", Name = "Madagascar" }, new Country { CountryCode = "MW", Name = "Malawi" }, new Country { CountryCode = "MY", Name = "Malaysia" }, new Country { CountryCode = "MV", Name = "Maldives" }, new Country { CountryCode = "ML", Name = "Mali" }, new Country { CountryCode = "MT", Name = "Malta" }, new Country { CountryCode = "MH", Name = "Marshall Islands" }, new Country { CountryCode = "MQ", Name = "Martinique" }, new Country { CountryCode = "MR", Name = "Mauritania" }, new Country { CountryCode = "MU", Name = "Mauritius" }, new Country { CountryCode = "TY", Name = "Mayotte" }, new Country { CountryCode = "MX", Name = "Mexico" }, new Country { CountryCode = "FM", Name = "Micronesia, Federated States of" }, new Country { CountryCode = "MD", Name = "Moldova, Republic of" }, new Country { CountryCode = "MC", Name = "Monaco" }, new Country { CountryCode = "MN", Name = "Mongolia" }, new Country { CountryCode = "ME", Name = "Montenegro" }, new Country { CountryCode = "MS", Name = "Montserrat" }, new Country { CountryCode = "MA", Name = "Morocco" }, new Country { CountryCode = "MZ", Name = "Mozambique" }, new Country { CountryCode = "MM", Name = "Myanmar" }, new Country { CountryCode = "NA", Name = "Namibia" }, new Country { CountryCode = "NR", Name = "Nauru" }, new Country { CountryCode = "NP", Name = "Nepal" }, new Country { CountryCode = "NL", Name = "Netherlands" }, new Country { CountryCode = "AN", Name = "Netherlands Antilles" }, new Country { CountryCode = "NC", Name = "New Caledonia" }, new Country { CountryCode = "NZ", Name = "New Zealand" }, new Country { CountryCode = "NI", Name = "Nicaragua" }, new Country { CountryCode = "NE", Name = "Niger" }, new Country { CountryCode = "NG", Name = "Nigeria" }, new Country { CountryCode = "NU", Name = "Niue" }, new Country { CountryCode = "NF", Name = "Norfolk Island" }, new Country { CountryCode = "MP", Name = "Northern Mariana Islands" }, new Country { CountryCode = "NO", Name = "Norway" }, new Country { CountryCode = "OM", Name = "Oman" }, new Country { CountryCode = "PK", Name = "Pakistan" }, new Country { CountryCode = "PW", Name = "Palau" }, new Country { CountryCode = "PS", Name = "Palestine" }, new Country { CountryCode = "PA", Name = "Panama" }, new Country { CountryCode = "PG", Name = "Papua New Guinea" }, new Country { CountryCode = "PY", Name = "Paraguay" }, new Country { CountryCode = "PE", Name = "Peru" }, new Country { CountryCode = "PH", Name = "Philippines" }, new Country { CountryCode = "PN", Name = "Pitcairn" }, new Country { CountryCode = "PL", Name = "Poland" }, new Country { CountryCode = "PT", Name = "Portugal" }, new Country { CountryCode = "PR", Name = "Puerto Rico" }, new Country { CountryCode = "QA", Name = "Qatar" }, new Country { CountryCode = "RE", Name = "Reunion" }, new Country { CountryCode = "RO", Name = "Romania" }, new Country { CountryCode = "RU", Name = "Russian Federation" }, new Country { CountryCode = "RW", Name = "Rwanda" }, new Country { CountryCode = "KN", Name = "Saint Kitts and Nevis" }, new Country { CountryCode = "LC", Name = "Saint Lucia" }, new Country { CountryCode = "VC", Name = "Saint Vincent and the Grenadines" }, new Country { CountryCode = "WS", Name = "Samoa" }, new Country { CountryCode = "SM", Name = "San Marino" }, new Country { CountryCode = "ST", Name = "Sao Tome and Principe" }, new Country { CountryCode = "SA", Name = "Saudi Arabia" }, new Country { CountryCode = "SN", Name = "Senegal" }, new Country { CountryCode = "RS", Name = "Serbia" }, new Country { CountryCode = "SC", Name = "Seychelles" }, new Country { CountryCode = "SL", Name = "Sierra Leone" }, new Country { CountryCode = "SG", Name = "Singapore" }, new Country { CountryCode = "SK", Name = "Slovakia" }, new Country { CountryCode = "SI", Name = "Slovenia" }, new Country { CountryCode = "SB", Name = "Solomon Islands" }, new Country { CountryCode = "SO", Name = "Somalia" }, new Country { CountryCode = "ZA", Name = "South Africa" }, new Country { CountryCode = "GS", Name = "South Georgia South Sandwich Islands" }, new Country { CountryCode = "ES", Name = "Spain" }, new Country { CountryCode = "LK", Name = "Sri Lanka" }, new Country { CountryCode = "SH", Name = "St. Helena" }, new Country { CountryCode = "PM", Name = "St. Pierre and Miquelon" }, new Country { CountryCode = "SD", Name = "Sudan" }, new Country { CountryCode = "SR", Name = "Suriname" }, new Country { CountryCode = "SJ", Name = "Svalbard and Jan Mayen Islands" }, new Country { CountryCode = "SZ", Name = "Swaziland" }, new Country { CountryCode = "SE", Name = "Sweden" }, new Country { CountryCode = "CH", Name = "Switzerland" }, new Country { CountryCode = "SY", Name = "Syrian Arab Republic" }, new Country { CountryCode = "TW", Name = "Taiwan" }, new Country { CountryCode = "TJ", Name = "Tajikistan" }, new Country { CountryCode = "TZ", Name = "Tanzania, United Republic of" }, new Country { CountryCode = "TH", Name = "Thailand" }, new Country { CountryCode = "TG", Name = "Togo" }, new Country { CountryCode = "TK", Name = "Tokelau" }, new Country { CountryCode = "TO", Name = "Tonga" }, new Country { CountryCode = "TT", Name = "Trinidad and Tobago" }, new Country { CountryCode = "TN", Name = "Tunisia" }, new Country { CountryCode = "TR", Name = "Turkey" }, new Country { CountryCode = "TM", Name = "Turkmenistan" }, new Country { CountryCode = "TC", Name = "Turks and Caicos Islands" }, new Country { CountryCode = "TV", Name = "Tuvalu" }, new Country { CountryCode = "UG", Name = "Uganda" }, new Country { CountryCode = "UA", Name = "Ukraine" }, new Country { CountryCode = "AE", Name = "United Arab Emirates" }, new Country { CountryCode = "GB", Name = "United Kingdom" }, new Country { CountryCode = "US", Name = "United States" }, new Country { CountryCode = "UM", Name = "United States minor outlying islands" }, new Country { CountryCode = "UY", Name = "Uruguay" }, new Country { CountryCode = "UZ", Name = "Uzbekistan" }, new Country { CountryCode = "VU", Name = "Vanuatu" }, new Country { CountryCode = "VA", Name = "Vatican City State" }, new Country { CountryCode = "VE", Name = "Venezuela" }, new Country { CountryCode = "VN", Name = "Vietnam" }, new Country { CountryCode = "VG", Name = "Virgin Islands (British)" }, new Country { CountryCode = "VI", Name = "Virgin Islands (U.S.)" }, new Country { CountryCode = "WF", Name = "Wallis and Futuna Islands" }, new Country { CountryCode = "EH", Name = "Western Sahara" }, new Country { CountryCode = "YE", Name = "Yemen" }, new Country { CountryCode = "ZR", Name = "Zaire" }, new Country { CountryCode = "ZM", Name = "Zambia" }, new Country { CountryCode = "ZW", Name = "Zimbabwe" } }; foreach (Country c in countries) { context.Countries.Add(c); } context.SaveChanges(); } if (!context.Users.Any()) { context.Database.ExecuteSqlCommand( "INSERT INTO [dbo].[Users] ([Id], [ConcurrencyStamp], [Email], [LockoutEnd], [NormalizedEmail], [NormalizedUserName], [PasswordHash], [SecurityStamp], [UserName]) VALUES (N\'6f67da5a-2059-4283-b485-7a1a39c671ad\', N\'821a09a3-843d-406c-ab00-017c0695782b\', N\'[email protected]\', NULL, N\'[email protected]\', N\'[email protected]\', N\'AQAAAAEAACcQAAAAEHhs3x7UIHr3rPCDoStUyItJTSv5QVXvlMnh5Pff8ND7oWiDKEReAOSPMbAazD/slg==\', N\'949ab286-bd07-4943-82b9-2c635b2c0c4d\', N\'[email protected]\')"); context.SaveChanges(); } if (!context.Owners.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Owners', RESEED, 0)"); var owners = new Owner[] { new Owner { FirstName = "Pawel", LastName = "Testowy", Created = DateTime.Now, OwnerEmail = "*****@*****.**" }, }; foreach (Owner o in owners) { context.Owners.Add(o); } context.SaveChanges(); } if (!context.Companies.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Companies', RESEED, 0)"); var companies = new Company[] { new Company { Name = "TestowaFirma1", Trade = "IT", Street = "Testowa 1/11", Town = "Bydgoszcz", PostalCode = "85-333", Voivodeship = 1, Country = 1, ownerID = 1 }, new Company { Name = "TestowaFirma2", Trade = "IT", Street = "Testowa 2/122", Town = "warszawa", PostalCode = "22-333", Voivodeship = 5, Country = 177, ownerID = 1 } }; foreach (Company c in companies) { context.Companies.Add(c); } context.SaveChanges(); } if (!context.Emails.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Emails', RESEED, 0)"); var emails = new Email[] { new Email { Sender = "*****@*****.**", Subject = "test", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test2", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test3", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test4", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test5", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test6", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test7", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test8", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test9", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true }, new Email { Sender = "*****@*****.**", Subject = "test10", OwnerID = 1, Message = "czesc, co tam?", ReceivedTime = DateTime.Parse("2017-07-17 12:20:22"), Saved = true } }; foreach (Email email in emails) { context.Emails.Add(email); } context.SaveChanges(); } if (!context.Employee.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Employees', RESEED, 0)"); var employees = new Employee[] { new Employee { FirstName = "Pawel", LastName = "Testowy", Position = "kierownik", Street = "Simple Street 1", Town = "new york", PostalCode = "", Voivodeship = 4, Country = 230, ownerID = 1 } }; foreach (Employee employee in employees) { context.Employee.Add(employee); } context.SaveChanges(); } if (!context.Product.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Products', RESEED, 0)"); var products = new Product[] { new Product { CompanyID = 1, Name = "karta graficzna 1", Description = "bardzo fajna karta graficzna", GrossPrice = 184.50M, NetPrice = 150.00M, Quantity = 20, ownerID = 1 }, new Product { CompanyID = 1, Name = "karta graficzna 2", Description = "fajna karta graficzna", GrossPrice = 246.00M, NetPrice = 200.00M, Quantity = 15, ownerID = 1 }, new Product { CompanyID = 1, Name = "karta graficzna 3", Description = "srednia karta graficzna", GrossPrice = 123.00M, NetPrice = 100.00M, Quantity = 10, ownerID = 1 }, new Product { CompanyID = 1, Name = "klawiatura logitech", Description = "bardzo fajna klawiatura logitech", GrossPrice = 55.35M, NetPrice = 45.00M, Quantity = 25, ownerID = 1 }, new Product { CompanyID = 1, Name = "klawiatura apple", Description = "klawiatura do jablek", GrossPrice = 307.50M, NetPrice = 250.00M, Quantity = 5, ownerID = 1 }, new Product { CompanyID = 1, Name = "router asus", Description = "najnowszy router od asusa", GrossPrice = 73.80M, NetPrice = 60.00M, Quantity = 12, ownerID = 1 }, new Product { CompanyID = 1, Name = "router tp-link", Description = "tp-link router", GrossPrice = 36.90M, NetPrice = 30.00M, Quantity = 10, ownerID = 1 }, new Product { CompanyID = 1, Name = "myszka razor v3", Description = "bezprzewodowa mysz dla graczy", GrossPrice = 98.40M, NetPrice = 80.00M, Quantity = 20, ownerID = 1 }, new Product { CompanyID = 1, Name = "mysz logitech", Description = "designerska mysz od logitecha", GrossPrice = 110.70M, NetPrice = 90.00M, Quantity = 8, ownerID = 1 }, new Product { CompanyID = 1, Name = "sprezone powietrze", Description = "srodek do czyszcenia komputerow stacjonarnych, laptopow, klawiatur i innych sprzetow", GrossPrice = 18.45M, NetPrice = 15.00M, Quantity = 45, ownerID = 1 } }; foreach (Product product in products) { context.Product.Add(product); } context.SaveChanges(); } if (!context.TransactionDescription.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('TransactionDescriptions', RESEED, 0)"); var transactionDescriptions = new TransactionDescription[] { new TransactionDescription { Type = 2, Description = "Sprzedaz 1", Date = DateTime.Now, ownerID = 1 } }; foreach (TransactionDescription tranDesc in transactionDescriptions) { context.TransactionDescription.Add(tranDesc); } context.SaveChanges(); } if (!context.Transaction.Any()) { context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Transactions', RESEED, 0)"); var transactions = new Transaction[] { new Transaction { ProductID = 1, UnitGrossPrice = 184.50M, UnitNetPrice = 150.00M, ProductUnits = 2, TransactionDescriptionID = 1, GrossPrice = 369.00M, NetPrice = 300.00M }, new Transaction { ProductID = 4, UnitGrossPrice = 55.35M, UnitNetPrice = 45.00M, ProductUnits = 1, TransactionDescriptionID = 1, GrossPrice = 55.35M, NetPrice = 45.00M }, new Transaction { ProductID = 6, UnitGrossPrice = 73.80M, UnitNetPrice = 60.00M, ProductUnits = 1, TransactionDescriptionID = 1, GrossPrice = 73.80M, NetPrice = 60.00M } }; foreach (Transaction transaction in transactions) { context.Transaction.Add(transaction); } context.SaveChanges(); } }
private void btnWithdraw_Click(object sender, EventArgs e) { if (acc == null) { API.Message("Please Search For an Account to Withdraw From", MessageBoxIcon.Error); } else { double withdraw = 0, charge = 0; try { withdraw = Convert.ToDouble(txtWithdraw.Text); } catch { API.Message("Please Input A Valid Number", MessageBoxIcon.Error); return; } TransactionCharge transactionCharge = API.Controllers.TransactionCharges.FindByValue(withdraw, Transaction.TransactionTypes.WITHDRAW); if (transactionCharge != null) { switch (API.Controllers.Settings.GetChargingSystem()) { case 1: //values system charge = transactionCharge.Charge; break; case 2: charge = (transactionCharge.Percentage / 100) * withdraw; break; } if ((withdraw + charge) > acc.Balance) { API.Message("Please Input A Valid Amount.\nYou Cannot Withdraw More Than You Have\nYou Have to Pay for the charge too ." + charge, MessageBoxIcon.Error); } else { if (MessageBox.Show("Confirm Withdrawal Of \n" + withdraw + " + " + charge + " From : {" + acc.Names + " : " + acc.Number + "}", "Withdraw", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { Account SysAcc = API.Controllers.Accounts.FetchByAccountNumber("0"); Transaction transaction = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.WITHDRAW }; API.Controllers.Transaction.Create(transaction); transaction = API.Controllers.Transaction.FindByGUID(transaction.TransationGUId); TransactionDescription transactionDescription = new TransactionDescription { Description = "Over the Counter Withdrawal : " + withdraw + ", Transaction Charge : " + charge, GUID = Guid.NewGuid().ToString(), CreditAccount = acc, DebitAccount = acc }; API.Controllers.TransactionDescription.Create(transactionDescription); transactionDescription = API.Controllers.TransactionDescription.FindByGUID(transactionDescription.GUID); TransactionDescription transactionChargesDesc = new TransactionDescription { Description = "Withdraw , Transaction Charge : " + charge, GUID = Guid.NewGuid().ToString(), CreditAccount = SysAcc, DebitAccount = acc }; API.Controllers.TransactionDescription.Create(transactionChargesDesc); transactionChargesDesc = API.Controllers.TransactionDescription.FindByGUID(transactionChargesDesc.GUID); CreditDebit creditDebit = new CreditDebit { Debit = withdraw + charge, Transaction = transaction, TransactionDescription = transactionDescription, Account = acc, TransactionType = Transaction.TransactionTypes.WITHDRAW }; API.Controllers.CreditDebit.Create(creditDebit); CreditDebit creditSys = new CreditDebit { Credit = charge, Transaction = transaction, Account = SysAcc, TransactionDescription = transactionChargesDesc, TransactionType = Transaction.TransactionTypes.SYSTEM_DEPOSIT }; API.Controllers.CreditDebit.Create(creditSys); API.Message("Transaction Successfull", MessageBoxIcon.Information); } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } } } } else { API.Message("Failed to transact.No charges defined.Please contact administrator or manager", MessageBoxIcon.Error); } } }
public void SetUp() { // setup db models _dbAssetType = new AssetType { Id = 1, Name = "a", IsActive = true }; _dbAsset = new Asset { Id = 2, AssetTypeId = _dbAssetType.Id, AssetType = _dbAssetType, // setup include Name = "b", IsActive = true }; _dbSettingType = new SettingType { Id = 3, Name = "c", IsActive = true }; _dbAssetSetting = new AssetSetting { Id = 4, AssetId = _dbAsset.Id, Asset = _dbAsset, // setup include SettingTypeId = _dbSettingType.Id, SettingType = _dbSettingType, // setup include Value = "d", IsActive = true }; _dbTransactionType = new TransactionType { Id = 5, Name = "e", IsActive = true }; _dbTransactionCategory = new TransactionCategory { Id = 6, Name = "f", IsActive = true }; _dbTransactionDescription = new TransactionDescription { Id = 7, Name = "g", IsActive = true }; _dbAssetTransaction = new AssetTransaction { Id = 8, AssetId = _dbAsset.Id, Asset = _dbAsset, // setup include TransactionTypeId = _dbTransactionType.Id, TransactionType = _dbTransactionType, // setup include TransactionCategoryId = _dbTransactionCategory.Id, TransactionCategory = _dbTransactionCategory, // setup include TransactionDescriptionId = _dbTransactionDescription.Id, TransactionDescription = _dbTransactionDescription, // setup include DueDate = new DateTime(1234, 5, 6), ClearDate = new DateTime(1234, 7, 8), Amount = 1.23M, Note = "abc", IsActive = true }; // setup DbContext Setup_FakeDbContext(); // setup uow _fakeUnitOfWork = new UnitOfWork(_fakeDbContext); // setup service _service = new AccountTransactionService(_fakeUnitOfWork); }
public void CanBeEmpty() { TransactionDescription description = ""; Assert.Equal("", description); }
private void btnProceed_Click(object sender, EventArgs e) { if (txtDepositAmount.Text.Trim().Equals(String.Empty)) { } else if (Convert.ToDouble(txtDepositAmount.Text) < fee.Amount) { API.Message("You Have to Pay Opening Account Fee", MessageBoxIcon.Warning); } else { try { Account account = new Account { Names = txtAccNames.Text, PIN = txtPIN.Text, Balance = 0.0, Type = AccountType, UserId = Convert.ToInt32(User.Id) }; API.Controllers.Accounts.CreateAccount(account); account = API.Controllers.Accounts.FetchNewUserAccount(Convert.ToInt32(User.Id), account.Names); //process the deposit transaction //1.create a Transaction Object with Unique GUID //2.Create a TransactionDescription with unique GUID //3.Create a CreditDebit Object //{use the Transaction.GUID to find the Transaction.Id and //The TransactionDescription GUID to find the TransactionDescription.Id } Constrain constrain = new Constrain { Account = account, Amount = Convert.ToDouble(textBox2.Text), Time = getTimeRangeFromIndex(comboBox1.SelectedIndex) }; API.Controllers.AccountConstrains.Create(constrain); Transaction Transaction = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.DEPOSIT }; TransactionDescription TransactionDescription = new TransactionDescription { Description = "First Deposit", CreditAccount = account, DebitAccount = account, GUID = Guid.NewGuid().ToString() }; CreditDebit CreditDebit = new CreditDebit { Account = account, PrevBalance = 0.0, Credit = Convert.ToDouble(txtDepositAmount.Text) - fee.Amount, Transaction = Transaction, TransactionDescription = TransactionDescription, TransactionType = Models.Transaction.TransactionTypes.DEPOSIT }; Account systemAcc = API.Controllers.Accounts.FetchByAccountNumber(0); TransactionDescription TransactionOpeningFeeDescription = new TransactionDescription { Description = "Opening Fee : " + fee.Amount, CreditAccount = systemAcc, DebitAccount = account, GUID = Guid.NewGuid().ToString() }; CreditDebit creditFee = new CreditDebit { Account = systemAcc, Credit = fee.Amount, Transaction = Transaction, TransactionDescription = TransactionOpeningFeeDescription, TransactionType = Models.Transaction.TransactionTypes.ACCOUNT_CREATION_FEE }; try { API.Controllers.Transaction.Create(Transaction); Transaction = API.Controllers.Transaction.FindByGUID(Transaction.TransationGUId); CreditDebit.Transaction = Transaction; creditFee.Transaction = Transaction; API.Controllers.TransactionDescription.Create(TransactionOpeningFeeDescription); TransactionOpeningFeeDescription = API.Controllers.TransactionDescription.FindByGUID(TransactionOpeningFeeDescription.GUID); creditFee.TransactionDescription = TransactionOpeningFeeDescription; API.Controllers.TransactionDescription.Create(TransactionDescription); TransactionDescription = API.Controllers.TransactionDescription.FindByGUID(TransactionDescription.GUID); CreditDebit.TransactionDescription = TransactionDescription; API.Controllers.CreditDebit.Create(CreditDebit); API.Controllers.CreditDebit.Create(creditFee); CreditDebit = API.Controllers.CreditDebit.FindByTransactionId(Transaction.TransactionId); API.Message("Transaction Processed Successfully", MessageBoxIcon.Information); AccountDetails AccDetails = new AccountDetails(account); AccDetails.ShowDialog(); } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } } }
private void btnProceed_Click(object sender, EventArgs e) { if (txtDepositAmount.Text.Trim().Equals(String.Empty) || txtAccNames.Text.Trim().Equals(String.Empty)) { API.Message("Input all Parameters", MessageBoxIcon.Warning); } else if (Convert.ToDouble(txtDepositAmount.Text) < fee.Amount) { API.Message("You Have to Pay Opening Account Fee", MessageBoxIcon.Warning); } else { try { Account account = new Account { Names = txtAccNames.Text, Balance = 0.0, Type = AccountType, UserId = Convert.ToInt32(User.Id), PIN = txtPIN.Text }; API.Controllers.Accounts.CreateAccount(account); account = API.Controllers.Accounts.FetchNewUserAccount(Convert.ToInt32(User.Id), account.Names); API.Message(account.Names, MessageBoxIcon.Warning); Account systemAcc = API.Controllers.Accounts.FetchByAccountNumber(0); Transaction Transaction = new Transaction { TransationGUId = Guid.NewGuid().ToString(), TransationType = Transaction.TransactionTypes.DEPOSIT }; TransactionDescription TransactionDescription = new TransactionDescription { Description = "First Deposit", CreditAccount = account, DebitAccount = account, GUID = Guid.NewGuid().ToString() }; CreditDebit CreditDebit = new CreditDebit { Account = account, PrevBalance = 0.0, Credit = Convert.ToDouble(txtDepositAmount.Text) - fee.Amount, Transaction = Transaction, TransactionDescription = TransactionDescription, TransactionType = Models.Transaction.TransactionTypes.DEPOSIT }; TransactionDescription TransactionOpeningFeeDescription = new TransactionDescription { Description = "Opening Fee : " + fee.Amount, CreditAccount = systemAcc, DebitAccount = account, GUID = Guid.NewGuid().ToString() }; CreditDebit creditFee = new CreditDebit { Account = systemAcc, Credit = fee.Amount, Transaction = Transaction, TransactionDescription = TransactionOpeningFeeDescription, TransactionType = Models.Transaction.TransactionTypes.ACCOUNT_CREATION_FEE }; try { API.Controllers.Transaction.Create(Transaction); Transaction = API.Controllers.Transaction.FindByGUID(Transaction.TransationGUId); CreditDebit.Transaction = Transaction; creditFee.Transaction = Transaction; API.Controllers.TransactionDescription.Create(TransactionOpeningFeeDescription); TransactionOpeningFeeDescription = API.Controllers.TransactionDescription.FindByGUID(TransactionOpeningFeeDescription.GUID); creditFee.TransactionDescription = TransactionOpeningFeeDescription; API.Controllers.TransactionDescription.Create(TransactionDescription); TransactionDescription = API.Controllers.TransactionDescription.FindByGUID(TransactionDescription.GUID); CreditDebit.TransactionDescription = TransactionDescription; API.Controllers.CreditDebit.Create(CreditDebit); API.Controllers.CreditDebit.Create(creditFee); CreditDebit = API.Controllers.CreditDebit.FindByTransactionId(Transaction.TransactionId); API.Message("Transaction Processed Successfully", MessageBoxIcon.Information); API.ClearFields(this.Controls); AccountDetails AccDetails = new AccountDetails(account); AccDetails.ShowDialog(); } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } } catch (Exception ex) { API.Message(ex.Message, MessageBoxIcon.Error); return; } } }