예제 #1
0
        protected override IPayment CreateConcretePayment()
        {
            IPayment product = new CashPayment();

            // Here is the place for some additional object creation logic.
            return(product);
        }
예제 #2
0
        public async Task <ActionResult <CashPayment> > PostCashPayment(CashPayment cashPayment)
        {
            _context.CashPayments.Add(cashPayment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCashPayment", new { id = cashPayment.CashPaymentId }, cashPayment));
        }
예제 #3
0
        public async Task <IActionResult> PutCashPayment(int id, CashPayment cashPayment)
        {
            if (id != cashPayment.CashPaymentId)
            {
                return(BadRequest());
            }

            _context.Entry(cashPayment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CashPaymentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("CashPaymentId,PaymentDate,TranscationModeId,PaidTo,Amount,SlipNo,Remarks,StoreId,UserId,EntryStatus,IsReadOnly")] CashPayment cashPayment)
        {
            if (id != cashPayment.CashPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cashPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CashPaymentExists(cashPayment.CashPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TranscationModeId"] = new SelectList(_context.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
            //ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreId", cashPayment.StoreId);
            return(View(cashPayment));
        }
예제 #5
0
    //public string InvoiceBalance(long customerID)
    //{
    //    return "";


    //}

    public static string CashPayment(long customer_id)
    {
        //get
        //{

        List <CashPayment> cashPayment = new List <global::CashPayment>();


        Database = new DatabaseDataContext();
        var data = Database._InvoiceOfficialReceipts.Where(x => x.CustomerID == customer_id);

        foreach (var or in data)
        {
            var cash = Database._InvoicePaymentCashes.Where(x => x.OfficialReceiptID == or.ID);

            foreach (var c in cash)
            {
                CashPayment _cash = new CashPayment();

                _cash.ID          = c.ID;
                _cash.RefNo       = or.RefNo + or.ID.ToString();
                _cash.CreatedDate = or.CreatedDate.Value;
                _cash.ORAmount    = or.TotalAmount.Value;
                _cash.CashAmount  = c.Amount.Value;

                cashPayment.Add(_cash);
            }
        }



        return(JsonConvert.SerializeObject(cashPayment, Newtonsoft.Json.Formatting.None));
        //}
    }
예제 #6
0
        private async System.Threading.Tasks.Task AddCashPaymentsAsync()
        {
            var ws = xS.GetWS("CashPayments");
            var nonEmptyDataRows = ws.RowsUsed();
            int Row = 6;//Title;

            //           CashPaymentId PaymentDate TranscationModeId Mode    PaidTo Amount  SlipNo StoreId UserName


            foreach (var dR in nonEmptyDataRows)
            {
                if (dR.RowNumber() > Row)
                {
                    CashPayment exp = new CashPayment
                    {
                        PaymentDate       = dR.Cell(2).GetDateTime(),
                        TranscationModeId = dR.Cell(3).GetValue <int>(),
                        PaidTo            = dR.Cell(5).Value.ToString(),
                        Amount            = dR.Cell(6).GetValue <decimal>(),
                        SlipNo            = dR.Cell(7).Value.ToString(),
                        Remarks           = "Imported",
                        StoreId           = dR.Cell(8).GetValue <int>(),
                        UserId            = dR.Cell(9).Value.ToString(),
                        EntryStatus       = 0,
                        IsReadOnly        = true,
                    };
                    db.CashPayments.Add(exp);
                }
            }
            await db.SaveChangesAsync();;
        }
예제 #7
0
        private async System.Threading.Tasks.Task AddPettyCashPaymentsAsync()
        {
            var ws = xS.GetWS("PettyCashExpenses");
            var nonEmptyDataRows = ws.RowsUsed();
            int Row = 6;//Title;

            //            PettyCashExpenseId ExpDate Particulars Amount  EmployeeId PaidTo  Remarks StoreId UserName

            Console.WriteLine(JsonConvert.SerializeObject(db.TranscationModes));
            foreach (var dR in nonEmptyDataRows)
            {
                if (dR.RowNumber() > Row)
                {
                    CashPayment exp = new CashPayment
                    {
                        PaymentDate       = dR.Cell(2).GetDateTime(),
                        Remarks           = "#Pat: " + dR.Cell(3).Value.ToString() + "#RM: " + dR.Cell(7).Value.ToString(),
                        Amount            = dR.Cell(4).GetValue <decimal>(),
                        PaidTo            = dR.Cell(6).Value.ToString(),
                        StoreId           = dR.Cell(8).GetValue <int>(),
                        UserId            = dR.Cell(9).Value.ToString(),
                        EntryStatus       = 0,
                        IsReadOnly        = true, SlipNo = "CashPayment_Imported",
                        TranscationModeId = 9
                    };
                    exp.TranscationModeId = GetTranscationMode(dR.Cell(3).Value.ToString());
                    db.CashPayments.Add(exp);
                }
            }
            await db.SaveChangesAsync();
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "Payment, Number, ReceiptNumber, ReceiptDate, FeeAmount")] CashPayment cashPayment)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    CashPaymentServices.Insert(CurrentUser.Id, cashPayment, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.PaymentList = new SelectList(PaymentServices.List(db), "Id", "Notes");
            return(View(cashPayment));
        }
예제 #9
0
    public static string CashPayment(long supplier_id)
    {
        //get
        //{

        List <CashPayment> cashPayment = new List <global::CashPayment>();


        Database = new DatabaseDataContext();
        var data = Database._PurchaseVoucherSelect(0, supplier_id);

        foreach (var or in data)
        {
            var cash = Database._PurchasedPaymentCashes.Where(x => x.PurchasedVoucherID == or.ID);

            foreach (var c in cash)
            {
                CashPayment _cash = new CashPayment();

                _cash.ID          = c.ID;
                _cash.RefNo       = or.RefNo;
                _cash.CreatedDate = or.CreatedDate.Value;
                _cash.ORAmount    = or.TotalAmount.Value;
                _cash.CashAmount  = c.Amount.Value;

                cashPayment.Add(_cash);
            }
        }



        return(JsonConvert.SerializeObject(cashPayment, Newtonsoft.Json.Formatting.None));
        //}
    }
예제 #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            CashPayment cashPayment = db.CashPayments.Find(id);

            db.CashPayments.Remove(cashPayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #11
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="cashPayment">Оплата</param>
 public PaymentRow(CashPayment cashPayment)
 {
     this.Guid        = cashPayment.Guid;
     this.PaymentDate = cashPayment.PaymentDate;
     this.Type        = ControllerResources.OrderPayControl_CashPaymentType;
     this.Amount      = cashPayment.Amount;
     this.IsManual    = cashPayment.Manual;
 }
예제 #12
0
        public void PaymentTypeIsCash()
        {
            PaymentType expectedPaymentType = PaymentType.Cash;

            var cashPayment = new CashPayment();

            Assert.AreEqual(expectedPaymentType, cashPayment.PaymentType,
                            "Incorrect PaymentType returned.");
        }
예제 #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            CashPayment cashPayment = db.CashPayments.Find(id);

            Utils.UpDateCashOutHand(db, cashPayment.PaymentDate, 0 - cashPayment.Amount);
            db.CashPayments.Remove(cashPayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void OnUpdate(AprajitaRetailsContext db, CashPayment payment)
        {
            var oldPay = db.CashPayments.Where(c => c.CashPaymentId == payment.CashPaymentId).Select(d => new { d.Amount, d.PaymentDate }).FirstOrDefault();

            if (oldPay != null)
            {
                CashTrigger.UpDateCashOutHand(db, oldPay.PaymentDate, 0 - oldPay.Amount);
            }
            CashTrigger.UpDateCashOutHand(db, payment.PaymentDate, payment.Amount);
        }
예제 #15
0
 public ActionResult Edit([Bind(Include = "CashPaymentId,PaymentDate,TranscationModeId,PaidTo,Amount,SlipNo")] CashPayment cashPayment)
 {
     if (ModelState.IsValid)
     {
         //TODO: Edit in cash balance need to update Utils.UpDateCashOutHand(db, cashPayment.PaymentDate, cashPayment.Amount);
         db.Entry(cashPayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TranscationModeId = new SelectList(db.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
     return(View(cashPayment));
 }
예제 #16
0
    public void OnDrop(PointerEventData eventData)
    {
        GameObject  payment     = eventData.pointerDrag;
        CashPayment CashPayment = payment.GetComponent <CashPayment>();

        if (CashPayment && CashCompartment.activeSelf)
        {
            change -= CashPayment.getAmount();
            payment.SetActive(false);
            UpdateRegisterDisplay(change);
            scannedPaymentCount += 1;
        }
    }
예제 #17
0
        public async Task <IActionResult> Create([Bind("CashPaymentId,PaymentDate,TranscationModeId,PaidTo,Amount,SlipNo")] CashPayment cashPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cashPayment);
                await _context.SaveChangesAsync();

                new ExpenseManager().OnInsert(_context, cashPayment);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TranscationModeId"] = new SelectList(_context.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
            return(PartialView(cashPayment));
        }
예제 #18
0
        public ActionResult Create([Bind(Include = "CashPaymentId,PaymentDate,TranscationModeId,PaidTo,Amount,SlipNo")] CashPayment cashPayment)
        {
            if (ModelState.IsValid)
            {
                db.CashPayments.Add(cashPayment);
                Utils.UpDateCashOutHand(db, cashPayment.PaymentDate, cashPayment.Amount);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TranscationModeId = new SelectList(db.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
            return(View(cashPayment));
        }
예제 #19
0
        public static void Main(string[] args)
        {
            IPaymentStrategy <Cash> cashPayment = new CashPayment();

            cashPayment.Pay(new Cash());

            IPaymentStrategy <CreditCard> creditCardPayment = new CreditCardPayment();

            creditCardPayment.Pay(new CreditCard(CardType.Visa, "4539867398424592"));

            IPaymentStrategy <Paypal> payPalPayment = new PayPalPayment();

            payPalPayment.Pay(new Paypal("*****@*****.**"));
        }
예제 #20
0
        // GET: CashPayments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CashPayment cashPayment = db.CashPayments.Find(id);

            if (cashPayment == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(cashPayment));
        }
예제 #21
0
        private void OpenCashDialog()
        {
            CashPayment cp = Dialogs.GetCashPayment(double.Parse(LeftToPay.ToString()));

            if (cp != null)
            {
                PartialPayments.Add(cp);
                CurrentOrder.Payments = new HashSet <Payment>(PartialPayments);
                LeftToPay            -= cp.TotalPayed;
                if (LeftToPay <= 0)
                {
                    CloseOrder();
                }
            }
        }
예제 #22
0
        /// <summary>
        /// Implement PayByCash method
        /// </summary>
        public void PayByCash()
        {
            decimal       balance     = sale.getBalance();
            decimal       amountEnter = Amount;
            decimal       amount      = (amountEnter > balance ? balance : amountEnter);
            PaymentMethod payment     = new CashPayment(amount);

            if (amountEnter > balance)
            {
                decimal change = amountEnter - balance;
                MessageBox.Show("Your change is " + change.ToString("C"));
            }
            sale.processPayment(payment);
            UpdatePaymentMethodView();
        }
예제 #23
0
        public async Task <IActionResult> Create([Bind("CashPaymentId,PaymentDate,TranscationModeId,PaidTo,Amount,SlipNo,Remarks,StoreId,UserId,EntryStatus,IsReadOnly")] CashPayment cashPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cashPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TranscationModeId"] = new SelectList(_context.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
            //ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreId", cashPayment.StoreId);
            ViewData["StoreId"] = ActiveSession.GetActiveSession(HttpContext.Session, HttpContext.Response, _returnUrl);

            return(View(cashPayment));
        }
예제 #24
0
        // GET: CashPayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CashPayment cashPayment = db.CashPayments.Find(id);

            if (cashPayment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TranscationModeId = new SelectList(db.TranscationModes, "TranscationModeId", "Transcation", cashPayment.TranscationModeId);
            return(View(cashPayment));
        }
예제 #25
0
        // GET: CashPayment/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db          db          = new Db(DbServices.ConnectionString);
            CashPayment cashPayment = CashPaymentServices.Get(id.Value, db);

            if (cashPayment == null)
            {
                return(HttpNotFound());
            }
            return(View(cashPayment));
        }
예제 #26
0
        public void CashCardPaymentHandler()
        {
            //init
            var dalMock     = new Mock <IPaymentAccessLayer>();
            var cashPayment = new CashPayment(2.5m);

            //act
            new CashPaymentHandler(dalMock.Object).Handle(cashPayment);

            //assert
            dalMock.Verify(layer =>
                           layer.AddCashPayment(It.Is <decimal>(item => item == 2.5m)), Times.Once);

            dalMock.Verify(layer =>
                           layer.AddCreditPayment(It.Is <decimal>(item => item == 2.5m)), Times.Never);
        }
예제 #27
0
        public virtual IPayment CreatePaymentMethod(PaymentsMethod method)
        {
            IPayment payment = null;

            switch (method)
            {
            case PaymentsMethod.Card:
                payment = new CardPayment();
                break;

            case PaymentsMethod.Cash:
                payment = new CashPayment();
                break;
            }

            return(payment);
        }
        public void TestInit()
        {
            IList <CashMoney> money = new List <CashMoney>()
            {
                new CashMoney()
                {
                    Id = 1, MoneyValue = 10, Quantity = 10
                },
                new CashMoney()
                {
                    Id = 2, MoneyValue = 5, Quantity = 10
                },
                new CashMoney()
                {
                    Id = 3, MoneyValue = 1, Quantity = 10
                },
                new CashMoney()
                {
                    Id = 4, MoneyValue = 0.5, Quantity = 10
                }
            };

            MockCashMoneyRepository = new Mock <ICashMoneyRepositoryExtended>();
            CashMoneyRepositoryMoq.GetMoney(MockCashMoneyRepository, money);
            CashMoneyRepositoryMoq.UpdateMoney(MockCashMoneyRepository, money);
            CashMoneyRepositoryMoq.GiveChange(MockCashMoneyRepository, money);

            IList <CashMoney> introducedMoney = new List <CashMoney>()
            {
                new CashMoney()
                {
                    Id = 2, MoneyValue = 5, Quantity = 1
                },
                new CashMoney()
                {
                    Id = 3, MoneyValue = 1, Quantity = 4
                },
                new CashMoney()
                {
                    Id = 4, MoneyValue = 0.5, Quantity = 1
                }
            };
            double total = 9.5;

            cashPayment = new CashPayment(MockCashMoneyRepository.Object, introducedMoney, total);
        }
예제 #29
0
        // GET: CashPayment/Edit/5
        public ActionResult Edit(Nullable <int> payment)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (payment == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CashPayment cashPayment = CashPaymentServices.Get(payment.Value, db);

            if (cashPayment == null)
            {
                return(HttpNotFound());
            }

            ViewBag.PaymentList = new SelectList(PaymentServices.List(db), "Id", "Notes", cashPayment.Payment);
            return(View(cashPayment));
        }
예제 #30
0
        public Task Process(string method, decimal amount)
        {
            var tEvent = new PaymentCreatedEvent();

            switch (method)
            {
            case "Cash":
                BasePayment cashPayment = new CashPayment();
                cashPayment.Execute(tEvent);
                break;

            case "Credit":
                BasePayment creditPayment = new CreditPayment();
                creditPayment.Execute(tEvent);
                break;
            }
            return(Task.CompletedTask);
        }
예제 #31
0
        /// <summary>
        /// Implement PayByCash method
        /// </summary>
        public void PayByCash()
        {
            decimal balance = sale.getBalance();
            decimal amountEnter = Amount;
            decimal amount = (amountEnter > balance ? balance : amountEnter);
            PaymentMethod payment = new CashPayment(amount);

            if (amountEnter > balance)
            {
                decimal change = amountEnter - balance;
                MessageBox.Show("Your change is " + change.ToString("C"));
            }
            sale.processPayment(payment);
            UpdatePaymentMethodView();
        }
예제 #32
0
        public ActionResult SaveNewOrder(string instructions, bool isPayment = false, int paymentDomainID = 0, CreditCardModel creditCardInfo = null,
            bool isCustomPrice = false, string customPrice = "", int? addressID = null, CashPayment cashPayment = CashPayment.Cash)
        {
            if (SessionManager.AdminBasket == null)
                return Json(new { success = false, error = "System cannot find your basket." });

            if (!ECommerceService.IsEnoughOnStock(SessionManager.AdminBasket.tbl_BasketContent))
                return Json(new { success = false, error = "Quantity of order items exceeds current stock ammount." });

            SessionManager.AdminBasket = ECommerceService.UpdateBasketDeliveryNotes(instructions, SessionManager.AdminBasket.BasketID);

            tbl_Orders order = ECommerceService.SaveOrder(0, null, isPayment ? (int?)null : (int)cashPayment, SessionManager.AdminBasket.BasketID, AdminUser.UserID, addressID.GetValueOrDefault(0));

            if (order == null)
                return Json(new { success = false, error = "There was a problem saving new order." });

            if (isCustomPrice)
            {
                decimal price = 0;
                bool parsed = Decimal.TryParse(customPrice.ChangeDecimalSeparator(), out price);
                if (parsed)
                    ECommerceService.SaveCustomTotalAmount(price, order.OrderID);
            }

            if (isPayment)
            {
                var selectedPaymentType = ECommerceService.GetPaymentDomainByID(paymentDomainID);
                if (selectedPaymentType == null)
                {
                    return Json(new { success = false, error = "Please select payment type." });
                }

                var isDirect = DomainService.GetSettingsValue(SettingsKey.sagePayMethod, SessionManager.AdminBasket.B_DomainID) == SagePayPaymentType.Direct.ToString();
                PaymentType key = (PaymentType)Enum.Parse(typeof(PaymentType), selectedPaymentType.tbl_PaymentType.PT_Code);
                switch (key)
                {
                    case PaymentType.SagePay:
                        if (isDirect)
                        {
                            if (creditCardInfo == null)
                                return Json(new { success = false, error = "Please fill in credit card information." });

                            SessionManager.CreditCard = creditCardInfo;
                        }

                        return Json(new { success = true, url = Url.RouteUrl("SagePay", new { action = "Payment", orderID = order.OrderID }) });

                    case PaymentType.PayPal:
                        return Json(new { success = true, url = Url.RouteUrl("PayPal", new { action = "Payment", orderID = order.OrderID }) });

                    case PaymentType.SecureTrading:

                        return Json(new { success = true, url = Url.RouteUrl("SecureTrading", new { action = "Payment", orderID = order.OrderID }) });
                }
            }
            else
            {
                order = ECommerceService.UpdateOrderPaymentStatus(order.OrderID, PaymentStatus.Paid);
                var domain = DomainService.GetDomainByID(SessionManager.AdminBasket.B_DomainID);
                MailingService.SendOrderConfirmationAdmin(order, domain != null ? domain.DO_Email : String.Empty);
                MailingService.SendOrderConfirmation(order);
            }

            if (order == null)
                return Json(new { success = false, error = "There was a problem updating payment status for order." });

            return Json(new { success = true });
        }