コード例 #1
0
        public JsonResult ComputeAdminFee(MotoRequestModel moto)
        {
            double adminFee = AdminFeeFormula.GetAdminFeeFromDB(moto, out string serverResponse);

            if (moto.Amount == null)
            {
                moto.Amount = 0;
            }

            if (moto.BCDFee == null)
            {
                moto.BCDFee = 0;
            }

            if (moto.Others == null)
            {
                moto.Others = 0;
            }

            double?total = double.Parse(moto.Amount.ToString()) +
                           double.Parse(moto.BCDFee.ToString()) +
                           double.Parse(moto.Others.ToString()) + adminFee;

            return(Json(new { total = String.Format("{0:0.00}", total), adminFee = String.Format("{0:0.00}", adminFee),
                              error = serverResponse }));
        }
コード例 #2
0
        public static List <MotoRequestModel> GetDuplicate(MotoRequestModel _model, out string message)
        {
            try
            {
                message = "";

                using (var db = new eCardEntities())
                {
                    var qDB = new QuickipediaEntities();

                    var moto = db.MotoRequest.Where(r => r.RecordLocator.ToLower() == _model.RecordLocator.ToLower() &&
                                                    r.PaxName.ToLower() == _model.PaxName.ToLower()).ToList();

                    var motoClientCode = moto.Select(r => r.ClientCode);

                    var quicki = qDB.ClientProfile.Where(r => motoClientCode.Contains(r.ClientCode)).ToList();

                    var join = from m in moto
                               join c in quicki on m.ClientCode equals c.ClientCode
                               join u in db.UserAccount on m.RequestedBy equals u.ID
                               orderby m.Date ascending
                               select new MotoRequestModel
                    {
                        ClientCode      = m.ClientCode,
                        ClientName      = c.ClientName,
                        AdminFee        = m.AdminFee,
                        Amount          = m.Amount,
                        ApprovalCode    = m.ApprovalCode,
                        BCDFee          = m.BCDFee,
                        Company         = m.Company,
                        Currency        = m.Currency,
                        Date            = m.Date,
                        ID              = m.ID,
                        Invoice         = m.Invoice,
                        OptionTime      = m.OptionTime,
                        Others          = m.Others,
                        PaxName         = m.PaxName.ToUpper(),
                        RecordLocator   = m.RecordLocator,
                        Remarks         = m.Remarks,
                        Status          = m.Status,
                        Total           = m.Total,
                        RequestedBy     = m.RequestedBy,
                        ShowRequestedBy = u.FirstName + " " + u.LastName,
                        DeclinedReason  = m.DeclinedReason,
                        ApprovedDate    = m.ApprovedDate,
                        LogID           = m.LogID
                    };

                    return(join.ToList());
                }
            }
            catch (Exception error)
            {
                message = error.Message;

                return(null);
            }
        }
コード例 #3
0
        public JsonResult GetDuplicate(MotoRequestModel moto)
        {
            string serverResponse = "";

            if (moto != null)
            {
                var duplicate = ECardService.GetDuplicate(moto, out serverResponse);

                return(Json(new { error = serverResponse, duplicate }));
            }

            return(Json(serverResponse));
        }
コード例 #4
0
        public JsonResult SaveMoto(MotoRequestModel moto)
        {
            string serverResponse = "";

            if (moto != null)
            {
                if (moto.Status == "F" && UniversalService.CurrentUser.Type == "APR")
                {
                    moto.Status = "V";
                }

                ECardService.SaveMotoRequest(moto, out serverResponse);
            }

            return(Json(serverResponse));
        }
コード例 #5
0
        public static double GetAdminFeeFromDB(MotoRequestModel _moto, out string message)
        {
            try
            {
                message = "";

                double _airFare, _serviceFee, _others;

                if (_moto.Amount == null)
                {
                    _airFare = 0;
                }
                else
                {
                    _airFare = double.Parse(_moto.Amount.ToString());
                }

                if (_moto.BCDFee == null)
                {
                    _serviceFee = 0;
                }
                else
                {
                    _serviceFee = double.Parse(_moto.BCDFee.ToString());
                }

                if (_moto.Others == null)
                {
                    _others = 0;
                }
                else
                {
                    _others = double.Parse(_moto.Others.ToString());
                }

                if (_moto.Currency == "" || _moto.Currency == null)
                {
                    message = "Currency is required to auto compute admin fee";

                    return(0);
                }

                using (var db = new QuickipediaEntities())
                {
                    var admFormula = db.EcardAdminFee.FirstOrDefault(r => r.ClientCode == _moto.ClientCode);

                    if (admFormula != null)
                    {
                        double total = 0;

                        if (_moto.Currency == "PHP")
                        {
                            if (admFormula.AirFareFlag)
                            {
                                total += _airFare;
                            }

                            if (admFormula.ServiceFeeFlag)
                            {
                                total += _serviceFee;
                            }

                            if (admFormula.OtherFeeFlag)
                            {
                                total += _others;
                            }

                            if (admFormula.Divide > 0)
                            {
                                total = total / double.Parse(admFormula.Divide.ToString());
                            }

                            if (admFormula.Multiply > 0)
                            {
                                total = total * double.Parse(admFormula.Multiply.ToString());
                            }
                        }
                        else
                        {
                            if (admFormula.AirFareUSD)
                            {
                                total += _airFare;
                            }

                            if (admFormula.ServiceFeeUSD)
                            {
                                total += _serviceFee;
                            }

                            if (admFormula.OthersUSD)
                            {
                                total += _others;
                            }

                            if (admFormula.DivideUSD > 0)
                            {
                                total = total / double.Parse(admFormula.DivideUSD.ToString());
                            }

                            if (admFormula.MultiplyUSD > 0)
                            {
                                total = total * double.Parse(admFormula.MultiplyUSD.ToString());
                            }
                        }

                        return(total);
                    }
                    else
                    {
                        message = "Admin Fee Profile not Found (You need to compute admin fee manually)";

                        return(0);
                    }
                }
            }
            catch (Exception error)
            {
                message = error.Message;

                return(0);
            }
        }
コード例 #6
0
        public static void SaveMotoRequest(MotoRequestModel _request, out string message)
        {
            try
            {
                message = "";

                using (var db = new eCardEntities())
                {
                    if (_request.ID == Guid.Empty) //NEW
                    {
                        MotoRequest newMoto = new MotoRequest
                        {
                            ID             = Guid.NewGuid(),
                            Date           = DateTime.Now,
                            RequestedBy    = UniversalService.CurrentUser.ID,
                            ClientCode     = _request.ClientCode,
                            Company        = _request.Company,
                            PaxName        = _request.PaxName.ToUpper(),
                            RecordLocator  = _request.RecordLocator.ToUpper(),
                            Currency       = _request.Currency,
                            Amount         = _request.Amount,
                            Others         = _request.Others,
                            BCDFee         = _request.BCDFee,
                            AdminFee       = _request.AdminFee,
                            Total          = _request.Amount + _request.BCDFee + _request.Others + _request.AdminFee,
                            OptionTime     = _request.OptionTime,
                            ApprovalCode   = _request.ApprovalCode,
                            Remarks        = _request.Remarks,
                            Invoice        = _request.Invoice,
                            Status         = _request.Status,
                            DeclinedReason = _request.DeclinedReason,
                            ApprovedBy     = Guid.Empty
                        };

                        db.Entry(newMoto).State = EntityState.Added;

                        db.SaveChanges();
                    }
                    else
                    {
                        var moto = db.MotoRequest.FirstOrDefault(r => r.ID == _request.ID);

                        if (moto != null)
                        {
                            moto.ClientCode = _request.ClientCode;

                            moto.Company = _request.Company;

                            moto.PaxName = _request.PaxName.ToUpper();

                            moto.RecordLocator = _request.RecordLocator.ToUpper();

                            moto.Currency = _request.Currency;

                            moto.AdminFee = _request.AdminFee;

                            moto.Total = _request.Amount + _request.Others + _request.BCDFee + _request.AdminFee;

                            moto.OptionTime = _request.OptionTime;

                            moto.ApprovalCode = _request.ApprovalCode;

                            moto.Remarks = _request.Remarks;

                            moto.Invoice = _request.Invoice;

                            moto.Status = _request.Status;

                            moto.DeclinedReason = _request.DeclinedReason;

                            moto.ApprovedDate = DateTime.Now;

                            moto.ApprovedBy = UniversalService.CurrentUser.ID;

                            db.Entry(moto).State = EntityState.Modified;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception error)
            {
                message = error.Message;
            }
        }