public static List <string> EditPaymentValidation(ReceiptPayment paymentToEdit, ReceiptPayment originalPayment) { var errors = new List <string>(); var p = paymentToEdit; bool hasMatch = false; var o = originalPayment; if (HasMatchingPayment(p, o)) { hasMatch = true; } if (!hasMatch) { errors.Add($@"The {Payment.GetPaymentType(p.PaymentType)} payment with payId {p.PayId} is not a valid payment."); } if (NotEditablePaymentTypes(paymentToEdit, originalPayment)) { errors.Add("You can only edit cash or check payments"); } if (IsDateFinalized(originalPayment)) { errors.Add("These payments have been finalized and can no longer be edited"); } return(errors); }
public static bool HasMatchingPayment(ReceiptPayment paymentToCheck, ReceiptPayment originalPayment) { if (paymentToCheck.PayId == originalPayment.PayId && paymentToCheck.OTId == originalPayment.OTId) { return(true); } return(false); }
public ClientResponse(string cashierid) { ResponseCashierData = CashierData.Get(cashierid); if (ResponseCashierData.CashierId != cashierid) { Errors.Add($"CashierId: {cashierid} was not found."); return; } Charges = Charge.GetChargesByCashierId(cashierid); ReceiptPayments = ReceiptPayment.Get(cashierid); }
public static List <string> UpdatePayments( ReceiptPayment paymentToEdit, ReceiptPayment originalPayment, // do i need this to rollback the transaction if not doing it using SQL? string username) { var errors = new List <string>(); var p = paymentToEdit; if (p.PaymentType == "CA" || p.PaymentType == "CK") { var param = new DynamicParameters(); param.Add("@PayId", p.PayId); param.Add("@otid", p.OTId); param.Add("@PaymentType", p.PaymentType); param.Add("@CheckNumber", p.CheckNumber); param.Add("@username", username); var query = @" USE WATSC; UPDATE ccCashierPayment SET PmtType = @PaymentType, CkNo = @CheckNumber, UpdatedBy = @username, UpdatedOn = GETDATE() WHERE PayId = @PayId AND OTid = @otid; "; try { if (!Constants.Save_Data(query, param)) { errors.Add($@"The {Payment.GetPaymentType(p.PaymentType).ToLower()} payment with payId {p.PayId} was not updated"); } } catch (Exception ex) { Constants.Log(ex, query); errors.Add($@"The {Payment.GetPaymentType(p.PaymentType).ToLower()} payment with payId {p.PayId} did not update properly"); } } return(errors); }
public static bool NotEditablePaymentTypes(ReceiptPayment paymentTypeToEdit, ReceiptPayment originalPaymentType) { string[] validPaymentTypes = { "CA", "CK" }; if (!validPaymentTypes.Contains(paymentTypeToEdit.PaymentType) || !validPaymentTypes.Contains(originalPaymentType.PaymentType)) //if ((from p in paymentTypeToEdit // where p.PaymentType != "CA" && // p.PaymentType != "CK" // select p).ToList().Count() > 0 || // (from p in originalPaymentType // where p.PaymentType != "CA" && // p.PaymentType != "CK" // select p).ToList().Count() > 0) { return(true); } return(false); }
public ClientResponse(string cashierid, UserAccess ua, bool isVoid = false) { ResponseCashierData = CashierData.Get(cashierid); if (ResponseCashierData.CashierId != cashierid) { Errors.Add($"CashierId: {cashierid} was not found."); return; } Charges = Charge.GetChargesByCashierId(cashierid); ReceiptPayments = ReceiptPayment.Get(cashierid); if (!isVoid && (ua.void_manager_access || (ua.cashier_access && !ReceiptPayments.Any(p => p.IsFinalized == true)))) { CanVoid = false; } else { ValidateVoid(ua, isVoid); } }
public static bool IsDateFinalized(ReceiptPayment originalPayment) { return(Balancing.DJournal.LastDateFinalized().Date >= originalPayment.TransactionDate.Date); }
public ClientResponse(string cashierid, List <Charge> charges) { ResponseCashierData = CashierData.Get(cashierid); Charges = charges; ReceiptPayments = ReceiptPayment.Get(cashierid); }