public DataResult GetData(StringDictionary attributeDictionary, IDataReader reader, string catalog, RunType runType) { var item = new Item { ItemId = reader["ItemID"].ToString(), Quantity = Int32.Parse(reader["Quantity"].ToString()), Reference_1 = reader["Reference_1"].ToString(), ShipNode = reader["ShipNode"].ToString(), TransactionDate = Convert.ToDateTime(reader["TransactionDate"]).ToUniversalTime().ToString(DATE_FORMAT) }; List <Item> itemList = new List <Item>(); itemList.Add(item); var posTransaction = new PosTransaction(); posTransaction.ItemList = itemList; posTransaction.SourceId = reader["Reference_1"].ToString(); return(new DataResult { ExportData = posTransaction }); }
protected override void OnLoad(EventArgs e) { if (!this.DesignMode) { receiptData = new PurchaseOrderReceiptData( ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID, ApplicationSettings.Terminal.StorePrimaryId); posTransaction = (PosTransaction)PurchaseOrderReceiving.InternalApplication.BusinessLogic.Utility.CreateSalesOrderTransaction( ApplicationSettings.Terminal.StoreId, ApplicationSettings.Terminal.StoreCurrency, ApplicationSettings.Terminal.TaxIncludedInPrice, PurchaseOrderReceiving.InternalApplication.Services.Rounding); ClearForm(); PurchaseOrderReceiving.InternalApplication.Services.Peripherals.Scanner.ScannerMessageEvent -= new ScannerMessageEventHandler(OnBarcodeScan); PurchaseOrderReceiving.InternalApplication.Services.Peripherals.Scanner.ScannerMessageEvent += new ScannerMessageEventHandler(OnBarcodeScan); PurchaseOrderReceiving.InternalApplication.Services.Peripherals.Scanner.ReEnableForScan(); } LoadReceiptLines(); TranslateLabels(); base.OnLoad(e); if (prType == PRCountingType.PurchaseOrder) { this.btnUom.Visible = false; } this.gvInventory.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridView_RowClickEventHandler); }
private bool IsLocked(string sSKUNo, out string sTransID) { bool bIsLocked = false; LSRetailPosis.DataAccess.SuspendRetrieveData objData = new LSRetailPosis.DataAccess.SuspendRetrieveData(SqlCon, ApplicationSettings.Database.DATAAREAID); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { RoundingService.Rounding roun = new RoundingService.Rounding(); PosTransaction pSuspended = objData.GetSuspendedTransaction(SqlCon, Convert.ToString(dr[0]), roun); RetailTransaction RTSuspended = pSuspended as RetailTransaction; if (RTSuspended != null) { foreach (SaleLineItem Sl in RTSuspended.SaleItems) { if (Sl.ItemId == sSKUNo) { bIsLocked = true; sTransID = RTSuspended.TransactionId; return(bIsLocked); } } } } } sTransID = string.Empty; return(bIsLocked); }
public frmPos() { InitializeComponent(); AddHandlers(); this.postTransaction = new PosTransaction(); }
public frmPayCustomerAccount(PayCustomerAccountConfirmation payCustomerAccountConfirmation) : this() { if (payCustomerAccountConfirmation == null) { throw new ArgumentNullException("payCustomerAccountConfirmation"); } this.tenderInfo = (Tender)payCustomerAccountConfirmation.TenderInfo; amtCustAmounts.SoldLocalAmount = payCustomerAccountConfirmation.BalanceAmount; this.balanceAmount = payCustomerAccountConfirmation.BalanceAmount; this.PosTransaction = (PosTransaction)payCustomerAccountConfirmation.PosTransaction; }
public int GenerateNewTransactionID() { using (var uow = new UnitOfWork(new DataContext())) { var postTransaction = new PosTransaction(); postTransaction.CreateTimeStamp = DateTime.Now; postTransaction.TransactionCode = Utils.RandomNumbers(5); postTransaction.AmountTender = 0; postTransaction.UserID = CurrentUser.UserID; uow.PosTransaction.Add(postTransaction); uow.Complete(); return(postTransaction.POSTransactionID); } }
/// <summary> /// Display the transaction on Receipt control /// </summary> /// <param name="posTransaction"></param> public void ShowTransaction(PosTransaction posTransaction) { if (posTransaction == null) { // There is no transaction taking place. Time to display advertisements in full screen mode HideReceiptControl(); // Update settings after every transaction. (Head office may have pushed new settings) LoadSettings(); } else { // Threre is a transaction taking place. Now we display the receipt component and resize the advertisement panel. ShowReceiptControl(); receipt.ShowTransaction(posTransaction); totalAmounts.ShowTransaction(posTransaction); } }
public PosTransactionModel GenerateNewTransaction() { using (var uow = new UnitOfWork(new DataContext())) { var posTransaction = new PosTransaction(); posTransaction.CreateTimeStamp = DateTime.Now; posTransaction.TransactionCode = Utils.RandomNumbers(5); posTransaction.MemberID = 1; // member always walk in as default; posTransaction.AmountTender = 0; posTransaction.UserID = CurrentUser.UserID; uow.PosTransaction.Add(posTransaction); uow.Complete(); return(new PosTransactionModel { PosTransactionID = posTransaction.POSTransactionID, TransactionCode = posTransaction.TransactionCode }); } }
public void DoTest() { var transactionRequest = new BuildTransactionRequest() { FeeAmount = "0.01", // Change this to the address that should receive the funds. OpReturnData = "PLv2NAsyn22cNbk5veopWCkypaN6DBR27L", AccountName = "account 0", AllowUnconfirmed = true, Recipients = new List <RecipientModel> { new RecipientModel { DestinationAddress = "2MyKFLbvhSouDYeAHhxsj9a5A4oV71j7SPR", Amount = "1.1" } }, Password = "******", WalletName = "test" }; WalletBuildTransactionModel model = Post <BuildTransactionRequest, WalletBuildTransactionModel>( "http://127.0.0.1:38221/api/wallet/build-transaction", transactionRequest); var transaction = new PosTransaction(model.Hex); var reader = new OpReturnDataReader(this.loggerFactory, Networks.Stratis.Testnet()); var extractor = new DepositExtractor(this.loggerFactory, this.federationGatewaySettings, reader, this.fullNode); IDeposit deposit = extractor.ExtractDepositFromTransaction(transaction, 2, 1); Assert.NotNull(deposit); Assert.Equal(transaction.GetHash(), deposit.Id); Assert.Equal(transactionRequest.OpReturnData, deposit.TargetAddress); Assert.Equal(Money.Parse(transactionRequest.Recipients[0].Amount), deposit.Amount); Assert.Equal((uint256)1, deposit.BlockHash); Assert.Equal(2, deposit.BlockNumber); // Post the transaction var sendRequest = new SendTransactionRequest() { Hex = model.Hex }; WalletSendTransactionModel model2 = Post <SendTransactionRequest, WalletSendTransactionModel>( "http://127.0.0.1:38221/api/wallet/send-transaction", sendRequest); }
/// <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; } }
/// <inheritdoc /> /// <exception cref="ConsensusErrors.BadColdstakeInputs">Thrown if the input scriptPubKeys mismatch.</exception> /// <exception cref="ConsensusErrors.BadColdstakeOutputs">Thrown if the output scriptPubKeys mismatch.</exception> /// <exception cref="ConsensusErrors.BadColdstakeAmount">Thrown if the total input is smaller or equal than the sum of outputs.</exception> public override Task RunAsync(RuleContext context) { // Get the second transaction so that we can confirm whether it is a cold coin stake transaction. Block block = context.ValidationContext.BlockToValidate; PosTransaction coinstakeTransaction = ((block.Transactions.Count >= 2) ? block.Transactions[1] : null) as PosTransaction; // If there is no coinstake transaction or it is not a cold coin stake transaction then this rule is not required. // The "IsColdCoinStake" flag will only be set in the OP_CHECKCOLDSTAKEVERIFY if ScriptFlags in DeploymentFlags has "CheckColdStakeVerify" set. if (!(coinstakeTransaction?.IsColdCoinStake ?? false)) { this.Logger.LogTrace("(-)[SKIP_COLDSTAKE_RULE]"); return(Task.CompletedTask); } var posRuleContext = context as PosRuleContext; // Verify that all inputs map to incoming outputs. if (coinstakeTransaction.Inputs.Any(i => !posRuleContext.CoinStakePrevOutputs.ContainsKey(i))) { this.Logger.LogTrace("(-)[COLDSTAKE_INPUTS_WITHOUT_OUTPUTS]"); ConsensusErrors.BadColdstakeInputs.Throw(); } // Check that ScriptPubKeys of all inputs of this transaction are the same. If they are not, the script fails. // Due to this being a coinstake transaction we know it will have at least one input. Script scriptPubKey = posRuleContext.CoinStakePrevOutputs[coinstakeTransaction.Inputs[0]].ScriptPubKey; for (int i = 1; i < coinstakeTransaction.Inputs.Count; i++) { if (scriptPubKey != posRuleContext.CoinStakePrevOutputs[coinstakeTransaction.Inputs[i]]?.ScriptPubKey) { this.Logger.LogTrace("(-)[BAD_COLDSTAKE_INPUTS]"); ConsensusErrors.BadColdstakeInputs.Throw(); } } // Check that the second output is a special output for presenting the public key with an OP_RETURN and that // the output value is zero. Checking for the OP_RETURN ensures that the PosBlockSignatureRule won't match the // PayToPubKey template. This will ensure that an attacker won't use a PayToPubKey output here to spend our // cold staking balance (using the hot wallet key) to an address other then our special scriptpubkey. if ((coinstakeTransaction.Outputs[1].ScriptPubKey.ToOps().FirstOrDefault()?.Code != OpcodeType.OP_RETURN) || (coinstakeTransaction.Outputs[1].Value != Money.Zero)) { this.Logger.LogTrace("(-)[MISSING_COLDSTAKE_PUBKEY_OUTPUT]"); ConsensusErrors.BadColdstakeOutputs.Throw(); } // Check that ScriptPubKeys of all outputs of this transaction, except for the marker output (a special first // output of each coinstake transaction) and the pubkey output (an optional special second output that contains // public key in coinstake transaction), are the same as ScriptPubKeys of the inputs. If they are not, the script fails. bool cirrusScriptFlagSeen = false; for (int i = 2; i < coinstakeTransaction.Outputs.Count; i++) { if (scriptPubKey != coinstakeTransaction.Outputs[i].ScriptPubKey) { // We have to make allowance for the fact that one of the cold stake outputs will be the Cirrus reward payment script. // So do not throw a consensus error for those unless more than one appears in the transaction. // We do not need to check the reward amount, because that is done elsewhere. if (coinstakeTransaction.Outputs[i].ScriptPubKey == StraxCoinstakeRule.CirrusRewardScript && !cirrusScriptFlagSeen) { cirrusScriptFlagSeen = true; continue; } this.Logger.LogTrace("(-)[BAD_COLDSTAKE_OUTPUTS]"); ConsensusErrors.BadColdstakeOutputs.Throw(); } } // Check that the sum of values of all inputs is smaller or equal to the sum of values of all outputs. If this does // not hold, the script fails. This prevents the hot balance from being reduced. if (posRuleContext.TotalCoinStakeValueIn > coinstakeTransaction.TotalOut) { this.Logger.LogTrace("(-)[COLDSTAKE_INPUTS_EXCEED_OUTPUTS]"); ConsensusErrors.BadColdstakeAmount.Throw(); } this.Logger.LogTrace("(-)"); return(Task.CompletedTask); }
/// <summary> /// Ctor. /// </summary> /// <param name="context">Context of the gift card form</param> /// <param name="posTransaction">Transaction object.</param> public GiftCardController(ContextType context, PosTransaction posTransaction) : this(context, posTransaction, null) { }
/// <summary> /// Checks for price check. /// </summary> /// <param name="posTransaction"></param> public frmPriceCheck(IPosTransaction posTransaction) : this() { this.posTransaction = (PosTransaction)posTransaction; }