public void GetDataTest() { using (var trans = TransHelper.NewScope()) { // arrange var expected = ReceiptDataFactory(); _purchaseDal.Insert(expected); // act var actual = _purchaseDal.GetData("A1"); // assert actual.Should().BeEquivalentTo(expected); } }
public void Generate(string brgID) { // listing brg // from adjustment plus var listStok = new List <StokItem>(); var listAdj = _stokAdj2Dal.ListDataBrg(brgID); if (listAdj != null) { Int32 i2 = 0; var e1 = new StartProsesStokEventArgs { ProsesName = "List Data Adjustment", DataCount = listAdj.Count() }; OnStartProses(e1); foreach (var item in listAdj) { i2++; var header = _stokAdjDal.GetData(item.StokAdjustmentID); if (header is null) { continue; } var e = new ProsesRegenStokEventArgs { Counter = i2, Tgl = header.TglTrs, TrsID = header.StokAdjustmentID }; OnProsesRegenStok(e); StokItem stok; if (item.QtyAdjust > 0) { stok = new StokItem { ReffID = item.StokAdjustmentID, Tgl = header.TglTrs, Jam = header.JamTrs, BrgID = item.BrgID, BrgName = item.BrgName, QtyIn = item.QtyAdjust, NilaiHpp = item.HppAdjust, QtyOut = 0, HargaJual = 0, BPStokID = "" } } ; else { stok = new StokItem { ReffID = item.StokAdjustmentID, Tgl = header.TglTrs, Jam = header.JamTrs, BrgID = item.BrgID, BrgName = item.BrgName, QtyIn = 0, NilaiHpp = 0, QtyOut = item.QtyAdjust * -1, HargaJual = 0, BPStokID = "", } }; listStok.Add(stok); } } var listJual = _penjualan2Dal.ListDataBrg(brgID); if (listJual != null) { Int32 i2 = 0; var e1 = new StartProsesStokEventArgs { ProsesName = "List Data Penjualan", DataCount = listJual.Count() }; OnStartProses(e1); foreach (var item in listJual) { i2++; var header = _penjualanDal.GetData(item.PenjualanID); if (header is null) { continue; } var e = new ProsesRegenStokEventArgs { Counter = i2, Tgl = header.TglPenjualan, TrsID = header.PenjualanID }; OnProsesRegenStok(e); var stok = new StokItem { ReffID = header.PenjualanID, Tgl = header.TglPenjualan, Jam = header.JamPenjualan, BrgID = item.BrgID, BPStokID = item.BPStokID, BrgName = item.BrgName, QtyIn = 0, NilaiHpp = 0, QtyOut = item.Qty, HargaJual = item.Harga, }; listStok.Add(stok); } } var listReceipt = _receiptDetilDal.ListData(brgID); if (listReceipt != null) { Int32 i2 = 0; var e1 = new StartProsesStokEventArgs { ProsesName = "List Data PenReceiptjualan", DataCount = listReceipt.Count() }; OnStartProses(e1); foreach (var item in listReceipt) { i2++; var header = _receiptDal.GetData(item.ReceiptID); if (header is null) { continue; } var e = new ProsesRegenStokEventArgs { Counter = i2, Tgl = header.Tgl, TrsID = header.ReceiptID }; OnProsesRegenStok(e); var stok = new StokItem { ReffID = header.ReceiptID, Tgl = header.Tgl, Jam = header.Jam, BrgID = item.BrgID, BrgName = item.BrgName, QtyIn = item.Qty, NilaiHpp = item.Harga - item.Diskon - item.TaxRupiah, QtyOut = 0, HargaJual = 0, BPStokID = "", }; listStok.Add(stok); } } Int32 i3 = 0; var e3 = new StartProsesStokEventArgs { ProsesName = "Re-generate stok", DataCount = listStok.Count() }; OnStartProses(e3); var listProsesAdd = listStok.Where(x => x.QtyIn > 0); foreach (var item in listProsesAdd.OrderBy(x => x.Tgl + x.Jam)) { i3++; var e = new ProsesRegenStokEventArgs { Counter = i3, Tgl = item.Tgl, TrsID = item.ReffID }; OnProsesRegenStok(e); _ = AddStok(item); } var listProsesRemove = listStok.Where(x => x.QtyOut > 0); foreach (var item in listProsesRemove.OrderBy(x => x.Tgl + x.Jam)) { i3++; var e = new ProsesRegenStokEventArgs { Counter = i3, Tgl = item.Tgl, TrsID = item.ReffID }; OnProsesRegenStok(e); _ = RemoveStok(item); } }