public POSTransactionsUI() { InitializeComponent(); loPOSTransaction = new POSTransaction(); loPOSTransactionDetail = new POSTransactionDetail(); loOrderSlipRpt = new OrderSlipRpt(); }
public List <POSTransactionItemViewModel> GetPOSTransactionItems(HttpContextBase httpContext) { POSTransaction posTransaction = GetPOSTransaction(httpContext, false); if (posTransaction != null) { var result = (from b in posTransaction.POSTransactionItems join p in productContext.Collection() on b.ProductId equals p.Id orderby b.ModifiedAt descending select new POSTransactionItemViewModel() { Id = b.Id, Quantity = b.Quantity, ModifiedAt = b.ModifiedAt, ProductId = b.ProductId, ProductName = p.Name, ProductDescription = p.Description, UPC = p.UPC, ProductCode = p.ProductCode, Image = p.Image, Price = p.Price }).ToList(); return(result); } else { return(new List <POSTransactionItemViewModel>()); } }
private POSTransaction GetPOSTransaction(HttpContextBase httpContext, bool createIfNull) { HttpCookie cookie = httpContext.Request.Cookies.Get(POSTransactionSessionName); POSTransaction posTransaction = new POSTransaction(); if (cookie != null) { string POSTransactionId = cookie.Value; if (!string.IsNullOrEmpty(POSTransactionId)) { posTransaction = POSTransactionContext.Find(POSTransactionId); } else { if (createIfNull) { posTransaction = CreateNewPOSTransaction(httpContext); } } } else { if (createIfNull) { posTransaction = CreateNewPOSTransaction(httpContext); } } return(posTransaction); }
public void ClearPOSTransaction(HttpContextBase httpContext) { POSTransaction posTransaction = GetPOSTransaction(httpContext, false); posTransaction.POSTransactionItems.Clear(); POSTransactionContext.Commit(); }
public POSTransactionSummaryViewModel GetPOSTransactionSummary(HttpContextBase httpContext) { POSTransaction posTransaction = GetPOSTransaction(httpContext, false); POSTransactionSummaryViewModel model = new POSTransactionSummaryViewModel(0, 0); if (posTransaction != null) { int?transactionCount = (from item in posTransaction.POSTransactionItems select item.Quantity).Sum(); decimal?transactionTotal = (from pi in posTransaction.POSTransactionItems join p in productContext.Collection() on pi.ProductId equals p.Id select pi.Quantity *p.Price).Sum(); model.TransactionCount = transactionCount ?? 0; model.TransactionTotal = transactionTotal ?? decimal.Zero; foreach (var item in posTransaction.POSTransactionItems) { POSSaleItem possaleItem = new POSSaleItem() { ProductId = item.ProductId, ProductName = item.ProductName, ProductDescription = item.ProductDescription, Image = item.Image, Price = item.Price, Quantity = item.Quantity }; model.POSSaleItems.Add(possaleItem); } } return(model); }
public CloseCashierPeriodUI() { InitializeComponent(); loCashierPeriod = new CashierPeriod(); loCashier = new Cashier(); loPOSTransaction = new POSTransaction(); loCashierPeriodSummaryRpt = new CashierPeriodSummaryRpt(); loCloseCashierPeriodRpt = new CloseCashierPeriodRpt(); loReportViewer = new ReportViewerUI(); }
public void AddQRCodeBasedPOSTransaction(string jsonTx, string jsonPosTx) { QRCodeTransferTransaction transaction = QRCodeTransferTransaction.FromJsonString(jsonTx); POSTransaction posDetail = POSTransaction.FromJsonString(jsonPosTx); if (transaction.Amount == 0) { throw new ValidationException("Invalid Amount"); } }
private POSTransaction CreateNewPOSTransaction(HttpContextBase httpContext) { POSTransaction posTransaction = new POSTransaction(); POSTransactionContext.Insert(posTransaction); POSTransactionContext.Commit(); HttpCookie cookie = new HttpCookie(POSTransactionSessionName); cookie.Value = posTransaction.Id; cookie.Expires = DateTime.Now.AddDays(1); httpContext.Response.Cookies.Add(cookie); return(posTransaction); }
public RenderUI() { InitializeComponent(); loPOSTransaction = new POSTransaction(); loPOSTransactionDetail = new POSTransactionDetail(); loCustomer = new Customer(); loInventory = new Inventory(); loInventoryDetail = new InventoryDetail(); loSystemConfiguration = new SystemConfiguration(); lFromClose = false; //loORPrePrintedRpt = new ORPrePrintedRpt(); //loORReceiptPrinter80mmRpt = new ORReceiptPrinter80mmRpt(); loOrderSlipRpt = new OrderSlipRpt(); loReportViewer = new ReportViewerUI(); }
public void RemoveFromPOSTransaction(HttpContextBase httpContext, string itemId) { POSTransaction posTransaction = GetPOSTransaction(httpContext, true); POSTransactionItem item = posTransaction.POSTransactionItems.FirstOrDefault(p => p.Id == itemId); if (item != null) { if (item.Quantity > 1) { --item.Quantity; POSTransactionContext.Commit(); } else { posTransaction.POSTransactionItems.Remove(item); POSTransactionContext.Commit(); } } }
private async Task CallPosTransactWebService(string fromAccountNumber, string toAccountNumber, string cardSerialNumberFrom, string cardSerialNumberTo, long?amount, TransactionType transactionType, TLV emvData) { Device.BeginInvokeOnMainThread(() => { gridProgress.IsVisible = true; }); try { Proxies.DCEMVDemoServerClient client = SessionSingleton.GenDCEMVServerApiClient(); using (SessionSingleton.HttpClient) { POSTransaction posTx = new POSTransaction(); posTx.InvItems = ConvertLineItems(basketItems.ToList()); CardTransferTransaction tx = new CardTransferTransaction() { Amount = amount.Value, AccountFrom = fromAccountNumber, AccountTo = toAccountNumber, CardSerialFrom = cardSerialNumberFrom, CardSerialTo = cardSerialNumberTo, CardFromEMVData = TLVasJSON.ToJSON(emvData), }; await client.StoreSalebycardPostAsync(tx.ToJsonString(), posTx.ToJsonString()); } } catch (Exception ex) { throw ex; } finally { Device.BeginInvokeOnMainThread(() => { gridProgress.IsVisible = false; }); } }
private async Task CallPosTransactWebService(string fromAccountNumber, string toAccountNumber, string cardSerialNumberFrom, string cardSerialNumberTo, int?amount, TransactionType transactionType, String emvData) { Device.BeginInvokeOnMainThread(() => { gridProgress.IsVisible = true; }); try { XServerApiClient client = SessionSingleton.GenXServerApiClient(); using (SessionSingleton.HttpClient) { POSTransaction posTx = new POSTransaction(); posTx.InvItems = posTransactionItems; Transaction tx = new Transaction() { Amount = Validate.AmountToCents(totalAmount.Total), AccountFrom = fromAccountNumber, AccountTo = toAccountNumber, CardSerialFrom = cardSerialNumberFrom, CardSerialTo = cardSerialNumberTo, CardFromEMVData = emvData, }; await client.StoreSalePostAsync(tx.ToJsonString(), posTx.ToJsonString()); } } catch (Exception ex) { throw ex; } finally { Device.BeginInvokeOnMainThread(() => { gridProgress.IsVisible = false; }); } }
public void AddToPOSTransaction(HttpContextBase httpContext, string productId) { IProductRetrieveService productDataService = new ProductRetrieveService(); Product product = productDataService.GetProduct(productId); if (product == null) { throw new Exception("Product not found."); } POSTransaction posTransaction = GetPOSTransaction(httpContext, true); POSTransactionItem item = posTransaction.POSTransactionItems.FirstOrDefault(t => t.ProductId == productId); if (item == null) { item = new POSTransactionItem() { POSTransactionId = posTransaction.Id, ProductId = productId, ProductName = product.Name, ProductDescription = product.Description, Quantity = 1, Price = product.Price, ModifiedAt = DateTime.Now }; posTransaction.POSTransactionItems.Add(item); } else { ++item.Quantity; item.ModifiedAt = DateTime.Now; } POSTransactionContext.Commit(); }
public string insertPOSTransaction([FromBody] POSTransaction pPOSTransaction) { return(loPOSTransaction.insertPOSTransaction(pPOSTransaction)); }
public Account GetAccountTransactions() { AccountPM account = accountsRepository.GetTransactionsForUser(GetCurrentUserId()); Account accountDetails = new Account() { AccountNumberId = account.AccountNumberId, AccountState = account.AccountState, CustomerType = account.CustomerType, FirstName = account.FirstName, LastName = account.LastName, BusinessName = account.BusinessName, CompanyRegNumber = account.CompanyRegNumber, TaxNumber = account.TaxNumber, Balance = account.Balance, }; account.TransactionsFrom.ForEach(x => { CardTransferTransaction tx = new CardTransferTransaction() { AccountFrom = x.AccountNumberIdFromRef, //AccountTo = x.AccountNumberIdToRef, Amount = x.Amount, TransactionType = x.TransactionType, DateTime = x.TransactionDateTime, TransactionId = x.TransactionId, }; accountDetails.TransferFromTransactions.Add(tx); }); account.TransactionsTo.ForEach(x => { CardTransferTransaction tx = new CardTransferTransaction() { //AccountFrom = x.AccountNumberIdFromRef, AccountTo = x.AccountNumberIdToRef, Amount = x.Amount, TransactionType = x.TransactionType, DateTime = x.TransactionDateTime, TransactionId = x.TransactionId, }; accountDetails.TransferToTransactions.Add(tx); }); account.POSTransactionsTo.ForEach(x => { POSTransaction tx = new POSTransaction() { AccountNumberId = x.AccountNumberIdToRef, TransactionDateTime = x.TransactionDateTime, TransactionId = x.TransactionIdRef, POSTransactionId = x.POSTransactionId, }; accountDetails.POSTransactions.Add(tx); }); account.CCTopUpTransactions.ForEach(x => { CCTopUpTransaction tx = new CCTopUpTransaction() { AccountNumberId = x.AccountNumberIdToRef, Amount = x.Amount, DateTime = x.TransactionDateTime, }; accountDetails.TopUpTransactions.Add(tx); }); return(accountDetails); }
public void AddCardBasedPOSTransaction(string jsonTx, string jsonPosTx) { CardTransferTransaction transaction = CardTransferTransaction.FromJsonString(jsonTx); POSTransaction posDetail = POSTransaction.FromJsonString(jsonPosTx); if (transaction.Amount == 0) { throw new ValidationException("Invalid Amount"); } //TODO: make sure data in EMV matches duplicate data fields in transaction TLV tlv = TLVasJSON.FromJSON(transaction.CardFromEMVData); TLV _9F02 = tlv.Children.Get(EMVTagsEnum.AMOUNT_AUTHORISED_NUMERIC_9F02_KRN.Tag); long emvAmount = FormattingUtils.Formatting.BcdToLong(_9F02.Value); if (transaction.Amount != emvAmount) { throw new ValidationException("Invalid Amount: Card does not match Cryptogram"); } if (TransactionController.VerifyCardSignature(tlv) == null) { throw new ValidationException("Invalid Cryptogram"); } transaction.TransactionType = TransactionType.SendMoneyFromCardToApp; switch (transaction.TransactionType) { case TransactionType.SendMoneyFromCardToApp: if (!String.IsNullOrEmpty(transaction.AccountFrom)) { throw new ValidationException("Invalid AccountNumberFrom"); } if (!String.IsNullOrEmpty(transaction.CardSerialTo)) { throw new ValidationException("Invalid CardSerialNumberTo"); } if (!Validate.GuidValidation(transaction.AccountTo)) { throw new ValidationException("Invalid AccountNumberTo"); } if (String.IsNullOrEmpty(transaction.CardSerialFrom)) { throw new ValidationException("Invalid CardSerialNumberFrom"); } break; default: throw new ValidationException("Invalid transaction type: " + transaction.TransactionType); } if (posDetail.InvItems == null || posDetail.InvItems.Count == 0) { throw new ValidationException("Invalid items"); } TransactionPM txpm = new TransactionPM() { TransactionType = transaction.TransactionType, AccountNumberIdFromRef = transaction.AccountFrom, AccountNumberIdToRef = transaction.AccountTo, CardSerialNumberIdFrom = transaction.CardSerialFrom, CardSerialNumberIdTo = transaction.CardSerialTo, Amount = transaction.Amount, CardFromEMVData = transaction.CardFromEMVData, }; List <POSTransactionItemPM> items = new List <POSTransactionItemPM>(); posDetail.InvItems.ForEach(x => { POSTransactionItemPM tipm = new POSTransactionItemPM() { Amount = x.Amount, Name = x.Name, Quantity = x.Quantity, InventoryItemId = x.InventoryItemId, }; items.Add(tipm); }); POSTransactionPM posTxpm = new POSTransactionPM() { POSTransactionItems = items, }; _posRepository.AddPOSTransaction(txpm, posTxpm, GetCurrentUserId()); }
public string updatePOSTransaction([FromBody] POSTransaction pPOSTransaction) { return(loPOSTransaction.updatePOSTransaction(pPOSTransaction)); }