Пример #1
0
        public void init()
        {
            _periodeId = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));

            _cashFlow = new CashFlow("ABC", _periodeId, 500000.0);
            _periode = new Periode(_periodeId,StatusPeriode.Mingguan);
        }
Пример #2
0
 public CashFlow(string tenanId, PeriodeId periodId, double saldoAwal)
 {
     this._tenanId = tenanId;
     this._periodId = periodId;
     this._saldoAwal = saldoAwal;
     Calculate();
 }
Пример #3
0
        public void testProsesNotaPengeluaran()
        {
            var transactionDate = new DateTime(2015, 10, 26);
            var periodId = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
            var listAkun = new string[] { "Ayam" };
            var listSummaryAkun = new List<SummaryAkunDto>()
            {
            new SummaryAkunDto(){ PeriodId = "20151104",Akun ="Ayam", Nominal=600000.0}
            };
            var factory = new MockRepository(MockBehavior.Loose);
            var mockRepository = factory.Create<IRepository>();
            var mockCashFlow = factory.Create<ICashFlow>();
            var mockPengeluaran = factory.Create<INotaPengeluaran>();
            var mockCurrentPeriod = factory.Create<IPeriod>();
            mockRepository.Setup(t => t.FindPeriodForDate(transactionDate)).Returns(mockCurrentPeriod.Object);
            mockCurrentPeriod.SetupGet(t => t.PeriodId).Returns(periodId);
            mockRepository.Setup(t => t.FindCashFlowByPeriod(periodId)).Returns(mockCashFlow.Object);
            mockPengeluaran.SetupGet(t => t.Date).Returns(transactionDate);
            mockPengeluaran.Setup(t => t.ListAkun()).Returns(listAkun);
            mockRepository.Setup(t => t.ListSummaryAkunIn(mockCurrentPeriod.Object, listAkun)).Returns(listSummaryAkun);
            mockCashFlow.Setup(t => t.ChangePengeluaran(It.IsAny<string>(), It.IsAny<double>(),It.IsAny<int>()));
            mockRepository.Setup(t => t.Save(mockCashFlow.Object));

            var service = new ProcessNotaPengeluaran();
            service.Repository = mockRepository.Object;
            service.Process(mockPengeluaran.Object);
            factory.VerifyAll();
        }
Пример #4
0
 public void TestIsDateInPeriod()
 {
     var id1 = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
     Assert.IsTrue(id1.IsInPeriod(new DateTime(2015, 11, 2)));
     Assert.IsTrue(id1.IsInPeriod(new DateTime(2015, 11, 3)));
     Assert.IsTrue(id1.IsInPeriod(new DateTime(2015, 11, 4)));
     Assert.IsTrue(id1.IsInPeriod(new DateTime(2015, 11, 5)));
 }
Пример #5
0
 public CashFlow(CashFlowDto snapshot)
 {
     this._tenanId=snapshot.TenantId;
        this._periodId = new PeriodeId(snapshot.PeriodId.StartPeriode, snapshot.PeriodId.EndPeriode);
        this._saldoAwal = snapshot.SaldoAwal;
        this._saldoAkhir = snapshot.SaldoAkhir;
        this._totalPenjualan = snapshot.TotalPenjualan;
        this._totalPenjualanLain = snapshot.TotalPenjualanLain;
        this._totalPengeluaran = snapshot.TotalPengeluaran;
        this._itemsPenjualan = ConvertToItemsPenjualan(snapshot.ItemsPenjualan);
        this._itemsPenjualanLain = ConvertToItemsPenjualanLain(snapshot.ItemsPenjualanLain);
        this._itemsPengeluaran = ConvertToItemsPengeluaran(snapshot.ItemsPengeluaran);
 }
Пример #6
0
        public void testPeriodeTidakDitemukanDiRepository()
        {
            var transactionDate = new DateTime(2015, 10, 26);
            var periodId = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));

            var factory = new MockRepository(MockBehavior.Loose);
            var mockRepository = factory.Create<IRepository>();

            var mockPengeluaran = factory.Create<INotaPengeluaran>();
            var mockCashFlow = factory.Create<ICashFlow>();
            mockRepository.Setup(t => t.FindCashFlowByPeriod(periodId)).Returns(mockCashFlow.Object);
            mockPengeluaran.SetupGet(t => t.Date).Returns(transactionDate);

            var service = new ProcessNotaPengeluaran();
            service.Repository = mockRepository.Object;
            service.Process(mockPengeluaran.Object);
        }
Пример #7
0
 public CashFlowId(PeriodeId periodId)
 {
     this._periodId = periodId;
 }
Пример #8
0
 public Periode(PeriodeId periodid, ex.StatusPeriode statusPeriode)
 {
     this._periodid = periodid;
     this._statusPeriode = statusPeriode;
 }
Пример #9
0
 public CashFlowId(PeriodeId periodId)
 {
     this._periodId = periodId;
 }
Пример #10
0
 public void TestPeriodEquality()
 {
     var id1 = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
     var id2 = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
     Assert.AreEqual(id1, id2);
 }
 public void init()
 {
     _periodeId = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
     _periode = new Periode(_periodeId, StatusPeriode.Bebas);
 }
        public void TestCashflowSucessCase()
        {
            var repo = new InMemoryRepository();
            var periodeId1 = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
            var periode = new Periode(periodeId1, StatusPeriode.Mingguan);
            repo.SavePeriod(periode);
            var periodeSnapShot = new PeriodeDto()
            {
                StartPeriode = new DateTime(2015, 11, 1),
                EndPeriode = new DateTime(2015, 11, 6),
                IsPeriode = StatusPeriode.Bebas
            };

            var periodeSave = repo.FindPeriodForDate(new DateTime(2015, 11, 3));

            Assert.AreEqual(periodeSnapShot, periodeSave.Snap());

            //cashflow
            var cashFlow = new CashFlow("ABC", periodeId1, 500000.0);
            repo.Save(cashFlow);

            var cashflowSnapshotDto = new CashFlowDto()
            {
                TenantId = "ABC",
                PeriodId = periode.Snap(),
                SaldoAwal = 500000.0,
                SaldoAkhir = 500000.0,
                TotalPenjualan = 0.0,
                TotalPenjualanLain = 0.0,
                TotalPengeluaran = 0.0,
            };

            var findCashFlow = repo.FindCashFlowByPeriod(periodeId1);
            Assert.AreEqual(cashflowSnapshotDto, findCashFlow.Snap());

            //Penjualan
            cashFlow.AddPenjualan(new DateTime(2015, 11, 1), 200000.0);
            repo.Save(cashFlow);
            var repoFind = repo.FindPeriodForDate(new DateTime(2015, 11, 3));
            var cashFlowSnapshot = cashFlow.Snap();
            var cashflowPenjualanSnapshot = new CashFlowDto()
            {
                TenantId = "ABC",
                PeriodId = periode.Snap(),
                SaldoAwal = 500000.0,
                SaldoAkhir = 700000.0,
                TotalPenjualan = 200000.0,
                TotalPenjualanLain = 0.0,
                TotalPengeluaran = 0.0,
            };

            Assert.AreEqual(cashflowPenjualanSnapshot, cashFlowSnapshot);
            Assert.AreEqual(1, cashFlowSnapshot.ItemsPenjualan.Count);
            var itemPenjualan = cashFlowSnapshot.ItemsPenjualan[0];
            Assert.AreEqual(new DateTime(2015, 11, 1), itemPenjualan.DateTime);
            Assert.AreEqual(200000.0, itemPenjualan.Nominal);

            //PenjualanLain
            cashFlow.AddPenjualanLain(new DateTime(2015, 11, 1), 200000.0);
            repo.Save(cashFlow);
            var repoFindLain = repo.FindPeriodForDate(new DateTime(2015, 11, 3));
            var cashFlowSnapshotLain = cashFlow.Snap();
            var cashflowPenjualanLainSnapshot = new CashFlowDto()
            {
                TenantId = "ABC",
                PeriodId = periode.Snap(),
                SaldoAwal = 500000.0,
                SaldoAkhir = 900000.0,
                TotalPenjualan = 200000.0,
                TotalPenjualanLain = 200000.0,
                TotalPengeluaran = 0.0,
            };

            Assert.AreEqual(cashflowPenjualanLainSnapshot, cashFlowSnapshotLain);
            Assert.AreEqual(1, cashFlowSnapshotLain.ItemsPenjualanLain.Count);
            var itemPenjualanLain = cashFlowSnapshotLain.ItemsPenjualanLain[0];
            Assert.AreEqual(new DateTime(2015, 11, 1), itemPenjualanLain.DateTimeLain);
            Assert.AreEqual(200000.0, itemPenjualanLain.NominalLain);

            //Pengeluaran
            cashFlow.ChangePengeluaran("Ayam",200000,5);
            repo.Save(cashFlow);
            var repoFindPengeluaran = repo.FindPeriodForDate(new DateTime(2015, 11, 3));
            var cashFlowSnapshotPengeluaran = cashFlow.Snap();
            var cashflowPengeluaranSnapshot = new CashFlowDto()
            {
                TenantId = "ABC",
                PeriodId = periode.Snap(),
                SaldoAwal = 500000.0,
                SaldoAkhir = 700000.0,
                TotalPenjualan = 200000.0,
                TotalPenjualanLain = 200000.0,
                TotalPengeluaran = 200000.0,
            };

            Assert.AreEqual(cashflowPengeluaranSnapshot, cashFlowSnapshotPengeluaran);
            Assert.AreEqual(1, cashFlowSnapshotPengeluaran.ItemsPengeluaran.Count);
            var itemPengeluaran = cashFlowSnapshotPengeluaran.ItemsPengeluaran[0];
            Assert.AreEqual("Ayam", itemPengeluaran.Akun);
            Assert.AreEqual(200000.0, itemPengeluaran.Nominal);
            Assert.AreEqual(5, itemPengeluaran.Jumlah);

            //NotaPengeluaran

            //var noNota = new NotaPengeluaranId("123");
            //var notaPengeluaran = new NotaPengeluaran(new DateTime(2015, 11, 1), noNota);
            //repo.SaveNota(notaPengeluaran);
            //var foundNota = repo.FindNotaPengeluaranByID("123");
            ////var notaSnapshot = notaPengeluaran.Snap();
            //var notaSnap = new NotaPengeluaranDto()
            //{
            //    Tanggal = new DateTime(2015, 11, 1),
            //    NoNota = noNota,
            //    TotalNota = 0.0
            //};
            //Assert.AreEqual(notaSnap, foundNota.Snap());

            ////AddAkunNota
            //notaPengeluaran.AddAkun("Ayam", 200000, 5);
            //repo.SaveNota(notaPengeluaran);
            //var repoFindNotaAkun = repo.FindPeriodForDate(new DateTime(2015, 11, 3));
            //var notaAkunSnapshot = notaPengeluaran.Snap();
            //var notaAkunSnap = new NotaPengeluaranDto()
            //{
            //    Tanggal = new DateTime(2015, 10, 26),
            //    NoNota = "123",
            //    TotalNota = 0.0
            //};
            //Assert.AreEqual(notaAkunSnap, notaAkunSnapshot);
        }
Пример #13
0
 public Periode(PeriodeId periodid, ex.StatusPeriode statusPeriode)
 {
     this._periodid      = periodid;
     this._statusPeriode = statusPeriode;
 }