public void AssignTableToSelectedTicket(int tableId) { if (SelectedTicket == null) { CreateNewTicket(); } var table = _ticketWorkspace.GetTableWithId(tableId); Debug.Assert(SelectedTicket != null); if (!string.IsNullOrEmpty(SelectedTicket.LocationName)) { var oldTable = _ticketWorkspace.GetTicketTable(); if (oldTable.TicketId == SelectedTicket.Id) { oldTable.IsTicketLocked = false; oldTable.TicketId = 0; } } if (table.TicketId > 0 && table.TicketId != SelectedTicket.Id) { MoveTicketItems(SelectedTicket.TicketItems.ToList(), table.TicketId); OpenTicket(table.TicketId); } SelectedTicket.DepartmentId = AppServices.CurrentTerminal.DepartmentId > 0 ? AppServices.CurrentTerminal.DepartmentId : SelectedDepartment.Id; SelectedTicket.LocationName = table.Name; table.TicketId = SelectedTicket.GetRemainingAmount() > 0 ? SelectedTicket.Id : 0; }
private void RoundSelectors() { if (AutoRoundValue != 0 && RemainingTotal > 0) { var amount = 0m; foreach (var selector in Selectors) { var price = selector.Price; var newPrice = decimal.Round(price / AutoRoundValue, MidpointRounding.AwayFromZero) * AutoRoundValue; selector.Price = newPrice; amount += (newPrice * selector.RemainingQuantity); } var mLast = Selectors.Where(x => x.RemainingQuantity > 0).OrderBy(x => x.RemainingPrice).First(); mLast.Price += ((SelectedTicket.GetRemainingAmount() / ExchangeRate) - amount) / mLast.RemainingQuantity; } }
public void UpdateTicketPayment(PaymentType paymentType, ChangePaymentType changeTemplate, decimal paymentDueAmount, decimal paidAmount, decimal tenderedAmount) { var paymentAccount = paymentType.Account ?? _ticketService.GetAccountForPayment(SelectedTicket, paymentType); if (paymentDueAmount > SelectedTicket.GetRemainingAmount() && paidAmount > SelectedTicket.GetRemainingAmount()) { var account = _accountBalances.GetActiveAccount(); if (account != null) { var ticketAmount = SelectedTicket.GetRemainingAmount(); var accountAmount = paidAmount - ticketAmount; var accountBalance = _accountBalances.GetAccountBalance(account.Id); if (accountAmount > accountBalance) { accountAmount = accountBalance; } if (ticketAmount > 0) { _ticketService.AddPayment(SelectedTicket, paymentType, paymentAccount, ticketAmount, tenderedAmount); } if (accountAmount > 0) { _ticketService.AddAccountTransaction(SelectedTicket, account, paymentAccount, accountAmount, ExchangeRate); } } _accountBalances.Refresh(); } else { _ticketService.AddPayment(SelectedTicket, paymentType, paymentAccount, paidAmount, tenderedAmount); if (paidAmount > paymentDueAmount && changeTemplate != null) { _ticketService.AddChangePayment(SelectedTicket, changeTemplate, changeTemplate.Account, paidAmount - paymentDueAmount); } } }
public decimal GetRemainingAmount() { return(SelectedTicket.GetRemainingAmount()); }
public decimal GetRemainingAmount() { return(AccountMode && _accountBalances.ContainsActiveAccount() ? SelectedTicket.GetRemainingAmount() + _accountBalances.GetActiveAccountBalance() - SelectedTicket.TransactionDocument.AccountTransactions.Where(x => x.ContainsAccountId(_accountBalances.GetActiveAccountId())).Sum(y => y.Amount) : SelectedTicket.GetRemainingAmount()); }
private bool CanMakeFastPayment(PaymentType arg) { return(SelectedTicket != Ticket.Empty && SelectedTicket.GetRemainingAmount() > 0); }
private bool CanMakePayment(string arg) { return(SelectedTicket != Ticket.Empty && (SelectedTicket.GetRemainingAmount() > 0 || SelectedTicket.Orders.Count > 0)); }