public SettlementRegIndex(Context.SettlementReguler dbitem)
 {
     Id           = dbitem.Id;
     IdSalesOrder = dbitem.IdSalesOrder;
     if (dbitem.SalesOrder.SalesOrderOncallId.HasValue)
     {
         JenisOrder  = "Oncall";
         NoSo        = dbitem.SalesOrder.SalesOrderOncall.SONumber;
         Customer    = dbitem.SalesOrder.SalesOrderOncall.Customer.CustomerNama;
         VehicleNo   = dbitem.SalesOrder.SalesOrderOncall.DataTruck.VehicleNo;
         Driver      = dbitem.SalesOrder.AdminUangJalan.Driver1.NamaDriver;
         TanggalMuat = dbitem.SalesOrder.SalesOrderOncall.TanggalMuat.Value;
     }
     else if (dbitem.SalesOrder.SalesOrderPickupId.HasValue)
     {
         JenisOrder  = "Pickup";
         NoSo        = dbitem.SalesOrder.SalesOrderPickup.SONumber;
         Customer    = dbitem.SalesOrder.SalesOrderPickup.Customer.CustomerNama;
         VehicleNo   = dbitem.SalesOrder.SalesOrderPickup.DataTruck.VehicleNo;
         Driver      = dbitem.SalesOrder.AdminUangJalan.Driver1.NamaDriver;
         TanggalMuat = dbitem.SalesOrder.SalesOrderPickup.TanggalPickup;
     }
     else if (dbitem.SalesOrder.SalesOrderProsesKonsolidasiId.HasValue)
     {
         JenisOrder  = "Konsolidasi";
         NoSo        = dbitem.SalesOrder.SalesOrderProsesKonsolidasi.SONumber;
         Customer    = "";
         VehicleNo   = dbitem.SalesOrder.SalesOrderProsesKonsolidasi.DataTruck.VehicleNo;
         Driver      = dbitem.SalesOrder.AdminUangJalan.Driver1.NamaDriver;
         TanggalMuat = dbitem.SalesOrder.SalesOrderProsesKonsolidasi.TanggalMuat.Value;
     }
     ListIdSo      = "0";
     TotalTambahan = dbitem.SettlementRegulerTambahanBiaya.Sum(d => d.Value);
 }
 public SettlementRegIndex(Context.SettlementReguler dbitem, List <Context.SalesOrderKontrakListSo> dbso)
 {
     Id            = dbitem.Id;
     IdSalesOrder  = dbitem.SalesOrder.Id;
     JenisOrder    = "Kontrak";
     NoSo          = string.Join(", ", dbso.Select(s => s.NoSo).ToList());
     Customer      = dbitem.SalesOrder.SalesOrderKontrak.Customer.CustomerNama;
     VehicleNo     = dbso.FirstOrDefault().DataTruck.VehicleNo;
     Driver        = dbso.FirstOrDefault().Driver1.NamaDriver;
     TotalTambahan = dbitem.SettlementRegulerTambahanBiaya.Sum(d => d.Value);
     ListIdSo      = dbitem.LisSoKontrak;
     TanggalMuat   = dbso.OrderBy(d => d.MuatDate).FirstOrDefault().MuatDate;
 }
Example #3
0
        public void SetDb(Context.SettlementReguler dbitem)
        {
            dbitem.Code               = Code;
            dbitem.IdSalesOrder       = IdSalesOrder;
            dbitem.KasDiterima        = KasDiterima;
            dbitem.TransferDiterima   = TransferDiterima;
            dbitem.SolarDiterima      = SolarDiterima;
            dbitem.KapalDiterima      = KapalDiterima;
            dbitem.KeteranganDiterima = KeteranganDiterima;
            dbitem.KasDiakui          = KasDiakui;
            dbitem.TransferDiakui     = TransferDiakui;
            dbitem.SolarDiakui        = SolarDiakui;
            dbitem.KapalDiakui        = KapalDiakui;
            dbitem.KeteranganDiakui   = KeteranganDiakui;
            dbitem.KasKembali         = KasKembali;
            dbitem.TransferKembali    = TransferKembali;
            dbitem.SolarKembali       = SolarKembali;
            dbitem.KapalKembali       = KapalKembali;
            dbitem.KeteranganKembali  = KeteranganKembali;
            dbitem.KasAktual          = KasAktual;
            dbitem.TransferAktual     = TransferAktual;
            dbitem.SolarAktual        = SolarAktual;
            dbitem.KapalAktual        = KapalAktual;
            dbitem.KeteranganAktual   = KeteranganAktual;
            dbitem.KasSelisih         = KasSelisih;
            dbitem.TransferSelisih    = TransferSelisih;
            dbitem.SolarSelisih       = SolarSelisih;
            dbitem.KapalSelisih       = KapalSelisih;
            dbitem.KeteranganSelisih  = KeteranganSelisih;

            dbitem.SettlementRegulerTambahanBiaya.Clear();
            foreach (var item in ListBiayaTambahan)
            {
                dbitem.SettlementRegulerTambahanBiaya.Add(item.SetDb(new Context.SettlementRegulerTambahanBiaya()));
            }

            dbitem.TotalCash            = TotalCash;
            dbitem.TanggalCash          = TanggalCash;
            dbitem.IdDriverTujuan       = IdDriverTujuan;
            dbitem.IdDriverTitip        = IdDriverTitip;
            dbitem.TotalTf              = TotalTf;
            dbitem.TanggalTf            = TanggalTf;
            dbitem.IdAtm                = IdAtm;
            dbitem.KeteranganPembayaran = KeteranganPembayaran;
            dbitem.TotalBayar           = TotalBayar;
            dbitem.LisSoKontrak         = listIdSoKontrak;
        }
        public ActionResult ShowPrint(int id, string listSo, int idSo)
        {
            Context.SettlementReguler dbitem2 = RepoSettlementReg.FindByPK(id);
            SettlementReg             model   = new SettlementReg(dbitem2, RepoAtm.FindAll());

            Context.SalesOrder dbitem = RepoSalesOrder.FindByPK(idSo);
            var items = model.ListBiayaTambahan;

            ViewBag.item = items;

            if (dbitem.SalesOrderOncallId.HasValue)
            {
                model.ModelOncall = new SalesOrderOncall(dbitem);
                ViewBag.NoSO      = model.ModelOncall.SONumber;
                ViewBag.Customer  = model.ModelOncall.NamaCustomer;
                ViewBag.VNo       = model.ModelOncall.VehicleNo;
                ViewBag.Driver    = model.ModelOncall.NamaDriver1;
                return(View("Print", model));
            }
            else if (dbitem.SalesOrderPickupId.HasValue)
            {
                model.ModelPickup = new SalesOrderPickup(dbitem);
                ViewBag.NoSO      = model.ModelPickup.SONumber;
                ViewBag.Customer  = model.ModelPickup.NamaCustomer;
                ViewBag.VNo       = model.ModelPickup.VehicleNo;
                ViewBag.Driver    = model.ModelPickup.NamaDriver1;
                return(View("Print", model));
            }
            else if (dbitem.SalesOrderProsesKonsolidasiId.HasValue)
            {
                model.ModelKonsolidasi = new SalesOrderProsesKonsolidasi(dbitem);
                ViewBag.NoSO           = model.ModelKonsolidasi.SONumber;
                ViewBag.Customer       = "";
                ViewBag.VNo            = model.ModelKonsolidasi.VehicleNo;
                ViewBag.Driver         = model.ModelKonsolidasi.NamaDriver1;
                return(View("Print", model));
            }
            else if (dbitem.SalesOrderKontrakId.HasValue)
            {
                return(View("Print", model));
            }

            return(View("Print", model));
        }
        public ActionResult Edit(SettlementReg model)
        {
            SettlementRegTambahanBiaya[] res = JsonConvert.DeserializeObject <SettlementRegTambahanBiaya[]>(model.StrBiayaTambahan);
            model.ListBiayaTambahan = res.ToList();

            if (ModelState.IsValid)
            {
                Context.SettlementReguler dbitem = RepoSettlementReg.FindByPK(model.Id);
                model.SetDb(dbitem);
                RepoSettlementReg.save(dbitem, UserPrincipal.id);
                RepoAuditrail.saveDelAllSettlementRegulerBiayaTambahanQuery(dbitem, UserPrincipal.id);
                foreach (Context.SettlementRegulerTambahanBiaya srtb in dbitem.SettlementRegulerTambahanBiaya)
                {
                    RepoAuditrail.saveSettlementRegulerBiayaTambahanQuery(srtb, UserPrincipal.id);
                }

                return(RedirectToAction("Index"));
            }

            return(View("Form", model));
        }
        public ActionResult Edit(int id)
        {
            Context.SettlementReguler dbitem = RepoSettlementReg.FindByPK(id);
            SettlementReg             model  = new SettlementReg(dbitem, RepoAtm.FindAll());

            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;
            }
            if (model.ModelKontrak != null)
            {
                ViewBag.name = model.ModelKontrak.SONumber;
            }

            return(View("Form", model));
        }
        public ActionResult Add(SettlementReg model)
        {
            SettlementRegTambahanBiaya[] res = JsonConvert.DeserializeObject <SettlementRegTambahanBiaya[]>(model.StrBiayaTambahan);
            model.ListBiayaTambahan = res.ToList();
            Context.ERPConfig  erpConfig = RepoERPConfig.FindByFrist();
            Context.SalesOrder dbso      = RepoSalesOrder.FindByPK(model.IdSalesOrder.Value);
            string             sod_oid   = Guid.NewGuid().ToString();

            if (ModelState.IsValid)
            {
                if (model.listIdSoKontrak != "" && model.listIdSoKontrak != null)
                {
                    List <int> ListIdDumy = model.listIdSoKontrak.Split(new string[] { "." }, StringSplitOptions.None).ToList().Select(int.Parse).ToList();
                    List <Context.SalesOrderKontrakListSo> dbsoDummy = dbso.SalesOrderKontrak.SalesOrderKontrakListSo.Where(d => ListIdDumy.Contains(d.Id)).ToList();
                    //dbso.SalesOrderKontrak.SalesOrderKontrakListSo = dbsoDummy;
                    foreach (var item in dbsoDummy)
                    {
                        item.Status = "settlement";
                    }
                    Context.SettlementReguler dbitem = new Context.SettlementReguler();
                    model.SetDb(dbitem);
                    RepoSalesOrder.save(dbso);
                    RepoSettlementReg.save(dbitem, UserPrincipal.id);
                    foreach (Context.SettlementRegulerTambahanBiaya srtb in dbitem.SettlementRegulerTambahanBiaya)
                    {
                        RepoAuditrail.saveSettlementRegulerBiayaTambahanQuery(srtb, UserPrincipal.id);
                    }
                }
                else
                {
                    Context.SettlementReguler dbitem = new Context.SettlementReguler();
                    string code = (dbso.SalesOrderOncallId.HasValue ? dbso.SalesOrderOncall.SONumber : dbso.SalesOrderProsesKonsolidasiId.HasValue ? dbso.SalesOrderProsesKonsolidasi.SONumber : dbso.SalesOrderPickupId.HasValue ? dbso.SalesOrderPickup.SONumber : dbso.SalesOrderKontrak.SONumber);
                    dbitem.Code = "SR-" + code;
                    string unyu = dbitem.Code;
                    model.SetDb(dbitem);
                    Context.AdminUangJalan db = RepoAdminUangJalan.FindByPK(dbso.AdminUangJalanId.Value);
                    dbso.Status    = "settlement";
                    dbso.UpdatedBy = UserPrincipal.id;
                    if (dbso.oidErp == null)
                    {
                        dbso.oidErp = sod_oid;
                    }
                    RepoSalesOrder.save(dbso);
                    RepoSettlementReg.save(dbitem, UserPrincipal.id);
                    RepoAuditrail.saveSettRegHistory(dbso);
                    foreach (Context.SettlementRegulerTambahanBiaya srtb in dbitem.SettlementRegulerTambahanBiaya)
                    {
                        RepoAuditrail.saveSettlementRegulerBiayaTambahanQuery(srtb, UserPrincipal.id);
                    }

                    //lebah dieu sync ERPna
                    //klo ada revisi rute
                    //D
                    Repoglt_det.saveFromAc(1, dbitem.Code, dbitem.KasSelisih + dbitem.TransferSelisih + dbitem.SolarSelisih + (dbitem.KapalSelisih == null ? 0 : dbitem.KapalSelisih), 0, Repoac_mstr.FindByPk(erpConfig.IdKasbonDriver)); //Kasbon Driver (Piutang)
                    Repoglt_det.saveFromBk(2, dbitem.Code, dbitem.KasAktual + dbitem.TransferAktual + dbitem.SolarAktual + (dbitem.KapalAktual == null ? 0 : dbitem.KapalAktual), 0, Repobk_mstr.FindByPk(erpConfig.IdCashCredit));        //Cash
                    Repoglt_det.saveFromAc(3, dbitem.Code, dbitem.KasDiakui + dbitem.TransferDiakui + dbitem.SolarDiakui + (dbitem.KapalDiakui == null ? 0 : dbitem.KapalDiakui), 0, Repoac_mstr.FindByPk(erpConfig.IdBiayaPerjalanan));   //Biaya

                    //K
                    decimal?tambahanRute  = db.AdminUangJalanTambahanRute.Sum(s => s.values);
                    decimal?boronganDasar = db.TotalBorongan - db.Kawalan - db.Timbangan - db.Karantina - db.SPSI - db.Multidrop - tambahanRute - db.AdminUangJalanTambahanLain.Sum(s => s.Values);
                    Repoglt_det.saveFromAc(1, dbitem.Code, 0, boronganDasar, Repoac_mstr.FindByPk(erpConfig.IdBoronganDasar));
                    Repoglt_det.saveFromAc(2, dbitem.Code, 0, db.Kawalan, Repoac_mstr.FindByPk(erpConfig.IdKawalan));
                    Repoglt_det.saveFromAc(3, dbitem.Code, 0, db.Timbangan, Repoac_mstr.FindByPk(erpConfig.IdTimbangan));
                    Repoglt_det.saveFromAc(4, dbitem.Code, 0, db.Karantina, Repoac_mstr.FindByPk(erpConfig.IdKarantina));
                    Repoglt_det.saveFromAc(5, dbitem.Code, 0, db.SPSI, Repoac_mstr.FindByPk(erpConfig.IdSPSI));
                    Repoglt_det.saveFromAc(6, dbitem.Code, 0, db.Multidrop, Repoac_mstr.FindByPk(erpConfig.IdMultidrop));
                    Repoglt_det.saveFromAc(7, dbitem.Code, 0, tambahanRute, Repoac_mstr.FindByPk(erpConfig.IdTambahanRuteMuat));
                    Repoglt_det.saveFromAc(8, dbitem.Code, 0, db.AdminUangJalanTambahanLain.Sum(s => s.Values), Repoac_mstr.FindByPk(erpConfig.IdTambahanRuteLain));
                    Repoglt_det.saveFromAc(4, dbitem.Code, 0, db.TotalPotonganDriver, Repoac_mstr.FindByPk(erpConfig.IdKasbonAuj)); //Hutang ke Driver, jurnal balik dr auj

                    //Cash&Transfer pada biaya tambahan
                    Repoglt_det.saveFromAc(3, dbitem.Code, dbitem.SettlementRegulerTambahanBiaya.Sum(d => d.Value), 0, Repoac_mstr.FindByPk(erpConfig.IdBiayaPerjalanan)); //D, Biaya Tambahan
                    Repoglt_det.saveFromAc(2, dbitem.Code, 0, dbitem.TotalCash, Repoac_mstr.FindByPk(erpConfig.IdCashCredit));                                             //K, Cash
                    Repoglt_det.saveFromAc(2, dbitem.Code, 0, dbitem.TotalTf, Repoac_mstr.FindByPk(erpConfig.IdTfCredit));                                                 //K, Transfer
                }
                return(RedirectToAction("Index"));
            }

            return(View("Form", model));
        }
Example #8
0
        public SettlementReg(Context.SettlementReguler dbitem, List <Context.Atm> listAtm)
        {
            Id           = dbitem.Id;
            IdSalesOrder = dbitem.IdSalesOrder;
            Code         = dbitem.Code;
            if (dbitem.SalesOrder.SalesOrderOncallId.HasValue)
            {
                ModelOncall = new SalesOrderOncall(dbitem.SalesOrder);
            }
            else if (dbitem.SalesOrder.SalesOrderPickupId.HasValue)
            {
                ModelPickup = new SalesOrderPickup(dbitem.SalesOrder);
            }
            else if (dbitem.SalesOrder.SalesOrderProsesKonsolidasiId.HasValue)
            {
                ModelKonsolidasi = new SalesOrderProsesKonsolidasi(dbitem.SalesOrder);
            }
            else if (dbitem.SalesOrder.SalesOrderKontrakId.HasValue)
            {
                ModelKontrak = new SalesOrderKontrak(dbitem.SalesOrder);
            }
            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;

            ListBiayaTambahan = new List <SettlementRegTambahanBiaya>();
            foreach (var item in dbitem.SettlementRegulerTambahanBiaya)
            {
                ListBiayaTambahan.Add(new SettlementRegTambahanBiaya(item));
            }

            TotalCash      = dbitem.TotalCash;
            TanggalCash    = dbitem.TanggalCash;
            IdDriverTujuan = dbitem.IdDriverTujuan;
            if (dbitem.IdDriverTujuan.HasValue)
            {
                NamaDriverTujuan = dbitem.DriverTujuan.KodeDriver + " - " + dbitem.DriverTujuan.NamaDriver;
            }
            IdDriverTitip = dbitem.IdDriverTitip;
            if (dbitem.IdDriverTitip.HasValue)
            {
                NamaDriverTitip = dbitem.DriverTitip.KodeDriver + " - " + dbitem.DriverTitip.NamaDriver;
            }
            TotalTf   = dbitem.TotalTf;
            TanggalTf = dbitem.TanggalTf;
            if (dbitem.IdAtm.HasValue)
            {
                IdAtm       = dbitem.IdAtm;
                NoRekening  = dbitem.Atm.NoRekening;
                AtasNamaRek = dbitem.Atm.AtasNama;
                Bank        = dbitem.Atm.LookupCodeBank.Nama;
            }
            else
            {
                //Context.Atm dbattm = listAtm.Where(d => d.IdDriver == dbitem.SalesOrder.AdminUangJalan.IdDriver1).FirstOrDefault();
                //if (dbattm != null)
                //{
                //    IdAtm = dbattm.Id;
                //    NoRekening = dbattm.NoRekening;
                //    AtasNamaRek = dbattm.AtasNama;
                //    Bank = dbattm.LookupCodeBank.Nama;
                //}
            }

            KeteranganPembayaran = dbitem.KeteranganPembayaran;
            listIdSoKontrak      = dbitem.LisSoKontrak;
            TotalBayar           = dbitem.TotalBayar;
        }