protected override IPayment CreateConcretePayment() { IPayment product = new CashPayment(); // Here is the place for some additional object creation logic. return(product); }
public async Task <ActionResult <CashPayment> > PostCashPayment(CashPayment cashPayment) { _context.CashPayments.Add(cashPayment); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCashPayment", new { id = cashPayment.CashPaymentId }, cashPayment)); }
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()); }
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)); }
//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)); //} }
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();; }
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(); }
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)); }
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)); //} }
public ActionResult DeleteConfirmed(int id) { CashPayment cashPayment = db.CashPayments.Find(id); db.CashPayments.Remove(cashPayment); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <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; }
public void PaymentTypeIsCash() { PaymentType expectedPaymentType = PaymentType.Cash; var cashPayment = new CashPayment(); Assert.AreEqual(expectedPaymentType, cashPayment.PaymentType, "Incorrect PaymentType returned."); }
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); }
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)); }
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; } }
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)); }
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)); }
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("*****@*****.**")); }
// 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)); }
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(); } } }
/// <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(); }
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)); }
// 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)); }
// 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)); }
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); }
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); }
// 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)); }
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); }
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 }); }