public EditNewPayment(Operation operation, BasePaymentType?paymentType = null, bool printFiscal = false) { this.operation = operation; if (this.operation.Id <= 0) { this.operation.Payments.Clear(); } total = Currency.Round(operation.TotalPlusVAT, operation.TotalsPriceType); this.paymentType = paymentType ?? BusinessDomain.AppConfiguration.LastPaymentMethod; paymentWidget = new PaymentWidget(payments, operation.TotalsPriceType); paymentWidget.PaymentDeleted += (sender, e) => RecalculateChange(paymentWidget.Received); paymentWidget.ValueChanged += (sender, e) => RecalculateChange(e.Value); Initialize(); ArrangePaymentWidget(); chkChangeIsReturned.Visible = operation.UseChange; ICashReceiptPrinterController cashReceiptPrinter = BusinessDomain.DeviceManager.CashReceiptPrinterDriver; object hasFiscalMemory; chkPrintCashReceipt.Sensitive = cashReceiptPrinter != null && operation.AllowFiscal && (operation.Id < 0 || (cashReceiptPrinter.GetAttributes().TryGetValue(DriverBase.HAS_FISCAL_MEMORY, out hasFiscalMemory) && (bool)hasFiscalMemory == false)); chkPrintCashReceipt.Visible = BusinessDomain.WorkflowManager.AllowSaleWithoutReceipt; chkPrintCashReceipt.Active = !BusinessDomain.WorkflowManager.AllowSaleWithoutReceipt || (chkPrintCashReceipt.Sensitive && printFiscal); chkPrintDocument.Sensitive = BusinessDomain.AppConfiguration.IsPrintingAvailable(); }
public EditNewAdvancePayment(Partner partner, BasePaymentType?paymentType = null, bool alwaysReceive = false) { this.partner = partner; this.alwaysReceive = alwaysReceive; this.paymentType = paymentType ?? BusinessDomain.AppConfiguration.LastPaymentMethod; paymentWidget = new PaymentWidget(payments, PriceType.SaleTotal); Initialize(); debt = Partner.GetDebt(partner.Id); lblDebtValue.SetText(Currency.ToString(Math.Abs(debt))); lblDebt.SetText(debt < 0 ? Translator.GetString("We owe:") : Translator.GetString("Debt:")); if (Partner.GetDuePayments(partner.Id).Length > 0) { paymentWidget.Received = Math.Abs(debt); } else { this.alwaysReceive = true; } ArrangePaymentWidget(); chkPrintCashReceipt.Sensitive = BusinessDomain.AppConfiguration.CashReceiptPrinterEnabled; }
public void SetSelectedPaymentType(BasePaymentType paymentType) { bool includePrinterPayments = false; DeviceManagerBase dManager = BusinessDomain.DeviceManager; if (dManager.CashReceiptPrinterConnected && dManager.CashReceiptPrinterDriver.SupportedCommands.Contains(DeviceCommands.GetPaymentName)) { includePrinterPayments = true; } List <KeyValuePair <long, string> > paymentPairs = new List <KeyValuePair <long, string> > (); foreach (PaymentType paymentMethod in PaymentType.GetAll()) { string paymentName; if (includePrinterPayments) { dManager.CashReceiptPrinterDriver.GetPaymentName(paymentMethod.BaseType, out paymentName); paymentName = string.IsNullOrEmpty(paymentName) ? paymentMethod.Name : string.Format("{0} ({1})", paymentMethod.Name, paymentName); } else { paymentName = paymentMethod.Name; } paymentPairs.Add(new KeyValuePair <long, string> (paymentMethod.Id, paymentName)); } cboPaymentMethod.Load(paymentPairs, "Key", "Value", (long)paymentType); }
public EditNewAdvancePayment(Payment payment) : this(new Partner { Id = payment.PartnerId, Name = payment.PartnerName }) { paymentToEdit = payment; paymentType = payment.Type.BaseType; hspChangeButtons.Visible = false; paymentWidget.SetSelectedPaymentType(paymentType); paymentWidget.Received = payment.Quantity; paymentWidget.TablePayments.Remove(btnAdd); paymentWidget.TablePayments.NColumns--; }
protected virtual string PaymentTypeToString(BasePaymentType paymentMethod) { switch (paymentMethod) { case BasePaymentType.BankTransfer: return("N"); case BasePaymentType.Card: return("D"); case BasePaymentType.Coupon: return("C"); default: return("P"); } }
public virtual void Payment(double amountPaid, BasePaymentType paymentMethod, string info) { StringBuilder res = new StringBuilder(); res.Append(info.Wrap(totalNoteCharsPerLine)); res.Append('\t'); res.Append(PaymentTypeToString(paymentMethod)); NumberFormatInfo numberFormat = new NumberFormatInfo { NumberDecimalSeparator = priceDecimalSeparator, NumberGroupSeparator = string.Empty }; res.Append(amountPaid.ToString("G9", numberFormat)); SendMessage(CommandCodes.Payment, defaultEnc.GetBytes(res.ToString())); balance -= amountPaid; }
private void Load() { ListStore listStore = new ListStore(typeof(bool), typeof(string), typeof(BasePaymentType)); for (int i = (int)BasePaymentType.Cash; i <= (int)BasePaymentType.Advance; i++) { BasePaymentType paymentType = (BasePaymentType)i; listStore.AppendValues(selected.Contains(paymentType), PaymentType.GetBasePaymentTypeName(paymentType), paymentType); } CellRendererToggle cellRendererToggle = new CellRendererToggle { Activatable = true }; cellRendererToggle.Toggled += (sender, e) => { TreeIter row; listStore.GetIter(out row, new TreePath(e.Path)); bool value = !(bool)listStore.GetValue(row, 0); BasePaymentType paymentType = (BasePaymentType)listStore.GetValue(row, 2); if (value) { selected.Add(paymentType); } else { selected.Remove(paymentType); } listStore.SetValue(row, 0, value); }; treeView.AppendColumn(string.Empty, cellRendererToggle, "active", 0); treeView.AppendColumn(string.Empty, new CellRendererText(), "text", 1); treeView.AppendColumn(string.Empty, new CellRendererText(), "text", 2).Visible = false; treeView.Model = listStore; }
public static string GetBasePaymentTypeName(BasePaymentType type) { switch (type) { case BasePaymentType.Cash: return(Translator.GetString("In cash")); case BasePaymentType.BankTransfer: return(Translator.GetString("To bank account")); case BasePaymentType.Card: return(Translator.GetString("By card")); case BasePaymentType.Coupon: return(Translator.GetString("Other")); case BasePaymentType.Advance: return(Translator.GetString("Advance Payment")); default: throw new ArgumentOutOfRangeException("type"); } }
public override void Payment(double amountPaid, BasePaymentType paymentMethod) { Payment(amountPaid, paymentMethod, string.Empty); }
public virtual void Payment(double amountPaid, BasePaymentType paymentMethod) { throw new NotSupportedException(); }
public virtual void GetPaymentName(BasePaymentType method, out string value) { throw new NotSupportedException(); }