/// <summary> /// Check if Gift card is already added to transaction either as sale or payment. /// </summary> /// <param name="cardNumber"></param> /// <exception cref="GiftCardException"></exception> private void AssertNotAlreadyAdded(string cardNumber) { // Once a Gift card is added to the transaction for any operation (Issue, AddTo, Payment), then // the same card cannot be added to the transaction again for any other operation. RetailTransaction retailTransaction = Transaction as RetailTransaction; CustomerPaymentTransaction customerPaymentTransaction = Transaction as CustomerPaymentTransaction; LinkedList <SaleLineItem> salesLines = null; LinkedList <TenderLineItem> tenderLines = null; if (retailTransaction != null) { tenderLines = retailTransaction.TenderLines; salesLines = retailTransaction.SaleItems; } else if (customerPaymentTransaction != null) { tenderLines = customerPaymentTransaction.TenderLines; } // Check for all sales lines of type GiftCertificateItem where they are not voided and the serial number matches the card number. if (salesLines != null && salesLines.OfType <IGiftCardLineItem>().Any(l => (!l.Voided) && (l.SerialNumber == cardNumber))) { throw new GiftCardException(ApplicationLocalizer.Language.Translate(4323)); } // Check for all tender lines of type GiftCertificateTenderLineItem where they are not voided and the serial number matches the card number. if (tenderLines != null && tenderLines.OfType <IGiftCardTenderLineItem>().Any(l => (!l.Voided) && (l.SerialNumber == cardNumber))) { throw new GiftCardException(ApplicationLocalizer.Language.Translate(4323)); } }
public static CustomerPaymentDTO ConvertToCustomerPaymentDto(ProductOrder productOrder, List <CustomerPaymentTransaction> customerPayments) { //TODO : Vimal please verify this logic whether we are showing sum of all order amount or single at a time for payments. // Means order payment can be done partially multiple time for single order or only one time ? decimal?totalCrAmountOfOrder = customerPayments.Sum(x => x.PaymentCrAmount); CustomerPaymentTransaction lastPaymentByCustomer = customerPayments.OrderByDescending(x => x.CustomerPaymentId).FirstOrDefault(); CustomerPaymentDTO customerPaymentDTO = new CustomerPaymentDTO(); customerPaymentDTO.CustomerId = productOrder.Customer.CustomerId; customerPaymentDTO.CustomerName = productOrder.Customer.Name; customerPaymentDTO.ProductName = productOrder.ProductOrderDetails.FirstOrDefault().ProductSiteMapping.Product.ProductName; customerPaymentDTO.OrderNumber = productOrder.OrderNumber; customerPaymentDTO.OrderId = productOrder.OrderId; customerPaymentDTO.PaidAmount = totalCrAmountOfOrder.Value; customerPaymentDTO.TotalAmount = productOrder.OrderTotalPrice.GetValueOrDefault(); customerPaymentDTO.PaymentCrAmount = totalCrAmountOfOrder.Value; customerPaymentDTO.PaymentDate = lastPaymentByCustomer != null ? lastPaymentByCustomer.PaymentDate : DateTime.Now; PaymentMode modeOfPay = PaymentMode.Cash; if (lastPaymentByCustomer != null) { Enum.TryParse(lastPaymentByCustomer.PaymentMode, out modeOfPay); } customerPaymentDTO.PaymentMode = modeOfPay; customerPaymentDTO.PaymentReceivedBy = lastPaymentByCustomer != null ? lastPaymentByCustomer.PaymentReceivedBy : "NA"; customerPaymentDTO.Ref2 = lastPaymentByCustomer != null ? lastPaymentByCustomer.Ref2 : "NA"; customerPaymentDTO.CustomerPaymentId = lastPaymentByCustomer != null ? lastPaymentByCustomer.CustomerPaymentId : 0; customerPaymentDTO.PaymentComments = lastPaymentByCustomer != null ? lastPaymentByCustomer.Ref1 : "No Comments mentioned"; customerPaymentDTO.OrderStatus = productOrder.ProductOrderDetails.FirstOrDefault().OrderStatus.ToString(); return(customerPaymentDTO); }
public void Update(CustomerPaymentTransaction customerPaymentTransaction) { if (customerPaymentTransaction != null) { _repository.Entry <Sql.CustomerPaymentTransaction>(customerPaymentTransaction).State = System.Data.Entity.EntityState.Modified; // _repository.SaveChanges(); } }
public void Add(CustomerPaymentTransaction customerPaymentTransaction) { if (customerPaymentTransaction != null) { _repository.CustomerPaymentTransactions.Add(customerPaymentTransaction); // _repository.SaveChanges(); } }
public void UpdateCustomerPayment(CustomerPaymentDTO customerPaymentDTO) { CustomerPaymentTransaction customerPaymentTransaction = null; CustomerPaymentConvertor.ConvertToCustomerPaymentEntity(ref customerPaymentTransaction, customerPaymentDTO, true); unitOfWork.CustomerPaymentRepository.Update(customerPaymentTransaction); unitOfWork.SaveChanges(); }
public CustomerPaymentTransaction GetById(int customerPaymentTransactionId) { CustomerPaymentTransaction customerPaymentTransaction = new CustomerPaymentTransaction(); customerPaymentTransaction = _repository.CustomerPaymentTransactions.FirstOrDefault(x => x.CustomerPaymentId == customerPaymentTransactionId); return(customerPaymentTransaction); }
public void AddCustomerPayment(CustomerPaymentDTO customerPaymentDTO) { CustomerPaymentTransaction customerPaymentTransaction = new CustomerPaymentTransaction(); customerPaymentTransaction.CustomerPaymentId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerPaymentTransaction"); CustomerPaymentConvertor.ConvertToCustomerPaymentEntity(ref customerPaymentTransaction, customerPaymentDTO, false); unitOfWork.CustomerPaymentRepository.Add(customerPaymentTransaction); this.UpdateCustomerWallet(customerPaymentDTO); unitOfWork.SaveChanges(); }
public void AddCustomerPayment(ProductOrderDtlDTO productOrderDtlDTO) { CustomerPaymentTransaction customerPaymentTransaction = new CustomerPaymentTransaction(); customerPaymentTransaction.CustomerPaymentId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerPaymentTransaction"); customerPaymentTransaction.CustomerId = productOrderDtlDTO.CustomerId; customerPaymentTransaction.OrderId = productOrderDtlDTO.OrderId; customerPaymentTransaction.PaymentCrAmount = productOrderDtlDTO.OrderAmountPaid; customerPaymentTransaction.PaymentDrAmount = productOrderDtlDTO.TotalPrice; customerPaymentTransaction.PaymentReceivedBy = "Order Placed"; customerPaymentTransaction.PaymentDate = DateTime.Now.Date; unitOfWork.CustomerPaymentRepository.Add(customerPaymentTransaction); }
public static CustomerPaymentDTO ConvertToCustomerPaymentDto(CustomerPaymentTransaction customerPaymentTransaction) { CustomerPaymentDTO customerPaymentDTO = new CustomerPaymentDTO(); customerPaymentDTO.CustomerPaymentId = customerPaymentTransaction.CustomerPaymentId; customerPaymentDTO.CustomerId = customerPaymentTransaction.CustomerId; customerPaymentDTO.OrderId = customerPaymentTransaction.OrderId; customerPaymentDTO.PaymentCrAmount = customerPaymentTransaction.PaymentCrAmount.GetValueOrDefault(); customerPaymentDTO.PaymentDrAmount = customerPaymentTransaction.PaymentDrAmount.GetValueOrDefault(); customerPaymentDTO.PaymentDate = customerPaymentTransaction.PaymentDate; customerPaymentDTO.PaymentReceivedBy = customerPaymentTransaction.PaymentReceivedBy; customerPaymentDTO.PaymentComments = customerPaymentTransaction.Ref1; customerPaymentDTO.PaymentMode = customerPaymentTransaction.Ref2; return(customerPaymentDTO); }
public static void ConvertToCustomerPaymentEntity(ref CustomerPaymentTransaction customerPaymentTransaction, CustomerPaymentDTO customerPaymentDTO, bool isUpdate) { if (isUpdate) { customerPaymentTransaction.CustomerPaymentId = customerPaymentDTO.CustomerPaymentId; } customerPaymentTransaction.CustomerId = customerPaymentDTO.CustomerId; customerPaymentTransaction.OrderId = customerPaymentDTO.OrderId; customerPaymentTransaction.PaymentCrAmount = customerPaymentDTO.PaymentCrAmount; customerPaymentTransaction.PaymentDrAmount = customerPaymentDTO.PaymentDrAmount; customerPaymentTransaction.PaymentDate = customerPaymentDTO.PaymentDate; customerPaymentTransaction.PaymentReceivedBy = customerPaymentDTO.PaymentReceivedBy; customerPaymentTransaction.Ref1 = customerPaymentDTO.PaymentComments; customerPaymentTransaction.Ref2 = customerPaymentDTO.PaymentMode; }
/// <summary> /// Ctor /// </summary> /// <param name="context">Context of the gift card form</param> /// <param name="posTransaction">Transaction object.</param> /// <param name="tenderInfo">Tender information about GC (Required for Payment Context) </param> public GiftCardController(ContextType context, PosTransaction posTransaction, Tender tenderInfo) { this.Context = context; this.Transaction = posTransaction; this.tenderInfo = tenderInfo; this.CardNumber = string.Empty; // Get the balance of the transaction. IRetailTransaction retailTransaction = Transaction as IRetailTransaction; CustomerPaymentTransaction customerPaymentTransaction = Transaction as CustomerPaymentTransaction; if (retailTransaction != null) { TransactionAmount = retailTransaction.TransSalePmtDiff; } else if (customerPaymentTransaction != null) { TransactionAmount = customerPaymentTransaction.TransSalePmtDiff; } }
/// <summary> /// Process Linked InfoCodes for InfoCodeLineItem /// </summary> /// <param name="posTransaction"></param> /// <param name="tableRefId"></param> /// <param name="infoCodeType"></param> public void ProcessLinkedInfoCodes(IPosTransaction posTransaction, InfoCodeTableRefType tableRefId, InfoCodeType infoCodeType) { CustomerPaymentTransaction customerTransaction = posTransaction as CustomerPaymentTransaction; TenderCountTransaction tenderTransaction = posTransaction as TenderCountTransaction; if (customerTransaction != null) { //Loop while a linkedInfoCode is found int i = 0; //Set as a stop for a infinite loop LinkedListNode <InfoCodeLineItem> infoCodeItem = customerTransaction.InfoCodeLines.Last; if (infoCodeItem != null) { while (!string.IsNullOrEmpty(infoCodeItem.Value.LinkedInfoCodeId) && (i < 10)) { ProcessInfoCode(posTransaction, 0, 0, customerTransaction.Customer.CustomerId, string.Empty, string.Empty, InfoCodeTableRefType.Customer, infoCodeItem.Value.LinkedInfoCodeId, (IInfoCodeLineItem)infoCodeItem.Value, InfoCodeType.Header); // This is to prevent an infinite loop when infocodes link to themselves.. if (infoCodeItem.Value.LinkedInfoCodeId == customerTransaction.InfoCodeLines.Last.Value.LinkedInfoCodeId) { break; } infoCodeItem = customerTransaction.InfoCodeLines.Last; i++; } } } else if (tenderTransaction != null) { //Loop while a linkedInfoCode is found int i = 0; //Set as a stop for a infinite loop LinkedListNode <InfoCodeLineItem> infoCodeItem = tenderTransaction.InfoCodeLines.Last; if (infoCodeItem != null) { while (!string.IsNullOrEmpty(infoCodeItem.Value.LinkedInfoCodeId) && (i < 10)) { infoCodeItem = tenderTransaction.InfoCodeLines.Last; i++; } } } else { RetailTransaction asRetailTransaction = (RetailTransaction)posTransaction; //Loop while a linkedInfoCode is found int i = 0; //Set as a stop for a infinite loop LinkedListNode <InfoCodeLineItem> infoCodeItem = asRetailTransaction.InfoCodeLines.Last; if (infoCodeItem != null) { while (!string.IsNullOrEmpty(infoCodeItem.Value.LinkedInfoCodeId) && (i < 10)) { ProcessInfoCode(posTransaction, 0, 0, asRetailTransaction.Customer.CustomerId, string.Empty, string.Empty, tableRefId, infoCodeItem.Value.LinkedInfoCodeId, (IInfoCodeLineItem)infoCodeItem.Value, infoCodeType); // This is to prevent an infinite loop when infocodes link to themselves.. if (infoCodeItem.Value.LinkedInfoCodeId == asRetailTransaction.InfoCodeLines.Last.Value.LinkedInfoCodeId) { break; } infoCodeItem = asRetailTransaction.InfoCodeLines.Last; i++; } } } }