Esempio n. 1
0
        public Customer(Context.Customer dbitem)
        {
            Id               = dbitem.Id;
            CustomerCode     = dbitem.CustomerCode;
            CustomerCodeOld  = dbitem.CustomerCodeOld;
            CustomerNama     = dbitem.CustomerNama;
            PrioritasId      = dbitem.PrioritasId;
            StrPrioritas     = dbitem.LookupCode.Nama;
            WajibPO          = dbitem.WajibPO;
            WajibGPS         = dbitem.WajibGPS;
            SpecialTreatment = dbitem.SpecialTreatment;
            Keterangan       = dbitem.Keterangan;
            CustomerPicId    = dbitem.CustomerPicId;


            ListPic              = dbitem.CustomerPic.ToList();
            ListAddress          = dbitem.CustomerAddress.ToList();
            ListProduct          = dbitem.CustomerProductType.ToList();
            ListLoadingAddress   = dbitem.CustomerLoadingAddress.ToList();
            ListUnLoadingAddress = dbitem.CustomerUnloadingAddress.ToList();
            ListSupplier         = dbitem.CustomerSupplier.ToList();
            ListBilling          = dbitem.CustomerBilling.ToList();
            ListNotif            = dbitem.CustomerNotification.ToList();

            ////ppn
            if (dbitem.CustomerPPN.Count() > 0)
            {
                Context.CustomerPPN ppnItem = dbitem.CustomerPPN.FirstOrDefault();
                IdPPN       = ppnItem.Id;
                IsPPn       = ppnItem.PPN;
                IdRekening  = ppnItem.IdRekening;
                NoNpwp      = ppnItem.NomorNPWP;
                NamaNpwp    = ppnItem.NamaNPWP;
                AddressNpwp = ppnItem.AddressNPWP;
            }
            else
            {
                IsPPn = true;
            }
            //cs
            if (dbitem.CustomerCreditStatus.Count() > 0)
            {
                Context.CustomerCreditStatus dbcs = dbitem.CustomerCreditStatus.FirstOrDefault();
                IdCreditStatus = dbcs.Id;
                StatusSystem   = dbcs.StatusSystem;
                StatusOveride  = dbcs.StatusOveride;
                KeteranganCS   = dbcs.Keterangan;
                ConditionCS    = dbcs.Condition;
                MinTOPOverdue1 = dbcs.MinTOPOverdue1;
                MaxTOPOverdue1 = dbcs.MaxTOPOverdue1;
                ValueOverdue2  = dbcs.ValueOverdue2;
                TOPOverdue2    = dbcs.TOPOverdue2;
                ShipmentDay1   = dbcs.ShipmentDay1;
                ShipmentDay2   = dbcs.ShipmentDay2;
            }
        }
Esempio n. 2
0
        public void saveSoMstr(SalesOrder soitem, string username, string guid, int customerId, decimal harga)
        {
            Context.so_mstr  model      = new Context.so_mstr();
            Context.Customer dbCustomer = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.Customer : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.Customer : soitem.SalesOrderPickup.Customer;
            model.so_oid          = guid;
            model.so_dom_id       = 1;
            model.so_en_id        = 1;
            model.so_add_by       = username;
            model.so_add_date     = DateTime.Now;
            model.so_upd_by       = username;
            model.so_upd_date     = DateTime.Now;
            model.so_code         = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.SONumber : soitem.SalesOrderProsesKonsolidasiId.HasValue ? soitem.SalesOrderProsesKonsolidasi.SONumber : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.SONumber : soitem.SalesOrderPickup.SONumber;
            model.so_ptnr_id_sold = customerId;
            model.so_ptnr_id_bill = customerId;
            model.so_date         = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.TanggalMuat.Value : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.TanggalPickup : soitem.SalesOrderPickup.TanggalPickup;
            model.so_credit_term  = 991025;                                                                                                                  //dbCustomer == null ? 0 : dbCustomer.CustomerCreditStatus.FirstOrDefault().ValueOverdue2.Value;//,   Customer Term of Payment
            model.so_taxable      = dbCustomer != null && dbCustomer.CustomerPPN != null && dbCustomer.CustomerPPN.FirstOrDefault().PPN == true ? "Y" : "N"; // Checkbox
            model.so_tax_class    = 0;                                                                                                                       //, from code_mstr where code_field ~~* 'taxclass_mstr'
            model.so_si_id        = 1;
            model.so_type         = "R";
//            model.so_sales_person = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.Driver1Id.Value : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.Driver1Id.Value : soitem.SalesOrderPickup.Driver1Id.Value;//0;//,  from ptnr_mstr where ptnr_is_member ~~* 'Y'
            model.so_pi_id      = 101;          //, from pi_mstr
            model.so_pay_type   = "9942";       //,  from code_mstr where code_field ~~* 'payment_type'
            model.so_pay_method = 99290;        //"0";// ,   from code_mstr where code_field ~~* 'payment_methode'
            model.so_ar_ac_id   = 0;            //, From pla_mstr.pla_ac_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)

            /*model.so_ar_sb_id = 0;//,  From pla_mstr.pla_sb_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)
             * model.so_ar_cc_id = 0;//   From pla_mstr.pla_cc_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)
             */model.so_dp                = 0;//,    nominal yg didapat dr form InputDP
            model.so_disc_header       = 0;
            model.so_total             = harga; //, Total SO
            model.so_tran_id           = 0;
            model.so_trans_id          = "D";
            model.so_dt                = DateTime.Now;
            model.so_cu_id             = 1;      //, from cu_mstr.cu_id currency)
            model.so_total_ppn         = 0;      //, Total PPN From Detail SO
            model.so_total_pph         = 0;      //, Total PPH From Detail SO
            model.so_payment           = 0;
            model.so_exc_rate          = 1;      //,  kurs mata uang From exr_rate current Date and Current Currency
            model.so_tax_inc           = "N";    //,   Y or N termasuk pajak atau belum, checkbox)
            model.so_cons              = "N";    //,  Y or N konsinyasi atau bukan, checkbox)
            model.so_terbilang         = "N";    //, Terbilang dalam bahasa indonesia
            model.so_bk_id             = 0;      //, from bk_mstr.bk_id Nama Bank)
            model.so_interval          = 1;      //,  from code_mstr where code_field ~~* 'payment_type'  kolom code_user_1
            model.so_ppn_type          = "A";    //,  E=PPN BEBAS, A = PPN BAYAR, N = NON
            model.so_branch_id         = 10001;  //, SO Branch from branch_mstr.branch_id)
            model.so_group_id          = 991414; //,  from code_mstr where code_field ~~* 'so_group'
            model.so_exc_rate_pi       = 0;
            model.so_prct_limit_return = 0;
            model.so_disc_type         = 0;
            model.so_departure_date    = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.TanggalMuat : soitem.SalesOrderProsesKonsolidasiId.HasValue ? soitem.SalesOrderProsesKonsolidasi.TanggalMuat : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.TanggalPickup : soitem.SalesOrderPickup.TanggalPickup;
            model.so_start_route       = "0"; //,   Kota Awal Berangkat from code_mstr where code_field ~~* 'route_mstr'
            model.so_destination_route = "0"; //  kota Tujuan from code_mstr where code_field ~~* 'route_mstr'*/
            context.so_mstr.Add(model);
            context.SaveChanges();
        }
Esempio n. 3
0
 public void setDb(Context.Customer dbitem)
 {
     dbitem.Id               = Id;
     dbitem.CustomerCode     = CustomerCode;
     dbitem.CustomerCodeOld  = CustomerCodeOld;
     dbitem.CustomerNama     = CustomerNama;
     dbitem.PrioritasId      = PrioritasId.Value;
     dbitem.WajibPO          = bool.Parse(WajibPO.ToString());
     dbitem.WajibGPS         = bool.Parse(WajibGPS.ToString());
     dbitem.SpecialTreatment = SpecialTreatment;
     dbitem.Keterangan       = Keterangan;
     dbitem.CustomerPicId    = CustomerPicId;
 }
Esempio n. 4
0
        public SalesOrderKonsolidasi(Context.SalesOrder dbitem, Context.Customer supp = null)
        {
            SalesOrderId            = dbitem.Id;
            SalesOrderKonsolidasiId = dbitem.SalesOrderKonsolidasi.SalesOrderKonsolidasiId;
            SONumber     = dbitem.SalesOrderKonsolidasi.SONumber;
            DN           = dbitem.SalesOrderKonsolidasi.DN;
            Urutan       = dbitem.SalesOrderKonsolidasi.Urutan;
            TanggalOrder = dbitem.SalesOrderKonsolidasi.TanggalOrder;
            TanggalMasuk = dbitem.SalesOrderKonsolidasi.TanggalMasuk;
            SONumberCust = dbitem.SalesOrderKonsolidasi.SONumberCust;
            CustomerId   = dbitem.SalesOrderKonsolidasi.CustomerId;
            KodeCustomer = dbitem.SalesOrderKonsolidasi.Customer.CustomerCode;
            KodeNama     = dbitem.SalesOrderKonsolidasi.Customer.CustomerCodeOld;
            NamaCustomer = dbitem.SalesOrderKonsolidasi.Customer.CustomerNama;

            SupplierId   = dbitem.SalesOrderKonsolidasi.SupplierId;
            SupplierName = (supp != null) ? supp.CustomerNama : "";

            if (dbitem.SalesOrderKonsolidasi.NamaTagihanId.HasValue)
            {
                CustomerTagihanId   = dbitem.SalesOrderKonsolidasi.NamaTagihanId;
                KodeCustomerTagihan = dbitem.SalesOrderKonsolidasi.CustomerTagihan.CustomerCode;
                NamaCustomerTagihan = dbitem.SalesOrderKonsolidasi.CustomerTagihan.CustomerNama;
            }

            Keterangan      = dbitem.SalesOrderKonsolidasi.Keterangan;
            ProductId       = dbitem.SalesOrderKonsolidasi.ProductId;
            StrProduct      = dbitem.SalesOrderKonsolidasi.MasterProduct.NamaProduk;
            Suhu            = int.Parse(dbitem.SalesOrderKonsolidasi.MasterProduct.TargetSuhu.ToString());
            RuteId          = dbitem.SalesOrderKonsolidasi.IdDaftarHargaItem;
            Rute            = dbitem.SalesOrderKonsolidasi.StrDaftarHargaItem;
            TypeKonsolidasi = dbitem.SalesOrderKonsolidasi.TypeKonsolidasi;
            Tonase          = dbitem.SalesOrderKonsolidasi.Tonase;
            karton          = dbitem.SalesOrderKonsolidasi.karton;
            Container       = dbitem.SalesOrderKonsolidasi.Container;
            m3               = dbitem.SalesOrderKonsolidasi.m3;
            Pallet           = dbitem.SalesOrderKonsolidasi.Pallet;
            isMinimumBerat   = dbitem.SalesOrderKonsolidasi.isMinimumBerat;
            MinimumId        = dbitem.SalesOrderKonsolidasi.MinimumId;
            PerhitunganDasar = dbitem.SalesOrderKonsolidasi.PerhitunganDasar;
            Harga            = dbitem.SalesOrderKonsolidasi.Harga;
            TotalHarga       = dbitem.SalesOrderKonsolidasi.TotalHarga;
            CaraBayar        = dbitem.SalesOrderKonsolidasi.CaraBayar;
            Status           = dbitem.Status;
            DateStatus       = dbitem.DateStatus;
            IsSelect         = dbitem.SalesOrderKonsolidasi.IsSelect;
        }
Esempio n. 5
0
        public ActionResult Edit(int id, string caller)
        {
            Context.Dokumen dbitem        = RepoDokumen.FindByPK(id);
            List <int>      ListIdDokumen = dbitem.DokumenItem.Select(b => b.IdBilling).ToList();
            string          strQuery      = "";

            //cek apakah di billing customer ada penambahan data
            //jika ada maka update data jika data dokumen belum close
            if (!dbitem.IsComplete)
            {
                Context.Customer dbcust = dbitem.Customer;
                foreach (var itemBilling in dbitem.Customer.CustomerBilling.Where(i => !ListIdDokumen.Contains(i.Id)).ToList())
                {
                    dbitem.DokumenItem.Add(new Context.DokumenItem()
                    {
                        IdBilling    = itemBilling.Id,
                        CustomerId   = itemBilling.CustomerId,
                        ModifiedDate = DateTime.Now,
                    });
                    strQuery += "INSERT INTO dbo.\"DokumenItem\" (\"IdBilling\", \"CustomerId\", \"ModifiedDate\") VALUES (" + itemBilling.Id + ", " + itemBilling.CustomerId + ", " + DateTime.Now + ");";
                }
                RepoDokumen.save(dbitem, UserPrincipal.id, strQuery);
            }

            if (dbitem.SalesOrder.SalesOrderOncallId.HasValue)
            {
                ViewBag.TanggalPulang = dbitem.SalesOrder.SalesOrderOncall.TanggalMuat.Value.AddDays(RepoSalesOrder.FindRute(dbitem.SalesOrder.SalesOrderOncall.IdDaftarHargaItem.Value).WaktuKerja);
            }
            Dokumen model = new Dokumen(dbitem);

            ViewBag.caller = caller;
            if (caller == "admin")
            {
                ViewBag.Title = "Dokumen Admin Surat Jalan";
            }
            else
            {
                ViewBag.Title = "Dokumen Billing";
            }

            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));
        }
Esempio n. 7
0
        public void saveSoMstr(SalesOrder soitem, string username)
        {
            Context.so_mstr  model      = new Context.so_mstr();
            Context.Customer dbCustomer = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.Customer : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.Customer : soitem.SalesOrderPickup.Customer;
            model.so_oid          = Guid.NewGuid().ToString();
            model.so_dom_id       = 1;
            model.so_en_id        = 1;
            model.so_add_by       = username;
            model.so_add_date     = DateTime.Now;
            model.so_upd_by       = username;
            model.so_upd_date     = DateTime.Now;
            model.so_code         = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.SONumber : soitem.SalesOrderProsesKonsolidasiId.HasValue ? soitem.SalesOrderProsesKonsolidasi.SONumber : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.SONumber : soitem.SalesOrderPickup.SONumber;
            model.so_ptnr_id_sold = dbCustomer == null ? 0 : dbCustomer.Id;
            model.so_ptnr_id_bill = dbCustomer == null ? 0 : dbCustomer.Id;
            model.so_date         = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.TanggalOrder : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.TanggalOrder : soitem.SalesOrderPickup.TanggalOrder;
            //public string so_credit_term { get; set; }//,   Customer Term of Payment
            model.so_taxable      = dbCustomer != null && dbCustomer.CustomerPPN != null && dbCustomer.CustomerPPN.FirstOrDefault().PPN == true ? "Y" : "N"; // Checkbox
            model.so_tax_class    = 0;                                                                                                                       //, from code_mstr where code_field ~~* 'taxclass_mstr'
            model.so_si_id        = 1;
            model.so_type         = "R";
            model.so_sales_person = 0; //,  from ptnr_mstr where ptnr_is_member ~~* 'Y'
            model.so_pi_id        = 0; //, from pi_mstr

            /*model.so_pay_type = 0;//,  from code_mstr where code_field ~~* 'payment_type'
             * model.so_pay_method = 0;// ,   from code_mstr where code_field ~~* 'payment_methode'
             * model.so_ar_ac_id = 0; //, From pla_mstr.pla_ac_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)
             * model.so_ar_sb_id = 0;//,  From pla_mstr.pla_sb_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)
             * model.so_ar_cc_id = 0;//   From pla_mstr.pla_cc_id partnumber --> pt_mstr.pt_pl_id =pla_mstr.pl_id)
             * model.so_dp = 0;*/      //,    nominal yg didapat dr form InputDP
            model.so_disc_header = 0;
            model.so_total       = 0;  //, Total SO
            model.so_tran_id     = 0;
            model.so_trans_id    = "D";
            model.so_trans_rmks  = "0";//,    SO Approval Remarks Null)

/*            model.so_current_route = 0;//, Current City Route
 *          model.so_next_route = 0;//,    Next City Route
 *          model.so_dt = DateTime.now;
 *          model.so_cu_id = 0;//, from cu_mstr.cu_id currency)
 *          model.so_total_ppn = 0;//, Total PPN From Detail SO
 *          model.so_total_pph = 0;//, Total PPH From Detail SO
 *          model.so_payment = 0;
 *          model.so_exc_rate = 0;//,  kurs mata uang From exr_rate current Date and Current Currency
 *          model.so_tax_inc = 0;//,   Y or N termasuk pajak atau belum, checkbox)
 *          model.so_cons = 0;//,  Y or N konsinyasi atau bukan, checkbox)
 *          model.so_terbilang = 0;//, Terbilang dalam bahasa indonesia
 *          model.so_bk_id = 0;//, from bk_mstr.bk_id Nama Bank)
 *          model.so_interval = 0;//,  from code_mstr where code_field ~~* 'payment_type'  kolom code_user_1
 *          model.so_ppn_type = 0;//,  E=PPN BEBAS, A = PPN BAYAR, N = NON
 *          model.so_branch_id = 0;//, SO Branch from branch_mstr.branch_id)
 *          model.so_group_id = 0;//,  from code_mstr where code_field ~~* 'so_group'
 *          model.so_exc_rate_pi = 0;
 *          model.so_prct_limit_return = 0;
 *          model.so_disc_type = 0;
 *          model.so_vehicle = model.DataTruck.VehicleNo;
 *          model.so_departure_date = soitem.SalesOrderOncallId.HasValue ? soitem.SalesOrderOncall.TanggalMuat : soitem.SalesOrderProsesKonsolidasiId.HasValue ? soitem.SalesOrderProsesKonsolidasi.TanggalMuat : soitem.SalesOrderPickupId.HasValue ? soitem.SalesOrderPickup.TanggalMuat : soitem.SalesOrderPickup.TanggalMuat;
 *          model.so_start_route = 0;//,   Kota Awal Berangkat from code_mstr where code_field ~~* 'route_mstr'
 *          model.so_destination_route = 0;//  kota Tujuan from code_mstr where code_field ~~* 'route_mstr'*/
            context.so_mstr.Add(model);
            context.SaveChanges();
        }