/// <summary> /// Processes the card payment by establishing a connection with the configured payment processor. /// </summary> /// <param name="eftInfo">Reference to an EftInfo object.</param> /// <param name="posTransaction">Current transaction.</param> /// <returns>True if the processing succeeded.</returns> public bool ProcessCardPayment(ref IEFTInfo eftInfo, IPosTransaction posTransaction) { //eftInfo.Authorized = true; //eftInfo.IsPendingCapture = true; //return eftInfo.Authorized; // This is the main entry point for the actual card processing. All card information that was // gathered by GetCardInfoAndAmount() has been copied to similar fields in the "eftInfo" object. // Use this information when calling your provider's service. // Our example will simulate successful authorization (or refund) randomly based on whether // this method gets hit on an odd or even second. In a real scenario, this is where you // would call your payment provider directly (web service, direct sockets, etc.) or call // out to a DLL with the necessary parameters. // All information is stored back to the eftInfo object which is used for printing the receipt, // storing information to the database (RetailTransactionPaymentTrans table), statement posting, etc. // In this example, we are simulating a 1-step Auth/Capture process, so we will // always leave "IsPendingCapture" as false. // The eftInfo class has many properties; most of them are used only for printing on the receipt. // See the EFT_NewSample2012_Readme.docx file for a mapping. // // Only a few are stored to the RetailTransactionPaymentTrans table: // eftInfo.BatchCode = BATCHID // eftInfo.AuthCode = EFTAUTHENTICATIONCODE // eftInfo.IssuerNumber = CARDTYPEID ** Only used if cardInfo.CardTypeId was blank after ID'ing the card // In addition, the cardInfo.CardNumber (masked) is stored to the CARDORACCOUNT column. // You may wish to save additional information to your own table. // Note: Both a SALE and a REFUND process will end up here. To determine if we're charging the card // or refunding money to the card, simply look at eftInfo.Amount. If the amount is negative, send a refund request. //if (DateTime.Now.Second % 2 == 1) //Uncomment this line to RANDOMLY succeed (odd or even second) ////if (true) //Uncomment this line to ALWAYS succeed //{ // //Auth was successful // eftInfo.Authorized = true; // //Authorization code returned from processor. // eftInfo.AuthCode = "123456"; // // Some fields only for printing on the receipt (see note above) // eftInfo.TransactionDateTime = DateTime.Now; // eftInfo.Message = String.Empty; // eftInfo.SequenceCode = String.Empty; // eftInfo.EntrySourceCode = String.Empty; // eftInfo.RetrievalReferenceNumber = String.Empty; // eftInfo.AccountType = "Checking"; // eftInfo.ResponseCode = String.Empty; // eftInfo.AuthorizedText = "Success"; // Printed on receipt as "EFT Info Message" field // // If performing a two-step Auth/Capture process, would set this to true in order // // to be caught by the Capture process at the end of the transaction. Otherwise, // // the Authorization process must send a Capture request at the same time as the Auth request. // eftInfo.IsPendingCapture = false; //} //else //{ // //Authorization failed // eftInfo.Authorized = false; // eftInfo.TransactionDateTime = DateTime.Now; // eftInfo.ProviderResponseCode = "99"; // eftInfo.NotAuthorizedText = "Not Approved"; // //Error Code and Error Message are shown to the user in pop-up window. // eftInfo.ErrorCode = "99999"; // eftInfo.ErrorMessage = "This is why the auth failed."; //} //if (!eftInfo.Authorized) //{ // // May want to print decline receipt if authorization failed. // PrintDeclineReceipt(eftInfo); // // Otherwise, set ErrorCode and ErrorMessage will be shown on the screen if Authorized = false // // Note: If authorization was successful, by default no message is given. You can add functionality // // to notify user of success. //} /* Blocked on 29.07.2013 // * * string sReqXML = "22,0,<?xml version='1.0' encoding='UTF-8' ?><purchase-request><TransactionInput ID='ID000001'><Card><IsManualEntry>false</IsManualEntry><Track1>4550381512383001^SUBHANKAR KUNDU ^1012101154730000000000774000000</Track1><Track2>5566204200063157=10031010019400</Track2></Card><Amount><BaseAmount>100</BaseAmount><CurrencyCode>INR</CurrencyCode></Amount><POS><POSReferenceNumber>TL993812</POSReferenceNumber><TransactionTime>2008-09-17T09:30:47.0Z</TransactionTime><Product><Code>SK9881277736</Code><Name>NOKIA 6610</Name><Description>Nokia mobile phone</Description><Category>MBL</Category></Product><Product><Code>SK9881277788</Code><Name>NOKIA 78GL ADPTR</Name><Description>Nokia travel adaptor</Description><Category>MBA</Category></Product><User><ID>16</ID><Name>AMITKUMAR</Name></User><TrackingNumber>818</TrackingNumber></POS></TransactionInput></purchase-request>"; * Project1.Class1 oEFTClass = new Project1.Class1(); * String sResponseXML = oEFTClass.Inno(sReqXML); * * DataSet ds = new DataSet(); * using (StringReader stringReader = new StringReader(sResponseXML)) * { * ds = new DataSet(); * ds.ReadXml(stringReader); * } * * DataTable dt = new DataTable(); * if (ds != null && ds.Tables.Count > 0) * { * dt = ds.Tables["HostResponse"]; * } * * if (dt != null && dt.Rows.Count > 0) * { * string code = Convert.ToString(dt.Rows[0]["ResponseCode"]); * string message = Convert.ToString(dt.Rows[0]["ResponseMessage"]); * string approvalcode = Convert.ToString(dt.Rows[0]["ApprovalCode"]); * if (string.IsNullOrEmpty(approvalcode)) * { * eftInfo.Authorized = false; * eftInfo.ErrorCode = code; * eftInfo.ErrorMessage = message; * } * } * else * { * eftInfo.Authorized = false; * eftInfo.ErrorCode = "99999"; * eftInfo.ErrorMessage = "No Connection Available to authorize the connection."; * } */ //using (LSRetailPosis.POSProcesses.frmMessage dialog = new frmMessage(sResponseXML, MessageBoxButtons.OK, MessageBoxIcon.Information)) //{ // Application.ApplicationFramework.POSShowForm(dialog); //} // eftInfo.Authorized = true; eftInfo.Authorized = true; string sTblName = "EXTNDCARDINFO" + ApplicationSettings.Terminal.TerminalId; string sCardNo = EFT.InternalApplication.BusinessLogic.Utility.MaskCardNumber(eftInfo.CardNumber); RetailTransaction retailTrans = posTransaction as RetailTransaction; if (retailTrans != null) { retailTrans.PartnerData.EFTCardNo = eftInfo.CardNumber; UpdateCardIfo(sTblName, retailTrans.TransactionId, sCardNo, sEFTApprovalCode, sCExpMonth, sCExpYear); } LSRetailPosis.Transaction.CustomerPaymentTransaction custTrans = posTransaction as LSRetailPosis.Transaction.CustomerPaymentTransaction; if (custTrans != null) { custTrans.PartnerData.EFTCardNo = eftInfo.CardNumber; UpdateCardIfo(sTblName, custTrans.TransactionId, sCardNo, sEFTApprovalCode, sCExpMonth, sCExpYear); } return(eftInfo.Authorized); }
public void PostProcessOperation(IPosTransaction posTransaction, PosisOperations posisOperation) { if (posisOperation == PosisOperations.CustomerAccountDeposit) { LSRetailPosis.Transaction.CustomerPaymentTransaction custTrans = posTransaction as LSRetailPosis.Transaction.CustomerPaymentTransaction; if (custTrans != null && custTrans.Amount != 0) { custTrans.PartnerData.EFTCardNo = string.Empty; if (!string.IsNullOrEmpty(Convert.ToString(custTrans.Customer.CustomerId))) { bool IsRepair = false; string sCustOrder = OrderNum(out IsRepair); //string sCustOrder = OrderNum(); if (!string.IsNullOrEmpty(sCustOrder)) { decimal dFixedRatePercentage = 0m; decimal dCustOrderTotalAmt = 0m; if (!IsRepair) { dFixedRatePercentage = GetCustOrderFixedRateInfo(sCustOrder, ref dCustOrderTotalAmt); } SqlConnection connection = new SqlConnection(); if (application != null) { connection = application.Settings.Database.Connection; } else { connection = ApplicationSettings.Database.LocalConnection; } Enums.EnumClass oEnum = new Enums.EnumClass(); string sMaxAmount = string.Empty; string sTerminalID = ApplicationSettings.Terminal.TerminalId; string sMinAmt = Convert.ToString(oEnum.ValidateMinDeposit(connection, out sMaxAmount, sTerminalID, dCustOrderTotalAmt)); (((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Comment = "INFORMATION : MINIMUM DEPOSIT AMOUNT IS " + decimal.Round(Convert.ToDecimal(sMinAmt), 2, MidpointRounding.AwayFromZero) + " " + "AND MAXIMUM DEPOSIT AMOUNT IS " + decimal.Round(Convert.ToDecimal(sMaxAmount), 2, MidpointRounding.AwayFromZero); ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdNo = sCustOrder; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdPercentage = dFixedRatePercentage; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdTotAmt = dCustOrderTotalAmt; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.GSSNum = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.NumMonths = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationType = Convert.ToString("NORMALCUSTOMERDEPOSIT"); ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationDone = Convert.ToBoolean(false); ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OrderNo = sCustOrder; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.SKUData = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.ItemIds = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.IsRepair = IsRepair; } else { #region Comment //frmOptionSelectionGSSorCustomerOrder optionSelection = new frmOptionSelectionGSSorCustomerOrder(); //optionSelection.ShowDialog(); //SqlConnection connection = new SqlConnection(); //if (application != null) // connection = application.Settings.Database.Connection; //else // connection = ApplicationSettings.Database.LocalConnection; //if (connection.State == ConnectionState.Closed) //{ // connection.Open(); //} //if (optionSelection.isGSS) //{ // string commandText = string.Empty; // commandText = " SELECT GSSACCOUNTOPENINGPOSTED.GSSACCOUNTNO AS [GSSACCOUNTNO.], " + // " DIRPARTYTABLE.NAMEALIAS AS [CUSTOMERNAME], " + // " CAST(GSSACCOUNTOPENINGPOSTED.INSTALLMENTAMOUNT AS NUMERIC(28,2)) AS [INSTALLMENTAMOUNT], " + // " ( CASE WHEN GSSACCOUNTOPENINGPOSTED.SCHEMETYPE=0 THEN 'FIXED' ELSE 'FLEXIBLE' END) AS [SCHEMETYPE], " + // " GSSACCOUNTOPENINGPOSTED.SCHEMECODE AS [SCHEMECODE], " + // " ( CASE WHEN GSSACCOUNTOPENINGPOSTED.SCHEMEDEPOSITTYPE=0 THEN 'GOLD' ELSE 'AMOUNT' END) AS [DEPOSITTYPE], " + // " GSSACCOUNTOPENINGPOSTED.GSSConfirm AS [GSSCONFIRM] " + // " FROM DIRPARTYTABLE INNER JOIN " + // " CUSTTABLE ON DIRPARTYTABLE.RECID = CUSTTABLE.PARTY INNER JOIN " + // " GSSACCOUNTOPENINGPOSTED ON CUSTTABLE.ACCOUNTNUM = GSSACCOUNTOPENINGPOSTED.CUSTACCOUNT " + // " WHERE GSSACCOUNTOPENINGPOSTED.CUSTACCOUNT = '" + custTrans.Customer.CustomerId + "'"; // if (connection.State == ConnectionState.Closed) // connection.Open(); // SqlCommand cmd = new SqlCommand(commandText, connection); // SqlDataReader rdr = cmd.ExecuteReader(); // DataTable dtGSS = new DataTable(); // dtGSS.Load(rdr); // BlankOperations.WinFormsTouch.frmGSSInput oGSS = new frmGSSInput(dtGSS, (((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Amount); // oGSS.ShowDialog(); // rdr.Dispose(); // if (oGSS.bStatus) // { // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.GSSNum = Convert.ToString(oGSS.GSSnumber); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.NumMonths = Convert.ToString(oGSS.months); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationType = Convert.ToString("GSS"); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationDone = Convert.ToBoolean(true); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.GoldFixing = oGSS.GoldFixing; // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).Amount = Convert.ToDecimal(oGSS.Amount); // (((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Amount = Convert.ToDecimal(oGSS.Amount); // (((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).TransSalePmtDiff = Convert.ToDecimal(oGSS.Amount); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdNo = string.Empty; // } // else // { // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.GSSNum = string.Empty; // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.NumMonths = string.Empty; // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationType = Convert.ToString("NORMALCUSTOMERDEPOSIT"); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationDone = Convert.ToBoolean(false); // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdNo = string.Empty; // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdPercentage = 0; // ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdTotAmt = 0; // } //} #endregion //else //{ ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.GSSNum = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.NumMonths = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationType = Convert.ToString("NORMALCUSTOMERDEPOSIT"); ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.OperationDone = Convert.ToBoolean(false); ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdNo = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdPercentage = 0; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.FixedRateCustOrdTotAmt = 0; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.ItemIds = string.Empty; ((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction)).PartnerData.IsRepair = false; //} } } } else { UpdateRetailTempTable(); } } LSRetailPosis.ApplicationLog.Log("IOperationTriggersV1.PostProcessOperation", "After the operation has been processed this trigger is called.", LSRetailPosis.LogTraceLevel.Trace); }
public void PrePayment(IPreTriggerResult preTriggerResult, IPosTransaction posTransaction, object posOperation, string tenderId) { RetailTransaction retailTransaction = posTransaction as RetailTransaction; LSRetailPosis.Transaction.CustomerPaymentTransaction custTrans = posTransaction as LSRetailPosis.Transaction.CustomerPaymentTransaction; if (custTrans != null) { InputConfirmation inputconfirm = new InputConfirmation(); inputconfirm.PromptText = "Remarks "; inputconfirm.InputType = InputType.Normal; Interaction.frmInput Oinput = new Interaction.frmInput(inputconfirm); Oinput.ShowDialog(); if (!string.IsNullOrEmpty(Oinput.InputText)) { custTrans.PartnerData.Remarks = Oinput.InputText; } else { custTrans.PartnerData.Remarks = ""; } if ((PosisOperations)posOperation == PosisOperations.PayCreditMemo) { preTriggerResult.ContinueOperation = false; return; } SqlConnection connection = new SqlConnection(); if (application != null) { connection = application.Settings.Database.Connection; } else { connection = ApplicationSettings.Database.LocalConnection; } Enums.EnumClass oEnum = new Enums.EnumClass(); string sMaxAmount = string.Empty; string sTerminalID = ApplicationSettings.Terminal.TerminalId; string sMinAmt = Convert.ToString(oEnum.ValidateMinDeposit(connection, out sMaxAmount, sTerminalID, Convert.ToDecimal((((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Amount))); if (Convert.ToDecimal(sMinAmt) != 0 && Convert.ToDecimal(sMaxAmount) != 0) { if (Convert.ToDecimal(sMinAmt) > Convert.ToDecimal((((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Amount) || Convert.ToDecimal(sMaxAmount) < Convert.ToDecimal((((LSRetailPosis.Transaction.CustomerPaymentTransaction)(posTransaction))).CustomerDepositItem.Amount)) { preTriggerResult.ContinueOperation = false; preTriggerResult.MessageId = 50448; return; } } } //start : RH on 05/11/2014 if (retailTransaction != null) { /* InputConfirmation inC = new InputConfirmation(); * inC.PromptText = "Remarks"; * inC.InputType = InputType.Normal; * * Interaction.frmInput Oinput = new Interaction.frmInput(inC); * Oinput.ShowDialog(); * if(!string.IsNullOrEmpty(Oinput.InputText)) * retailTransaction.PartnerData.Remarks = Oinput.InputText; * else * retailTransaction.PartnerData.Remarks = "";*/ int iPM = 100; int iCF = 100; int isSale = 0; foreach (SaleLineItem saleLineItem in retailTransaction.SaleItems) { if (!saleLineItem.Voided) { isSale = 1; iPM = getMetalType(saleLineItem.ItemId); if (iPM == (int)MetalType.PackingMaterial) { break; } } } if (isSale == 1 && string.IsNullOrEmpty(retailTransaction.PartnerData.Remarks)) { InputConfirmation inC = new InputConfirmation(); inC.PromptText = "Remarks"; inC.InputType = InputType.Normal; Interaction.frmInput Oinput = new Interaction.frmInput(inC); Oinput.ShowDialog(); if (!string.IsNullOrEmpty(Oinput.InputText)) { retailTransaction.PartnerData.Remarks = Oinput.InputText; } else { retailTransaction.PartnerData.Remarks = ""; } } if ((isSale == 1 || retailTransaction.SaleIsReturnSale) && string.IsNullOrEmpty(retailTransaction.PartnerData.TouristNumber)) { using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Tourist VAT Applicable.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); //command.Parameters.Add("@GOLDFIXING", SqlDbType.Bit).Value = Convert.ToString(dialog.DialogResult).ToUpper().Trim() == "YES" ? "True" : "False"; if (Convert.ToString(dialog.DialogResult).ToUpper().Trim() == "YES") { InputConfirmation inC = new InputConfirmation(); inC.PromptText = "Tourist VAT Applicable"; inC.InputType = InputType.Normal; inC.MaxLength = 20; Interaction.frmInput Oinput = new Interaction.frmInput(inC); Oinput.ShowDialog(); if (!string.IsNullOrEmpty(Oinput.InputText)) { retailTransaction.PartnerData.TouristNumber = Oinput.InputText; } else { retailTransaction.PartnerData.TouristNumber = ""; } } } } string sAdjustmentId = AdjustmentItemID(); foreach (SaleLineItem SLineItem in retailTransaction.SaleItems) { //if(SLineItem.ItemId == sAdjustmentId && retailTransaction.SaleItems.Count == 1) //{ // retailTransaction.RefundReceiptId = "1"; // //break; //} if (SLineItem.ItemId == sAdjustmentId && retailTransaction.SaleItems.Count > 0) { retailTransaction.RefundReceiptId = "1"; } if (SLineItem.ItemId != sAdjustmentId) { retailTransaction.RefundReceiptId = ""; break; } } foreach (SaleLineItem saleLineItem in retailTransaction.SaleItems) { if (!saleLineItem.Voided) { iCF = getMetalType(saleLineItem.ItemId); if (iCF == (int)MetalType.Certificate) { break; } } } foreach (SaleLineItem saleLineItem in retailTransaction.SaleItems) { if (saleLineItem.ReturnLineId == 0) { if (retailTransaction.PartnerData.PackingMaterial != "Y") { if (IsRetailItem(saleLineItem.ItemId)) { if (iPM != (int)MetalType.PackingMaterial) { #region Commented //using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Have you issued packing material?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) //{ // LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // if(Convert.ToString(dialog.DialogResult).ToUpper().Trim() == "NO") // { // preTriggerResult.ContinueOperation = false; // return; // } // else // { // retailTransaction.PartnerData.PackingMaterial = "Y"; // if(IsCertificateItem(saleLineItem.ItemId)) // { // if(iCF != (int)MetalType.Certificate) // { // using(LSRetailPosis.POSProcesses.frmMessage dialog1 = new LSRetailPosis.POSProcesses.frmMessage("Have you issued the certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) // { // LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog1); // if(Convert.ToString(dialog1.DialogResult).ToUpper().Trim() == "NO") // { // preTriggerResult.ContinueOperation = false; // return; // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; // } // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; // } // } //} #endregion using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Proceed without packing material?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); if (Convert.ToString(dialog.DialogResult).ToUpper().Trim() == "NO") { preTriggerResult.ContinueOperation = false; return; } } } else { retailTransaction.PartnerData.PackingMaterial = "Y"; #region Commented //if(IsCertificateItem(saleLineItem.ItemId)) //{ // if(iCF != (int)MetalType.Certificate) // { // using(LSRetailPosis.POSProcesses.frmMessage dialog1 = new LSRetailPosis.POSProcesses.frmMessage("Have you issued the certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) // { // LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog1); // if(Convert.ToString(dialog1.DialogResult).ToUpper().Trim() == "NO") // { // preTriggerResult.ContinueOperation = false; // return; // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; // } // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; //} #endregion } } } #region Commented // else if(retailTransaction.PartnerData.CertificateIssue != "Y") // { // if(IsCertificateItem(saleLineItem.ItemId)) // { // if(iCF != (int)MetalType.Certificate) // { // using(LSRetailPosis.POSProcesses.frmMessage dialog1 = new LSRetailPosis.POSProcesses.frmMessage("Have you issued the certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) // { // LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog1); // if(Convert.ToString(dialog1.DialogResult).ToUpper().Trim() == "NO") // { // preTriggerResult.ContinueOperation = false; // return; // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; // } // } // else // retailTransaction.PartnerData.CertificateIssue = "Y"; // } // } #endregion } } } // end: RH on 05/11/2014 LSRetailPosis.ApplicationLog.Log("PaymentTriggers.PrePayment", "On the start of a payment operation...", LSRetailPosis.LogTraceLevel.Trace); switch ((PosisOperations)posOperation) { case PosisOperations.PayCash: // Insert code here... break; case PosisOperations.PayCard: // Insert code here... break; case PosisOperations.PayCheque: // Insert code here... break; case PosisOperations.PayCorporateCard: // Insert code here... break; case PosisOperations.PayCreditMemo: // Insert code here... break; case PosisOperations.PayCurrency: // Insert code here... break; case PosisOperations.PayCustomerAccount: // Insert code here... break; case PosisOperations.PayGiftCertificate: // Insert code here... break; case PosisOperations.PayLoyalty: // Insert code here... break; // etc..... } }
public bool ProcessInfoCode(IPosTransaction posTransaction, decimal quantity, decimal amount, string refRelation, string refRelation2, string refRelation3, InfoCodeTableRefType tableRefId, string linkedInfoCodeId, IInfoCodeLineItem orgInfoCode, InfoCodeType infoCodeType) { RetailTransaction retailTransaction = posTransaction as RetailTransaction; TenderCountTransaction tenderCountTransaction = posTransaction as TenderCountTransaction; // Other possible transaction types at this point include CustomerPayment if (refRelation == null) { refRelation = string.Empty; } if (refRelation2 == null) { refRelation2 = string.Empty; } if (refRelation3 == null) { refRelation3 = string.Empty; } //Infocode IInfoCodeSystem infoCodeSystem = this.Application.BusinessLogic.InfoCodeSystem; IInfoCodeLineItem[] infoCodes = new IInfoCodeLineItem[0]; if (!string.IsNullOrEmpty(linkedInfoCodeId)) { infoCodes = infoCodeSystem.GetInfocodes(linkedInfoCodeId); } else if (tableRefId == InfoCodeTableRefType.FunctionalityProfile) { infoCodes = infoCodeSystem.GetInfocodes(refRelation2); refRelation2 = string.Empty; } else if (tableRefId == InfoCodeTableRefType.PreItem) { // Pre item is just a table ref id of item, but handled during different processing infoCodes = infoCodeSystem.GetInfocodes(refRelation, refRelation2, refRelation3, InfoCodeTableRefType.Item); } else { infoCodes = infoCodeSystem.GetInfocodes(refRelation, refRelation2, refRelation3, tableRefId); } foreach (InfoCodeLineItem infoCode in infoCodes) { if (infoCode.InfocodeId == null) { return(false); } //If no infocode is found // Process age limit info codes as pre item. I.e. stop processing on this info code if it is pre item // and not of type age limit. // Low impact fix that should be reevaluated if any info code other than age limit is ever added // pre item. Using continue because indentation of if/else sequence already too much. if (((tableRefId == InfoCodeTableRefType.PreItem) && (infoCode.InputType != InfoCodeInputType.AgeLimit))) { continue; } //If bug in data, fixes division by zero if (infoCode.RandomFactor == 0) { infoCode.RandomFactor = 100; } infoCode.OriginType = infoCodeType; infoCode.RefRelation = refRelation; infoCode.RefRelation2 = refRelation2; infoCode.RefRelation3 = refRelation3; switch (infoCode.OriginType) { case InfoCodeType.Header: infoCode.Amount = amount; break; case InfoCodeType.Sales: infoCode.Amount = (amount * -1); break; case InfoCodeType.Payment: infoCode.Amount = amount; break; case InfoCodeType.IncomeExpense: infoCode.Amount = amount; break; } int randomFactor = (int)(100 / infoCode.RandomFactor); //infoCode.RandomFactor = 100 means ask 100% for a infocode Random random = new Random(); int randomNumber = random.Next(randomFactor); //Creates numbers from 0 to randomFactor-1 //Only get the infocode if randomfactor is set to zero or generated random number is the sama as the randomfactor-1 if (infoCode.RandomFactor == 100 || randomNumber == (randomFactor - 1)) { Boolean infoCodeNeeded = true; if (infoCode.OncePerTransaction) { if (tenderCountTransaction != null) { infoCodeNeeded = tenderCountTransaction.InfoCodeNeeded(infoCode.InfocodeId); } else { infoCodeNeeded = retailTransaction.InfoCodeNeeded(infoCode.InfocodeId); } } if (infoCodeNeeded) { // If the required type is negative but the quantity is positive, do not continue if (infoCode.InputRequiredType == InfoCodeInputRequiredType.Negative && quantity > 0) { infoCodeNeeded = false; } // If the required type is positive but the quantity is negative, do not continue if (infoCode.InputRequiredType == InfoCodeInputRequiredType.Positive && quantity < 0) { infoCodeNeeded = false; } } // If there is some infocodeID existing, and infocod is needed if (infoCode.InfocodeId != null && infoCodeNeeded == true) { #region Text and General if (infoCode.InputType == InfoCodeInputType.Text || infoCode.InputType == InfoCodeInputType.General) { Boolean inputValid = true; bool abort = false; // Get a infocode text do { inputValid = true; InputConfirmation inputConfirmation = new InputConfirmation() { MaxLength = MaxInfocodeInformationLengh, PromptText = infoCode.Prompt, }; InteractionRequestedEventArgs request = new InteractionRequestedEventArgs(inputConfirmation, () => { if (inputConfirmation.Confirmed) { if (string.IsNullOrEmpty(inputConfirmation.EnteredText)) { abort = true; POSFormsManager.ShowPOSMessageDialog(3593); } else { int textId = 0; if (inputConfirmation.EnteredText.Length == 0 && infoCode.InputRequired) { textId = 3590; //The input text is required inputValid = false; } if (inputValid && infoCode.MinimumLength > 0 && inputConfirmation.EnteredText.Length < infoCode.MinimumLength) { textId = 3591; //The input text is too short. inputValid = false; } if (inputValid && infoCode.MaximumLength > 0 && inputConfirmation.EnteredText.Length > infoCode.MaximumLength) { textId = 3592; //The input text exceeds the maximum length. inputValid = false; } if (inputValid && infoCode.AdditionalCheck == 1) { inputValid = CheckKennitala(inputConfirmation.EnteredText); if (!inputValid) { textId = 3603; } } if (!inputValid) { POSFormsManager.ShowPOSMessageDialog(textId); } } infoCode.Information = inputConfirmation.EnteredText; } else { inputValid = infoCode.InputRequired; } } ); Application.Services.Interaction.InteractionRequest(request); if (abort) { return(false); } } while (!inputValid); //Adding the result to the infocode } #endregion #region Date else if (infoCode.InputType == InfoCodeInputType.Date) { Boolean inputValid = true; do { inputValid = true; string inputText; //Show the input form using (frmInputNumpad inputDialog = new frmInputNumpad()) { inputDialog.EntryTypes = NumpadEntryTypes.Date; inputDialog.PromptText = infoCode.Prompt; POSFormsManager.ShowPOSForm(inputDialog); // Quit if cancel is pressed... if (inputDialog.DialogResult == System.Windows.Forms.DialogResult.Cancel && !infoCode.InputRequired) { return(false); } inputText = inputDialog.InputText; } //Is input valid? if (!string.IsNullOrEmpty(inputText)) { int textId = 0; bool isDate = true; DateTime infoDate = DateTime.Now; try { infoDate = Convert.ToDateTime(inputText, (IFormatProvider)Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch { isDate = false; } if (!isDate) { textId = 3602; //Date entered is not valid inputValid = false; } if (inputText.Length == 0 && infoCode.InputRequired) { textId = 3594; //A number input is required inputValid = false; } if (!inputValid) { POSFormsManager.ShowPOSMessageDialog(textId); } else { //Setting the result to the infocode infoCode.Information = infoDate.ToString(Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern); } } else if (infoCode.InputRequired) { inputValid = false; POSFormsManager.ShowPOSMessageDialog(3597);//A number input is required } } while (!inputValid); } #endregion #region Numeric and Operator/Staff else if (infoCode.InputType == InfoCodeInputType.Numeric || infoCode.InputType == InfoCodeInputType.Operator) { Boolean inputValid = true; do { inputValid = true; string inputText = string.Empty; //Show the input form using (frmInputNumpad inputDialog = new frmInputNumpad()) { inputDialog.EntryTypes = NumpadEntryTypes.Price; inputDialog.PromptText = infoCode.Prompt; POSFormsManager.ShowPOSForm(inputDialog); // Quit if cancel is pressed and input not required... if (inputDialog.DialogResult == System.Windows.Forms.DialogResult.Cancel && !infoCode.InputRequired) { return(false); } // If input required then only valid result is Ok. if (inputDialog.DialogResult == System.Windows.Forms.DialogResult.OK) { inputText = inputDialog.InputText; } } //Is input empty? if (!string.IsNullOrWhiteSpace(inputText)) { int textId = 0; if (inputText.Length == 0 && infoCode.InputRequired) { textId = 3594; //A number input is required inputValid = false; } if (infoCode.MinimumValue != 0 && Convert.ToDecimal(inputText) < infoCode.MinimumValue) { textId = 3595; //The number is lower than the minimum value inputValid = false; } if (infoCode.MaximumValue != 0 && Convert.ToDecimal(inputText) > infoCode.MaximumValue) { textId = 3596; //The number exceeds the maximum value inputValid = false; } if (!inputValid) { POSFormsManager.ShowPOSMessageDialog(textId); } } else { inputValid = false; POSFormsManager.ShowPOSMessageDialog(3597); //A number input is required } //Setting the result to the infocode infoCode.Information = inputText; } while (!inputValid); } #endregion #region Customer else if (infoCode.InputType == InfoCodeInputType.Customer) { bool inputValid = true; do { inputValid = true; Contracts.DataEntity.ICustomer customer = this.Application.Services.Customer.Search(); if (customer != null) { infoCode.Information = customer.CustomerId; inputValid = true; } else { if (infoCode.InputRequired) { inputValid = false; POSFormsManager.ShowPOSMessageDialog(3598); //A customer needs to be selected } } } while (!inputValid); } #endregion #region Item else if (infoCode.InputType == InfoCodeInputType.Item) { Boolean inputValid = true; do { string selectedItemID = string.Empty; DialogResult dialogResult = this.Application.Services.Dialog.ItemSearch(500, ref selectedItemID); // Quit if cancel is pressed... if (dialogResult == System.Windows.Forms.DialogResult.Cancel && !infoCode.InputRequired) { return(false); } if (!string.IsNullOrEmpty(selectedItemID)) { infoCode.Information = selectedItemID; inputValid = true; } else { if (infoCode.InputRequired) { inputValid = false; POSFormsManager.ShowPOSMessageDialog(3599);//A items needs to be selected } } } while (!inputValid); } #endregion #region SubCode else if ((infoCode.InputType == InfoCodeInputType.SubCodeList) || (infoCode.InputType == InfoCodeInputType.SubCodeButtons)) { FormInfoCodeSubCodeBase infoSubCodeDialog; if (infoCode.InputType == InfoCodeInputType.SubCodeList) { infoSubCodeDialog = new FormInfoCodeSubCodeList(); } else { infoSubCodeDialog = new FormInfoSubCode(); } using (infoSubCodeDialog) { bool inputValid = false; do { infoSubCodeDialog.InfoCodePrompt = infoCode.Prompt; infoSubCodeDialog.InfoCodeId = infoCode.InfocodeId; infoSubCodeDialog.InputRequired = infoCode.InputRequired; POSFormsManager.ShowPOSForm(infoSubCodeDialog); switch (infoSubCodeDialog.DialogResult) { case DialogResult.OK: inputValid = true; break; case DialogResult.No: return(false); default: if (!infoCode.InputRequired) { return(false); } break; } //if InputValid is false then nothing was selected in the dialog and there is no point in going through this code if (inputValid) { infoCode.Information = infoSubCodeDialog.SelectedDescription; infoCode.Subcode = infoSubCodeDialog.SelectedSubcodeId; //TenderDeclarationTransaction also has infocodes but it can't have any sale items so no need //to go through this code. if (retailTransaction != null) { //Look through the information on the subcode that was selected and see if an item is to be sold //and if a discount and/or price needs to be modified //foreach (SubcodeInfo subcodeInfo in infoSubCodeDialog.SubCodes) //{ if ((infoSubCodeDialog.SelectedTriggerFunction == (int)TriggerFunctionEnum.Item) && (infoSubCodeDialog.SelectedTriggerCode.Length != 0)) { OperationInfo opInfo = new OperationInfo(); ItemSale itemSale = new ItemSale(); itemSale.OperationID = PosisOperations.ItemSale; itemSale.OperationInfo = opInfo; itemSale.Barcode = infoSubCodeDialog.SelectedTriggerCode; itemSale.POSTransaction = retailTransaction; itemSale.RunOperation(); //The infocode item has been added. //Look at the last item on the transaction and if it is the same item that the ItemSale was supposed to sell //then check to see if it is to have a special price or discount if (retailTransaction.SaleItems.Last.Value.ItemId == infoSubCodeDialog.SelectedTriggerCode) { //set the property of that item to being an infocode item such that if the same item is added again, then //these will not be aggregated (since the item as infocode item might receive a different discount than the same //item added regularly. retailTransaction.SaleItems.Last.Value.IsInfoCodeItem = true; infoCode.SubcodeSaleLineId = retailTransaction.SaleItems.Last.Value.LineId; if (infoSubCodeDialog.SelectedPriceType == (int)PriceTypeEnum.Price) { PriceOverride priceOverride = new PriceOverride(); opInfo.NumpadValue = infoSubCodeDialog.SelectedAmountPercent.ToString("n2"); opInfo.ItemLineId = retailTransaction.SaleItems.Last.Value.LineId; priceOverride.OperationInfo = opInfo; priceOverride.OperationID = PosisOperations.PriceOverride; priceOverride.POSTransaction = retailTransaction; priceOverride.LineId = retailTransaction.SaleItems.Last.Value.LineId; priceOverride.RunOperation(); } else if (infoSubCodeDialog.SelectedPriceType == (int)PriceTypeEnum.Percent) { LineDiscountPercent lineDiscount = new LineDiscountPercent(); opInfo.NumpadValue = infoSubCodeDialog.SelectedAmountPercent.ToString("n2"); opInfo.ItemLineId = retailTransaction.SaleItems.Last.Value.LineId; lineDiscount.OperationInfo = opInfo; lineDiscount.OperationID = PosisOperations.LineDiscountPercent; lineDiscount.POSTransaction = retailTransaction; lineDiscount.RunOperation(); } } } } } } while (!inputValid); } } #endregion #region Age limit else if ((infoCode.InputType == InfoCodeInputType.AgeLimit)) { int ageLimit = (int)infoCode.MinimumValue; if (ageLimit >= 0) { //Calculate birthdate corresponding to minimum age limit DateTime dtBirthDate = DateTime.Today.AddYears(-ageLimit); //Convert the date time value according to the current culture information string birthDate = dtBirthDate.ToString(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern); string msg = ApplicationLocalizer.Language.Translate(3606, ageLimit, birthDate); // Process age limit info codes if it is pre item and prompt the message to user for processing. // Also Info Code type is an item and Age Limit is a link to reason code then process the info code with prompt to user. if (((tableRefId == InfoCodeTableRefType.PreItem) && (infoCode.InputType == InfoCodeInputType.AgeLimit)) || (!string.IsNullOrEmpty(linkedInfoCodeId) && tableRefId == InfoCodeTableRefType.Item)) { using (frmMessage frmMsg = new frmMessage(msg, MessageBoxButtons.YesNo, MessageBoxIcon.Information, false)) { POSFormsManager.ShowPOSForm(frmMsg); if (frmMsg.DialogResult != DialogResult.Yes) { return(false); } } } infoCode.Information = msg; } } #endregion else { POSFormsManager.ShowPOSMessageDialog(3589); return(false); } // Add the infocode to the transaction if (infoCode.Information != null && infoCode.Information.Length > 0) { string infoComment = string.Empty; if (infoCode.PrintPromptOnReceipt || infoCode.PrintInputOnReceipt || infoCode.PrintInputNameOnReceipt) { if (infoCode.PrintPromptOnReceipt && (infoCode.Prompt.Length != 0)) { infoComment = infoCode.Prompt; } if (infoCode.PrintInputOnReceipt && (infoCode.Subcode != null) && (infoCode.Subcode.Length != 0)) { if (infoComment.Length != 0) { infoComment += " - " + infoCode.Subcode; } else { infoComment = infoCode.Subcode; } } if (infoCode.PrintInputNameOnReceipt && (infoCode.Information.Length != 0)) { if (infoComment.Length != 0) { infoComment += " - " + infoCode.Information; } else { infoComment = infoCode.Information; } } } if (infoCodeType == InfoCodeType.Sales) { int lineId; if (infoCode.SubcodeSaleLineId != -1) { SaleLineItem saleLineItem = retailTransaction.GetItem(infoCode.SubcodeSaleLineId - 1); saleLineItem.Add(infoCode); lineId = saleLineItem.LineId; } else { // don't save if this is pre-item. the same infocodes will be found next pass for normal item infocodes. if (tableRefId == InfoCodeTableRefType.PreItem) { continue; } else { LinkedListNode <SaleLineItem> saleLineItem = retailTransaction.SaleItems.Last; saleLineItem.Value.Add(infoCode); lineId = saleLineItem.Value.LineId; } } if (infoComment.Trim().Length != 0) { OperationInfo opInfo = new OperationInfo(); opInfo.NumpadValue = infoComment.Trim(); opInfo.ItemLineId = lineId; ItemComment itemComment = new ItemComment(); itemComment.OperationID = PosisOperations.ItemComment; itemComment.POSTransaction = (PosTransaction)posTransaction; itemComment.OperationInfo = opInfo; itemComment.RunOperation(); } } else if (infoCodeType == InfoCodeType.Payment) { if (retailTransaction != null) { LinkedListNode <TenderLineItem> tenderLineItem = retailTransaction.TenderLines.Last; tenderLineItem.Value.Add(infoCode); if (infoComment.Trim().Length != 0) { tenderLineItem.Value.Comment = infoComment.Trim(); } } else { LSRetailPosis.Transaction.CustomerPaymentTransaction custPayTrans = posTransaction as LSRetailPosis.Transaction.CustomerPaymentTransaction; LinkedListNode <TenderLineItem> tenderLineItem = custPayTrans.TenderLines.Last; tenderLineItem.Value.Add(infoCode); if (infoComment.Trim().Length != 0) { tenderLineItem.Value.Comment = infoComment.Trim(); } } //LinkedListNode<TenderLineItem> tenderLineItem = retailTransaction.TenderLines.Last; // //tenderLineItem.Value.Add(infoCode); //if (infoComment.Trim().Length != 0) //{ // tenderLineItem.Value.Comment = infoComment.Trim(); //} } else { if (retailTransaction != null) { retailTransaction.Add(infoCode); if (infoComment.Trim().Length != 0) { retailTransaction.InvoiceComment += infoComment.Trim(); } } else { tenderCountTransaction.Add(infoCode); //No invoice comment on TenderDeclarationTransaction } } } } } } return(true); }