Пример #1
0
        public static bool InsertBookingNew(ISession session, string trxid, int fid, string fitur, int clientid,
                                            string debitaccount, string debitaccountname, string debitcurr,
                                            string creditaccount, string creditaccountname, string creditcurr,
                                            double instAmount, string instCurrency, string dealrate, string trxremark, string trxremark2, DateTime trxdate,
                                            int booktype, string bookingoffice, double feeBen, out int idbooking, out string OutMsg)
        {
            bool result = true;

            idbooking = 0;
            OutMsg    = "";

            //20161122 - Add SayedZul Handler duplicate data
            try
            {
                string theQuery = "select id from booking where trxid = '" + trxid + "' and fid = " + fid + " and booktype = " + booktype + " and status <> 4 and not (status = 3 and statusec = 3) limit 1;";
                string theId    = "";
                string msg      = "";
                if (!PayrollHelper.ExecuteQueryValue(session, theQuery, out theId, out msg))
                {
                    result = false;
                    OutMsg = "Exception on checking duplicate trx - Message: " + msg;
                    Console.WriteLine("Exception Id: " + trxid + " === " + OutMsg);
                    return(result);
                }
                else
                {
                    if (!String.IsNullOrEmpty(theId))
                    {
                        result    = false;
                        idbooking = int.Parse(theId);
                        OutMsg    = "Transaction already exist: " + idbooking;
                        return(result);
                    }
                }
            }
            catch (Exception ee)
            {
                result = false;
                OutMsg = "Exception on checking duplicate trx - Message: " + ee.Message + " - InnerEx: " + ee.InnerException + " - StackTr: " + ee.StackTrace;
                Console.WriteLine("Exception Id: " + trxid + " === " + OutMsg);
                return(result);
            }

            try
            {
                Booking bookrcd = new Booking();
                bookrcd.TrxId = trxid.ToString();
                bookrcd.FID   = fid;
                bookrcd.Fitur = fitur;

                #region set jenis transaksi

                string JenisTransaksi = "";
                fitur = fitur.ToUpper();
                if (fitur.Equals("IFT"))
                {
                    JenisTransaksi = TotalOBHelper.Overbooking;
                }
                else if (fitur.Contains("LLG") || fitur.Contains("KLIRING"))
                {
                    JenisTransaksi = TotalOBHelper.LLG;
                }
                else if (fitur.Contains("RTG"))
                {
                    JenisTransaksi = TotalOBHelper.RTGS;
                }
                else if (fitur.Contains("SWIFT") || fitur.Contains("MOR"))
                {
                    JenisTransaksi = TotalOBHelper.SWIFT;
                }
                else if (fitur.Contains("PAYROLL"))
                {
                    string   temp     = trxremark;
                    string[] jenisTrx = temp.Trim().Split(' ');

                    if (jenisTrx.Length > 2)
                    {
                        if (jenisTrx[2].Equals("LLG"))
                        {
                            JenisTransaksi = TotalOBHelper.LLG;
                        }
                        else
                        {
                            JenisTransaksi = TotalOBHelper.RTGS;
                        }
                    }
                }
                else
                {
                    JenisTransaksi = "OTHER";
                }

                if (fid == 80 || fid == 85)
                {
                    JenisTransaksi = TotalOBHelper.Overbooking;
                }
                bookrcd.JenisTransaksi = JenisTransaksi;

                #endregion

                bookrcd.ClientId          = clientid;
                bookrcd.DebitAccount      = debitaccount;
                bookrcd.DebitAccountName  = debitaccountname;
                bookrcd.CreditAccount     = creditaccount;
                bookrcd.CreditAccountName = creditaccountname;
                bookrcd.InstAmount        = instAmount;
                bookrcd.InstCurrency      = instCurrency;
                bookrcd.DealRate          = dealrate;
                bookrcd.TrxRemark         = trxremark;
                bookrcd.TrxRemark2        = trxremark2;
                bookrcd.TrxDate           = trxdate;
                bookrcd.BookType          = booktype;
                bookrcd.BookingOffice     = bookingoffice;

                bookrcd.Status       = ParameterHelper.SCH_WAITINGBOOK;
                bookrcd.Description  = ParameterHelper.BOOKINGDESC_WAITINGBOOKING;
                bookrcd.CreationDate = DateTime.Now;
                bookrcd.LastUpdate   = DateTime.Now;
                bookrcd.FeeBen       = Convert.ToInt32(feeBen);

                /* Denny IL - 27 Feb 17
                 * Add to get Currency from Account Number
                 */
                //bookrcd.CreditCurrency = GetCurrency(creditaccount);//skenariuo gagal insert
                bookrcd.CreditCurrency = creditcurr;
                bookrcd.DebitCurrency  = SchHelper._Currency(debitaccount);


                session.Save(bookrcd);
                idbooking = bookrcd.Id;
                session.Flush();
                result = true;
            }
            catch (Exception e)
            {
                OutMsg = "Exception " + e.Message + "||" + e.InnerException + "||" + e.StackTrace;
                result = false;
            }

            return(result);
        }
Пример #2
0
        private void Commitjob_transaction(ILog log)
        {
            IList <TrxPayrollDetail> txList = session.CreateSQLQuery("select * from trxpayrolldetails where status = ? and instructioncode in ('" + TotalOBHelper.RTGS + "','" + TotalOBHelper.LLG + "') and lastupdate < now()")
                                              .AddEntity(typeof(TrxPayrollDetail))
                                              .SetInt32(0, ParameterHelper.TRXSTATUS_PAYROLLNEW_POST_MBASEANDWS_RTGSANDLLG)
                                              .List <TrxPayrollDetail>();

            if (txList.Count > 0)
            {
                foreach (TrxPayrollDetail o in txList)
                {
                    try
                    {
                        #region PARAMETERS
                        int    outid  = 0;
                        string outmsg = "";
                        Double _amt   = 0;

                        TrxPayroll    p         = o.Parent;
                        ClientAccount clientAcc = new ClientAccount();

                        Booking b = session.Load <Booking>(o.IdBooking);

                        ClientMatrix    cm     = session.Load <ClientMatrix>(p.ClientID);
                        Client          client = session.Load <Client>(p.ClientID);
                        AuthorityHelper ah     = new AuthorityHelper(cm.Matrix);

                        if (o.InstructionCode.Equals(TotalOBHelper.RTGS))
                        {
                            _amt = Double.Parse(ah.GetTransactionFee(session, 100, 2).ToString());
                        }
                        else if (o.InstructionCode.Equals(TotalOBHelper.LLG))
                        {
                            _amt = Double.Parse(ah.GetTransactionFee(session, 100, 3).ToString());
                        }

                        int    fid           = 100;
                        string fitur         = TotalOBHelper.Payroll;
                        string debitAcc      = "";
                        string debitAccName  = "";
                        string creditAcc     = o.Account;
                        string creditAccName = o.Name;
                        string benAddress    = o.BenAddress;
                        string remark        = o.TrxRemark.Trim();
                        string bucketAmt     = b.Bucket;
                        string chargeType    = "OUR";
                        if (b.FeeBen > 0)
                        {
                            chargeType = "BEN";
                        }
                        string debitAccAddress = client.Address1;

                        try
                        {
                            IList <ClientAccount> clAccs = session.CreateCriteria(typeof(ClientAccount))
                                                           .Add(Expression.Eq("Number", p.DebitAccount))
                                                           .Add(Expression.Eq("Pid", p.ClientID))
                                                           .Add(Expression.Eq("StatusDel", 0))
                                                           .SetMaxResults(1)
                                                           .List <ClientAccount>();

                            clientAcc = clAccs[0];

                            debitAcc     = p.DebitAccount;
                            debitAccName = clientAcc.Name;
                        }
                        catch { }
                        #endregion

                        #region PROCESS INSERT

                        /*Modified by Mettaw : 1 Oct 2019
                         *
                         * Terjadi perubahan Flow MBASE pada Payroll LLG (Kliring) namun tidak pada Payroll RTGS
                         * Code Sedikit dirombak , bila RTGS pakai flow Lama, yaitu Insert ke tbl MBASEandWS
                         * dan dimakan sama Sch MBASEAndWS
                         *
                         * Sedangkan LLG di insert ke tbl baru ExpressProcess.
                         * dan dimakan sama ExpressProcessSch
                         *
                         */

                        if (o.InstructionCode.Equals(TotalOBHelper.RTGS))
                        {
                            #region Insert to MBASEandWS
                            log.Info(SchCode + " === (TrxID " + o.Id + ") === Begin Posting to MBASEANDWS");

                            if (MBASEAndWSHelper.insertMbaseandws(session, int.Parse(o.Id.ToString()), fid, fitur, p.ClientID, o.InstructionCode, debitAcc,
                                                                  debitAccName, creditAcc, creditAccName, benAddress, remark, bucketAmt, o.IdBooking, o.RemittanceNumber,
                                                                  o.BankCode.Trim(), b.JournalSeq.Trim(), chargeType, _amt, debitAccAddress, out outid, out outmsg))
                            {
                                o.Status       = ParameterHelper.TRXSTATUS_PAYROLLNEW_CHECK_MBASEANDWS_RTGSANDLLG;
                                o.IdMBASEAndWS = outid;
                                o.Description  = "proses mbaseandws".ToUpper();
                                log.Info(SchCode + " === (TrxID " + o.Id + ") === Posting to MBASEANDWS SUCCESS");
                            }
                            else
                            {
                                if (outid > 0)
                                {
                                    o.Status       = ParameterHelper.TRXSTATUS_PAYROLLNEW_CHECK_MBASEANDWS_RTGSANDLLG;
                                    o.IdMBASEAndWS = outid;
                                    o.Description  = "proses mbaseandws".ToUpper();

                                    log.Info(SchCode + " === (TrxID " + o.Id + ") === Already Exist, Posting to MBASEANDWS SUCCESS");
                                }
                                else
                                {
                                    //gagal insert Mbaseandws
                                    o.LastUpdate = DateTime.Now.AddMinutes(2);

                                    log.Error(SchCode + " === (TrxID " + o.Id + ") === Posting to MBASEANDWS FAILED: " + outmsg);
                                }
                            }
                            session.Update(o);
                            session.Flush();

                            log.Info(SchCode + " === (TrxID " + o.Id + ") === End Posting to MBASEANDWS");
                            #endregion
                        }
                        else if (o.InstructionCode.Equals(TotalOBHelper.LLG))
                        {
                            #region Insert to ExpressProcess
                            log.Info(SchCode + " === (TrxID " + o.Id + ") === Begin Posting to ExpressProcess");

                            #region PARAMETERS FOR ExpressProcess
                            ExpressProcess exprocess = new ExpressProcess();

                            String _fitur = "PAYROLL LLG";

                            BankKliring bank = session.CreateCriteria(typeof(BankKliring))
                                               .Add(Expression.Eq("BankCode", o.Account))
                                               .UniqueResult <BankKliring>();

                            double _instamount  = o.Amount;
                            string _instcur     = SchHelper._Currency(o.RemittanceNumber);
                            string _benbankname = bank.Nama;
                            #endregion

                            #region ADD ExpressProcess

                            /*New added by Mettaw :
                             * tampung data disini... untuk parameter WS Express
                             * dan insert ke tbl expressprocess
                             * 9 september 2019*/

                            /*DATA MANDATORY*/
                            exprocess.Tanggal_Transaksi            = DateTime.Now;
                            exprocess.Sarana_Transaksi             = "2";
                            exprocess.Kode_Transaksi               = "50";
                            exprocess.Peserta_Pengirim_Asal        = "BRINIDJA";
                            exprocess.Sandi_Kota_Asal              = "0391";
                            exprocess.Peserta_Pengirim_Penerus     = "BRINIDJA";
                            exprocess.Peserta_Penerima_Akhir       = bank.BankCode;
                            exprocess.Sandi_Kota_Tujuan            = bank.SandiKota;
                            exprocess.Peserta_Penerima_Penerus     = bank.BankCode;
                            exprocess.Jenis_Nasabah                = "1";
                            exprocess.No_Rekening_Pengirim         = debitAcc;
                            exprocess.Nama_Pengirim                = debitAccName;
                            exprocess.No_Identitas_Pengirim        = "NIKPENGRMCMS";
                            exprocess.Jenis_Nasabah_Pengirim       = "1";
                            exprocess.Status_Kependudukan_Pengirim = "1";
                            exprocess.Alamat_Pengirim              = client.Address1;
                            exprocess.No_Rekening_Tujuan           = creditAcc;
                            exprocess.Nama_Penerima                = creditAccName;
                            exprocess.Jenis_Nasabah_Penerima       = "1";
                            exprocess.Status_Kependudukan_Penerima = "1";
                            exprocess.Alamat_Penerima              = benAddress;
                            exprocess.Cara_Penyetoran              = "DEBET_REK";
                            exprocess.No_Rekening_Asal             = debitAcc;
                            exprocess.Nama                       = debitAccName;
                            exprocess.Jumlah_Dikirim             = _instamount.ToString("0.00");
                            exprocess.Currency_Dikirim           = _instcur;
                            exprocess.Biaya                      = _amt.ToString("0.00");
                            exprocess.Total                      = (double.Parse(_instamount.ToString()) + _amt).ToString("0.00");
                            exprocess.Currency_Total             = _instcur;
                            exprocess.Kanca_Asal                 = "CMS";
                            exprocess.User_Approve               = "0374891";
                            exprocess.Cabang                     = "0374";
                            exprocess.No_Remitance               = o.RemittanceNumber;
                            exprocess.Jurnal_Seq                 = o.IdBooking.ToString();
                            exprocess.Nama_Bank_Penerima         = _benbankname;
                            exprocess.Provinsi_Penerima          = bank.SandiPropinsi;
                            exprocess.Jenis_Badan_Usaha          = bank.JenisUsaha.Trim();
                            exprocess.Kode_Bank_Brinets_Penerima = bank.Code;
                            exprocess.Channel                    = "CMS";
                            exprocess.Booking_Id                 = o.IdBooking.ToString();


                            /*DATA TIDAK MANDATORY*/
                            exprocess.Telepon_Pengirim      = "TELPPNGRMCMS";
                            exprocess.No_Identitas_Penerima = "NIKPENRMMCMS";
                            exprocess.Telepon_Penerima      = "TELPPNRMCMS";
                            exprocess.NoCekBG           = "";
                            exprocess.Berita            = o.TrxRemark;
                            exprocess.Sumber_Dana       = "";
                            exprocess.Keperluan         = "";
                            exprocess.Pekerjaan         = "";
                            exprocess.Jabatan           = "";
                            exprocess.Ttl               = "";
                            exprocess.User_Id           = "";
                            exprocess.Cif               = "";
                            exprocess.Kode_Pos_Pengirim = "";
                            exprocess.Kode_Pos_Penerima = "";
                            exprocess.Remark            = remark;
                            #endregion

                            #region PROCESS
                            log.Info(SchCode + " === (TrxID " + o.Id + ") === DO INSERT TO ExpressProcess");

                            if (MBASEHelper.InsertMBASEExpress(session, o.Id, _fitur, exprocess, out outmsg, out outid))
                            {
                                #region COMPLETE

                                /*Express Process*/
                                exprocess.Status      = ParameterHelper.SCH_MBASE_WAITING; /*1: Waiting*/
                                exprocess.Description = ParameterHelper.MBASEDESC_WAITINGMBASE;
                                exprocess.LastUpdate  = DateTime.Now;
                                session.Update(exprocess);

                                /*Trx Payroll*/
                                o.Status      = ParameterHelper.TRXSTATUS_PAYROLLNEW_CHECK_MBASEANDWS_RTGSANDLLG;
                                o.Description = "proses express".ToUpper();

                                log.Info(SchCode + " === (TrxID " + o.Id + ") === Posting to ExpressProcess SUCCESS");
                                #endregion
                            }
                            else
                            {
                                if (outid > 0)
                                {
                                    #region COMPLETE
                                    /*bila gagal validasi insert, tapi id sudah terbuat, update aja coy */

                                    /*Express Process*/
                                    ExpressProcess ex = session.Load <ExpressProcess>(outid);
                                    ex.Status      = ParameterHelper.SCH_MBASE_WAITING; /*1: Waiting MBASE*/
                                    ex.Description = ParameterHelper.MBASEDESC_WAITINGMBASE;
                                    ex.LastUpdate  = DateTime.Now;
                                    session.Update(ex);

                                    /*Trx Payroll*/
                                    o.Status      = ParameterHelper.TRXSTATUS_PAYROLLNEW_CHECK_MBASEANDWS_RTGSANDLLG;
                                    o.Description = "proses express".ToUpper();

                                    log.Info(SchCode + " === (TrxID " + o.Id + ") === Already Exist, Posting to ExpressProcess SUCCESS");
                                    #endregion
                                }
                                else
                                {
                                    #region REVERSAL PROCESS
                                    /*Gagal Insert to ExpressProcess, do Reversal.*/

                                    /*Booking*/
                                    Booking book = session.Load <Booking>(o.IdBooking);
                                    book.StatusEC = ParameterHelper.SCH_ECWAITING;

                                    /*Trx Payroll*/
                                    o.Status      = ParameterHelper.TRXSTATUS_REJECT;
                                    o.Description = "REJECTED";
                                    o.LastUpdate  = DateTime.Now;

                                    session.Update(book);
                                    session.Flush();

                                    log.Info(SchCode + " ===  (TrxID " + o.Id + " ) Insert to ExpressProcess FAILED: " + outmsg + ". DO Reject & REVERSAL");

                                    #endregion
                                }
                            }

                            session.Update(o);
                            session.Flush();

                            log.Info(SchCode + " === (TrxID " + o.Id + ") === End Posting to ExpressProcess");
                            #endregion

                            #endregion
                        }
                        else
                        {
                            log.Error(SchCode + " === " + SchName + " IntructionCode tidak terdefenisi ");
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        log.Error(SchCode + " === (TrxID " + o.Id + ") === Exception: " + ex.Message + " >>> " + ex.InnerException + " >>> " + ex.StackTrace);
                    }
                }
            }
            else
            {
                Console.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + " - " + SchCode + " === Tidak ada Trx yang diproses");
            }
        }