Ejemplo n.º 1
0
        public void PersonFrom_Must_Have_Valid_Bank_Account_Number()
        {
            // Arrange
            Person person = new PhysicalPerson("12345678901", "Mile", "Milic");
            LegalPerson legalPerson = new LegalPerson("12345678901", "Mile d.o.o");

            // Act
            Bill bill = new Bill(person, legalPerson, 23);

            // Assert
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Placanje racuna iz pricuve
        /// </summary>
        /// <param name="bill">racun</param>
        /// <returns></returns>
        public bool PayBill(Bill bill)
        {
            if(money < bill.TotalAmountWithTax) {
                return false;
            }

            money -= bill.TotalAmountWithTax;
            paymentTransactions.Add(new PaymentTransaction(bill, bill.TotalAmountWithTax));
            bill.IsPayed = true;

            return true;
        }
Ejemplo n.º 3
0
        public void Can_Create_Bill()
        {
            // Arrange
            Person person = new PhysicalPerson("12345678901", "Mile", "Milic");
            LegalPerson legalPerson = new LegalPerson("12345678901", "Mile d.o.o") {
                NumberOfBankAccount = "123487815645"
            };

            // Act
            Bill bill = new Bill(person, legalPerson, 23);

            // Assert
            Assert.IsNotNull(bill);
            Assert.IsFalse(bill.IsPayed);
        }
Ejemplo n.º 4
0
        public void Can_Calculate_Correct_Total_Amount_With_And_Without_Tax()
        {
            // Arrange
            Person person = new PhysicalPerson("12345678901", "Mile", "Milic");
            LegalPerson legalPerson = new LegalPerson("12345678901", "Mile d.o.o") {
                NumberOfBankAccount = "123487815645"
            };

            Bill bill = new Bill(person, legalPerson, 23);
            bill.AddBillItem(new BillItem(1, 23.5m, "Kruške"));
            bill.AddBillItem(new BillItem(3, 46.8m, "Jabuke"));

            // Act
            var totalAmount = bill.TotalAmount;
            var totalAmountWithTax = bill.TotalAmountWithTax;

            // Assert
            Assert.AreEqual(163.9m, totalAmount);
            Assert.AreEqual(201.597m, totalAmountWithTax);
        }
Ejemplo n.º 5
0
        public void Can_Receive_Money_From_Payed_Bill()
        {
            // Arrange
            Reserve reserve = new Reserve(building);
            decimal currentMoneyStatus = reserve.MoneyStatus;

            Bill bill = new Bill(new PhysicalPerson("12345678903", "Mile", "Milic"), building.BuildingManager.LegalPerson, 23);

            // Act
            reserve.PayBill(bill);

            // Assert
            Assert.AreEqual(currentMoneyStatus + bill.TotalAmountWithTax, reserve.MoneyStatus);
            Assert.IsTrue(bill.IsPayed);
        }
Ejemplo n.º 6
0
        public void Can_Pay_Bill_From_Reserve()
        {
            // Arrange
            Reserve reserve = new Reserve(building);
            decimal currentMoneyStatus = reserve.MoneyStatus;

            LegalPerson legalPerson = new LegalPerson("12345678901", "Mile d.o.o.") {
                NumberOfBankAccount = "1234"
            };

            Bill bill = new Bill(building.RepresentativeOfPartOwners, legalPerson, 23);

            // Act
            reserve.PayBill(bill);

            // Assert
            Assert.AreEqual(currentMoneyStatus - bill.TotalAmountWithTax, reserve.MoneyStatus);
            Assert.IsTrue(bill.IsPayed);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Izadaje racun za pricuvu
        /// </summary>
        /// <param name="apartment">stan za kojieg se izdaje racun za placanje pricuve</param>
        /// <returns>racun za pricuvu</returns>
        public Bill IssueReserveBillFor(Apartment apartment)
        {
            if(apartment.ResponsibleTenant == null) {
                throw new RulesException("Responsible tenant is not set.");
            }

            Bill bill = new Bill(apartment.ResponsibleTenant, buildingManager.LegalPerson, tax);
            decimal price = reserveCoefficient * apartment.SurfaceArea;
            BillItem billItem = new BillItem(1, price, "Pričuva");
            bill.AddBillItem(billItem);
            bill.ReferenceNumber = REFERENCE_NUMBER_PREFIX + apartment.Id + bill.DateTimeIssued.ToShortDateString();

            return bill;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Uplata novca dobivenog iz pricuve
 /// </summary>
 /// <param name="bill">racun</param>
 public void ReceivePaymentFor(Bill bill)
 {
     bill.IsPayed = true;
     money += bill.TotalAmountWithTax;
 }
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="bill">racun za kojeg se uplacuje ili isplacuje</param>
 /// <param name="amountOfMoney">svota novca</param>
 public PaymentTransaction(Bill bill, decimal amountOfMoney)
 {
     this.bill = bill;
     this.amountOfMoney = amountOfMoney;
     dateTime = DateTime.Now;
 }