public void save(SettlementBatal dbitem, int id, string modul) { dbitem.ModifiedDate = DateTime.Now; if (dbitem.Id == 0) //create { var query = "INSERT INTO dbo.\"SettlementBatal\" (\"IdSalesOrder\", \"KasDiterima\", \"TransferDiterima\", \"SolarDiterima\", \"KapalDiterima\", \"KeteranganDiterima\", \"KasDiakui\"," + "\"TransferDiakui\", \"SolarDiakui\", \"KapalDiakui\", \"KeteranganDiakui\", \"KasKembali\", \"TransferKembali\", \"SolarKembali\", \"KapalKembali\", \"KeteranganKembali\"," + "\"KasAktual\", \"TransferAktual\", \"SolarAktual\", \"KapalAktual\", \"KeteranganAktual\", \"KasSelisih\", \"TransferSelisih\", \"SolarSelisih\", \"KapalSelisih\"," + "\"KeteranganSelisih\", \"Keterangan\", \"IsProses\", \"ModifiedDate\", \"ModifiedBy\", \"JenisBatal\", \"IdDriver\", \"IdAdminUangJalan\", \"IdSoKontrak\", \"Code\", \"IdDataTruck\"" + ") VALUES (" + dbitem.IdSalesOrder + ", " + dbitem.KasDiterima + ", " + dbitem.TransferDiterima + ", " + dbitem.SolarDiterima + ", " + dbitem.KapalDiterima + ", " + dbitem.KeteranganDiterima + ", " + dbitem.KasDiakui + ", " + dbitem.TransferDiakui + ", " + dbitem.SolarDiakui + ", " + dbitem.KapalDiakui + ", " + dbitem.KeteranganDiakui + ", " + dbitem.KasKembali + ", " + dbitem.TransferKembali + ", " + dbitem.SolarKembali + ", " + dbitem.KapalKembali + ", " + dbitem.KeteranganKembali + ", " + dbitem.KasAktual + ", " + dbitem.TransferAktual + ", " + dbitem.SolarAktual + ", " + dbitem.KapalAktual + ", " + dbitem.KeteranganAktual + ", " + dbitem.KasSelisih + ", " + dbitem.TransferSelisih + ", " + dbitem.SolarSelisih + ", " + dbitem.KapalSelisih + ", " + dbitem.KeteranganSelisih + ", " + dbitem.Keterangan + ", " + dbitem.IsProses + ", " + dbitem.ModifiedDate + ", " + dbitem.ModifiedBy + ", " + dbitem.JenisBatal + ", " + dbitem.IdDriver + ", " + dbitem.IdAdminUangJalan + ", " + dbitem.IdSoKontrak + ", " + dbitem.Code + ", " + dbitem.IdDataTruck + ");"; context.SettlementBatal.Add(dbitem); var auditrail = new Auditrail { Actionnya = "Edit", EventDate = DateTime.Now, Modulenya = modul, QueryDetail = query, RemoteAddress = AppHelper.GetIPAddress(), IdUser = id }; context.Auditrail.Add(auditrail); } else //edit { context.SettlementBatal.Attach(dbitem); var query = "UPDATE dbo.\"SettlementBatal\" SET \"KasDiterima\" = " + dbitem.KasDiterima + ", \"TransferDiterima\" = " + dbitem.TransferDiterima + ", \"SolarDiterima\" = " + dbitem.SolarDiterima + ", \"KapalDiterima\" = " + dbitem.KapalDiterima + ", \"KeteranganDiterima\" = " + dbitem.KeteranganDiterima + ", \"KasDiakui\" = " + dbitem.KasDiakui + ", \"TransferDiakui\" = " + dbitem.TransferDiakui + ", \"SolarDiakui\" = " + dbitem.SolarDiakui + ", \"KapalDiakui\" = " + dbitem.KapalDiakui + ", \"KeteranganDiakui\" = " + dbitem.KeteranganDiakui + ", \"KasKembali\" = " + dbitem.KasKembali + ", \"TransferKembali\" = " + dbitem.TransferKembali + ", \"SolarKembali\" = " + dbitem.SolarKembali + ", \"KapalKembali\" = " + dbitem.KapalKembali + ", \"KeteranganKembali\" = " + dbitem.KeteranganKembali + ", \"KasAktual\" = " + dbitem.KasAktual + ", \"TransferAktual\" = " + dbitem.TransferAktual + ", \"SolarAktual\" = " + dbitem.SolarAktual + ", \"KapalAktual\" = " + dbitem.KapalAktual + ", \"KeteranganAktual\" = " + dbitem.KeteranganAktual + ", \"KasSelisih\" = " + dbitem.KasSelisih + ", \"TransferSelisih\" = " + dbitem.TransferSelisih + ", \"SolarSelisih\" = " + dbitem.SolarSelisih + ", \"KapalSelisih\" = " + dbitem.KapalSelisih + ", \"KeteranganSelisih\" = " + dbitem.KeteranganSelisih + ", \"Keterangan\" = " + dbitem.Keterangan + ", \"IsProses\" = " + dbitem.IsProses + ", \"ModifiedDate\" = " + dbitem.ModifiedDate + ", \"ModifiedBy\" = " + dbitem.ModifiedBy + ", \"JenisBatal\" = " + dbitem.JenisBatal + ", \"IdDriver\" = " + dbitem.IdDriver + ", \"IdAdminUangJalan\" = " + dbitem.IdAdminUangJalan + ", \"Code\" = " + dbitem.Code + ", \"IdDataTruck\"" + dbitem.IdDataTruck + " WHERE \"Id\" = " + dbitem.Id + ";"; var auditrail = new Auditrail { Actionnya = "Edit", EventDate = DateTime.Now, Modulenya = modul, QueryDetail = query, RemoteAddress = AppHelper.GetIPAddress(), IdUser = id }; var entry = context.Entry(dbitem); entry.State = EntityState.Modified; } context.SaveChanges(); }
public ActionResult View(int id) { Context.SettlementBatal dbitem = RepoSettlementBatal.FindByPK(id); SettlementBatal model = new SettlementBatal(dbitem); if (model.ModelOncall != null) { ViewBag.name = model.ModelOncall.SONumber; } if (model.ModelPickup != null) { ViewBag.name = model.ModelPickup.SONumber; } if (model.ModelKonsolidasi != null) { ViewBag.name = model.ModelKonsolidasi.SONumber; } return(View(model)); }
public ActionResult Edit(int id) { Context.SettlementBatal dbitem = RepoSettlementBatal.FindByPK(id); if (dbitem.IdSoKontrak == "" || dbitem.IdSoKontrak == null) { SettlementBatal model = new SettlementBatal(dbitem); Context.SalesOrder dbso = RepoSalesOrder.FindByPK(dbitem.IdSalesOrder.Value); ViewBag.SPBU = dbso.AdminUangJalan.AdminUangJalanVoucherSpbu; ViewBag.KeteranganBatal = dbso.KeteranganBatal; if (model.ModelOncall != null) { ViewBag.name = model.ModelOncall.SONumber; if (dbitem.Driver != null && dbitem.DataTruck != null) { ViewBag.KodeDriver = dbitem.Driver.KodeDriver; ViewBag.KodeDriverOld = dbitem.Driver.KodeDriverOld; ViewBag.DriverName = dbitem.Driver.NamaDriver; ViewBag.VehicleNo = dbitem.DataTruck.VehicleNo; } } if (model.ModelPickup != null) { ViewBag.name = model.ModelPickup.SONumber; } if (model.ModelKonsolidasi != null) { ViewBag.name = model.ModelKonsolidasi.SONumber; } return(View("Form", model)); } else { SettlementBatal model = new SettlementBatal(dbitem); Context.SalesOrder dbso = RepoSalesOrder.FindByPK(dbitem.IdSalesOrder.Value); ViewBag.SPBU = dbso.SalesOrderKontrak.SalesOrderKontrakListSo.Where(d => d.Id == int.Parse(dbitem.IdSoKontrak)).FirstOrDefault().AdminUangJalan.AdminUangJalanVoucherSpbu; return(View("Form", model)); } }
public ActionResult Edit(SettlementBatal model) { if (ModelState.IsValid) { Context.SettlementBatal dbitem = RepoSettlementBatal.FindByPK(model.Id); if (dbitem.IdSoKontrak == "" || dbitem.IdSoKontrak == null) { Context.SalesOrder dbso = RepoSalesOrder.FindByPK(model.IdSalesOrder.Value); Context.AdminUangJalan db = RepoAdminUangJalan.FindByPK(dbso.AdminUangJalanId.Value); Context.ERPConfig erpConfig = RepoERPConfig.FindByFrist(); dbitem.Code = "SB-" + (dbso.SalesOrderOncallId.HasValue ? dbso.SalesOrderOncall.SONumber : dbso.SalesOrderProsesKonsolidasiId.HasValue ? dbso.SalesOrderProsesKonsolidasi.SONumber : dbso.SalesOrderPickupId.HasValue ? dbso.SalesOrderPickup.SONumber : dbso.SalesOrderKontrak.SONumber); model.SetDb(dbitem); //Jurnal Pengembalian Uang Jalan //(uang, dll dikembalikan utuh), mau utuh mau ngga, nominal cash yg dikembalikan mah ambil dari form :p decimal nominalHutangUangJalanDriver = (model.KasAktual == null ? 0 : model.KasAktual.Value) + (model.TransferAktual == null ? 0 : model.TransferAktual.Value); decimal nomDiakui = (model.KasDiakui == null ? 0 : model.KasDiakui.Value) + (model.TransferDiakui == null ? 0 : model.TransferDiakui.Value) + (model.SolarDiakui == null ? 0 : model.SolarDiakui.Value) + (model.KapalDiakui == null ? 0 : model.KapalDiakui.Value); decimal nomSelisih = (dbitem.KasSelisih == null ? 0 : dbitem.KasSelisih.Value) + (dbitem.TransferSelisih == null ? 0 : dbitem.TransferSelisih.Value) + (dbitem.KapalSelisih == null ? 0 : dbitem.KapalSelisih.Value); nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanVoucherSpbu.Select(d => d.Value).Sum().ToString()); nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanVoucherKapal.Select(d => d.Value).Sum().ToString()); nominalHutangUangJalanDriver += db.KasbonDriver1 == null ? 0 : db.KasbonDriver1.Value; nominalHutangUangJalanDriver += db.KlaimDriver1 == null ? 0 : db.KlaimDriver1.Value; nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanPotonganDriver.Select(d => d.Value).Sum().ToString()); decimal?TotalBiaya = nomDiakui; int idx = 2; if (nomDiakui > 0) { Repoglt_det.saveFromAc(2, "SB-" + dbso.SalesOrderOncall.SONumber, nomDiakui, 0, Repoac_mstr.FindByPk(erpConfig.IdBiayaBatalJalan));//BIAYA BATAL JALAN } foreach (Context.AdminUangJalanVoucherSpbu aujvs in db.AdminUangJalanVoucherSpbu) { idx++; if (model.SPBUKembali != null && model.SPBUKembali.Contains(aujvs.Keterangan)) //jurnal balik, ga jadi hutangnya { Repoglt_det.saveFromAc(idx, "SB-" + dbso.SalesOrderOncall.SONumber, aujvs.Value, 0, Repoac_mstr.FindByPk(RepoLookup.FindByName(aujvs.Keterangan).ac_id)); //HUTANG SPBU 34.171.04 Pangkalan 2 dan atau TotalBiaya += aujvs.Value; } else //jadi hutang SPBU, masuk ke AP Inv { string a = aujvs.Keterangan; string username = UserPrincipal.username; int? vend = RepoLookup.FindByName(aujvs.Keterangan).VendorId; int vendorId = RepoLookup.FindByName(aujvs.Keterangan).VendorId.Value; Context.Customer cust = RepoCustomer.FindByPK(RepoLookup.FindByName(aujvs.Keterangan).VendorId.Value); Repogr_mstr.save(aujvs.Value, cust, username, dbitem.Code); } } Repoglt_det.saveFromAc(idx, "SB-" + dbso.SalesOrderOncall.SONumber, dbitem.SolarSelisih, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverBatalJalanSementaraSolar)); TotalBiaya += dbitem.SolarSelisih; if (dbitem.KapalAktual > 0) { foreach (Context.AdminUangJalanVoucherKapal aujvs in db.AdminUangJalanVoucherKapal) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbso.SalesOrderOncall.SONumber, aujvs.Value, 0, Repoac_mstr.FindByPk(RepoLookup.FindByName(aujvs.Keterangan).ac_id));//HUTANG SPBU 34.171.04 Pangkalan 2 dan atau TotalBiaya += aujvs.Value; } } // if (nomSelisih > 0){ idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbso.SalesOrderOncall.SONumber, nomSelisih, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverBatalJalan), "Selisih Kas/Transfer/Kapal");//PIUTANG DRIVER BATAL JALAN TotalBiaya += nomSelisih; // } //mau utuh mau ngga, nominal cash yg dikembalikan mah ambil dari form :p Repoglt_det.saveFromAc(2, "SB-" + dbso.SalesOrderOncall.SONumber, model.KasAktual, 0, Repoac_mstr.FindByPk(RepoMasterPool.FindByIPAddress().IdCreditCash)); //BCA Audy 386-7957777 atau Repoglt_det.saveFromAc(2, "SB-" + dbso.SalesOrderOncall.SONumber, model.TransferAktual, 0, Repoac_mstr.FindByPk(dbitem.IdCreditTf)); //BCA Audy 386-7957777 atau TotalBiaya += (model.KasAktual + model.TransferAktual); Repoglt_det.saveFromAc(1, "SB-" + dbso.SalesOrderOncall.SONumber, 0, TotalBiaya, Repoac_mstr.FindByPk(erpConfig.IdAUJCredit)); //Hutang Uang Jalan Driver RepoSettlementBatal.save(dbitem, UserPrincipal.id, "Settlement Batal"); try {//masuklah ke saldo piutang driver, save to pby_mstr&det var glt_oid = Guid.NewGuid().ToString(); Repopbyd_det.saveMstr(glt_oid, dbitem.Code, erpConfig.IdAUJCredit.Value, "Settlement Batal " + dbitem.Code, db.IdDriver1.Value + 7000000); Repopbyd_det.save( glt_oid, dbitem.Code, erpConfig.IdAUJCredit.Value, "Settlement Batal " + dbitem.Code, db.IdDriver1.Value + 7000000, erpConfig.IdAUJCredit.Value, Repoac_mstr.FindByPk(erpConfig.IdAUJCredit).ac_name, 0 ); } catch (Exception e) {} } else { Context.SalesOrder dbso = RepoSalesOrder.FindByPK(model.IdSalesOrder.Value); Context.SalesOrderKontrakListSo dbKontrak = dbso.SalesOrderKontrak.SalesOrderKontrakListSo.Where(d => d.Id == int.Parse(dbitem.IdSoKontrak)).FirstOrDefault(); Context.AdminUangJalan db = RepoAdminUangJalan.FindByPK(dbKontrak.IdAdminUangJalan.Value); Context.ERPConfig erpConfig = RepoERPConfig.FindByFrist(); dbitem.Code = "SB-" + (dbso.SalesOrderOncallId.HasValue ? dbso.SalesOrderOncall.SONumber : dbso.SalesOrderProsesKonsolidasiId.HasValue ? dbso.SalesOrderProsesKonsolidasi.SONumber : dbso.SalesOrderPickupId.HasValue ? dbso.SalesOrderPickup.SONumber : dbso.SalesOrderKontrak.SONumber); model.SetDb(dbitem); //Jurnal Pengembalian Uang Jalan //(uang, dll dikembalikan utuh), mau utuh mau ngga, nominal cash yg dikembalikan mah ambil dari form :p decimal nominalHutangUangJalanDriver = model.KasAktual ?? model.KasAktual.Value + model.TransferAktual ?? model.TransferAktual.Value; decimal nomDiakui = model.KasDiakui ?? model.KasDiakui.Value + model.TransferDiakui ?? model.TransferDiakui.Value + model.SolarDiakui ?? model.SolarDiakui.Value + model.KapalDiakui ?? model.KapalDiakui.Value; decimal nomSelisih = dbitem.KasSelisih.Value + dbitem.TransferSelisih.Value + dbitem.KapalSelisih.Value; nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanVoucherSpbu.Select(d => d.Value).Sum().ToString()); nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanVoucherKapal.Select(d => d.Value).Sum().ToString()); nominalHutangUangJalanDriver += db.KasbonDriver1 == null ? 0 : db.KasbonDriver1.Value; nominalHutangUangJalanDriver += db.KlaimDriver1 == null ? 0 : db.KlaimDriver1.Value; nominalHutangUangJalanDriver += decimal.Parse(db.AdminUangJalanPotonganDriver.Select(d => d.Value).Sum().ToString()); int idx = 2; Repoglt_det.saveFromAc(1, "SB-" + dbKontrak.NoSo, 0, nominalHutangUangJalanDriver, Repoac_mstr.FindByPk(erpConfig.IdAUJCredit));//Hutang Uang Jalan Driver if (nomDiakui > 0) { Repoglt_det.saveFromAc(2, "SB-" + dbKontrak.NoSo, nomDiakui, 0, Repoac_mstr.FindByPk(erpConfig.IdBiayaBatalJalan));//BIAYA BATAL JALAN } foreach (Context.AdminUangJalanVoucherSpbu aujvs in db.AdminUangJalanVoucherSpbu) { idx++; if (model.SPBUKembali.Contains(aujvs.Keterangan)) { Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, aujvs.Value, 0, Repoac_mstr.FindByPk(RepoLookup.FindByName(aujvs.Keterangan).ac_id));//HUTANG SPBU 34.171.04 Pangkalan 2 dan atau } else { Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, aujvs.Value, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverBatalJalanSementaraSolar), "Voucher SPBU " + aujvs.Keterangan); } } foreach (Context.AdminUangJalanVoucherKapal aujvs in db.AdminUangJalanVoucherKapal) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, aujvs.Value, 0, Repoac_mstr.FindByPk(RepoLookup.FindByName(aujvs.Keterangan).ac_id));//HUTANG SPBU 34.171.04 Pangkalan 2 dan atau } // if (nomSelisih > 0){ idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, nomSelisih, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverBatalJalan), "Selisih Kas/Transfer/Kapal");//PIUTANG DRIVER BATAL JALAN // } if (db.PotonganB > 0) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, db.PotonganB, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverBatalJalan));//PIUTANG DRIVER BATAL JALAN } if (db.PotonganP > 0) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, db.PotonganP, 0, Repoac_mstr.FindByPk(erpConfig.IdPiutangDriverPribadi));//PIUTANG DRIVER BATAL JALAN / SEMENTARA TUNAI } if (db.PotonganK > 0) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, db.PotonganK, 0, Repoac_mstr.FindByPk(erpConfig.IdPendapatanPengembalianPiutangDriver)); } if (db.PotonganT > 0) { idx++; Repoglt_det.saveFromAc(idx, "SB-" + dbKontrak.NoSo, db.PotonganT, 0, Repoac_mstr.FindByPk(erpConfig.IdTabunganDriver)); } //mau utuh mau ngga, nominal cash yg dikembalikan mah ambil dari form :p Repoglt_det.saveFromAc(2, "SB-" + dbKontrak.NoSo, model.KasAktual, 0, Repoac_mstr.FindByPk(RepoMasterPool.FindByIPAddress().IdCreditCash)); //BCA Audy 386-7957777 atau Repoglt_det.saveFromAc(2, "SB-" + dbKontrak.NoSo, model.TransferAktual, 0, Repoac_mstr.FindByPk(db.AdminUangJalanUangTf.FirstOrDefault().IdCreditTf)); //BCA Audy 386-7957777 atau RepoSettlementBatal.save(dbitem, UserPrincipal.id, "Settlement Batal"); try {//masuklah ke saldo piutang driver, save to pby_mstr&det var glt_oid = Guid.NewGuid().ToString(); Repopbyd_det.saveMstr(glt_oid, dbitem.Code, erpConfig.IdAUJCredit.Value, "Settlement Batal " + dbitem.Code, db.IdDriver1.Value + 7000000); Repopbyd_det.save( glt_oid, dbitem.Code, erpConfig.IdAUJCredit.Value, "Settlement Batal " + dbitem.Code, db.IdDriver1.Value + 7000000, erpConfig.IdAUJCredit.Value, Repoac_mstr.FindByPk(erpConfig.IdAUJCredit).ac_name, 0 ); } catch (Exception e) {} } return(RedirectToAction("Index")); } return(View("Form", model)); }
public void delete(SettlementBatal dbitem) { context.SettlementBatal.Remove(dbitem); context.SaveChanges(); }