public void Show(IAdjustment adjustment) { if ((mode & Target.Customer) == Target.Customer) { customerForm.Show(adjustment); } }
public void ShowCorrect(IAdjustment adjustment, bool isSubTotalAdj) { if ((mode & Target.Customer) == Target.Customer) { customerForm.ShowCorrect(adjustment); } }
/// <summary> /// Edit the adjustment. /// </summary> /// <param name="adjustment"> The adjustment. </param> public void AdjustmentMenuEdit(IAdjustment adjustment) { if (adjustment is null) { this.DrawLayout.Hide(); return; } if (adjustment.PageVisibility == Visibility.Collapsed) { this.DrawLayout.Hide(); return; } { this.AdjustmentFlyout.Hide(); this.LayerFlyout.Hide(); } IAdjustmentPage adjustmentPage = Retouch_Photo2.Adjustments.XML.CreateAdjustmentPage(typeof(BrightnessPage), adjustment.Type); if (this.SelectionViewModel.SelectionLayerage is Layerage layerage) { ILayer layer = layerage.Self; int index = layer.Filter.Adjustments.IndexOf(adjustment); adjustmentPage.Index = index; adjustmentPage.Follow(); } this.DrawLayout.ShowWritable(adjustmentPage.Icon, adjustmentPage.Title, adjustmentPage.Self); // Delegat }
public void ShowCorrect(IAdjustment adjustment) { try { if (adjustment.Method == (AdjustmentType.PercentDiscount) || (adjustment.Method == AdjustmentType.PercentFee)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.CORRECTION, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C}", Common.PosMessage.CORRECTION, new Number(adjustment.NetAmount)); } if (!(adjustment.Target is ISalesDocument)) { ShowItems(); } UpdateSubtotal(); } catch (FormatException e) { EZLogger.Log.Error("Display error. {0}", e.Message); } }
public static List <String> Format(IAdjustment ai) { currentLines = new List <string>(); if (ai.Target is ISalesDocument) { if (CurrentSettings.GetProgramOption(Setting.PrintSubtTotal) == PosConfiguration.OFF) { FormatSubTotal(FiscalPrinter.Document, true); } } switch (ai.Method) { case AdjustmentType.PercentDiscount: case AdjustmentType.PercentFee: FormatLine(new Location(productNameLocation.X, currentLines.Count + 1), ai.Label); FormatLine(new Location(productNameLocation.X + 12, currentLines.Count), String.Format("%{0}", ai.RequestValue.ToString().PadLeft(2, ' '))); FormatLine(new Location(productAmountLocation.X - maxAmountWidth, currentLines.Count), String.Format("{0," + maxAmountWidth + "}", "*" + new Number(ai.NetAmount).ToString("C"))); break; case AdjustmentType.Discount: case AdjustmentType.Fee: FormatLine(new Location(productNameLocation.X, currentLines.Count + 1), ai.Label); FormatLine(new Location(productAmountLocation.X - maxAmountWidth, currentLines.Count), String.Format("{0," + maxAmountWidth + "}", "*" + new Number(ai.NetAmount).ToString("C"))); break; } return(currentLines); }
public Decimal Adjust(IAdjustment a) { //TODO: Necessary business rules to check if adjustment is valid Adjustment adjustment = (Adjustment)a; if (adjustment.Target != this) { adjustment = new Adjustment(this, adjustment.Method, adjustment.RequestValue, adjustment.AuthorizingCashierId); } if (adjustment.NetAmount == 0) { return(0); } if (TotalAmount + adjustment.NetAmount < 0) { throw new NegativeResultException(); } adjustments.Add(adjustment); Decimal oldAmount = TotalAmount; totalAmount = TotalAmount + adjustment.NetAmount; //TODO unit price 2 basamaga yuvarlanmali mi? unitPrice = totalAmount / quantity; if (OnTotalAmountUpdated != null) { OnTotalAmountUpdated(this, new PriceUpdateEventArgs(oldAmount, totalAmount)); } //gerekesiz tekrar gibi gozukuyor ama degil total - Total farki ikisi de lazim unitPrice = TotalAmount / quantity; return(adjustment.NetAmount); }
public Action(ActionEnum type, int index, IAdjustment adjustmentAfter, IAdjustment adjustmentBefore = null) { this._type = type; this._adjustmentAfter = adjustmentAfter; this._adjustmentBefore = adjustmentBefore; this._index = index; }
internal void Show(IAdjustment adjustment) { try { if (adjustment.Target is IFiscalItem) { if (adjustment.Method == (AdjustmentType.PercentDiscount)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.PRODUCT_PERCENT_DISCOUNT, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.PercentFee) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.PRODUCT_PERCENT_FEE, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.Discount) { Show("{0}\n \t{1:C} ", Common.PosMessage.PRODUCT_PRICE_DISCOUNT, new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C} ", Common.PosMessage.PRODUCT_PRICE_FEE, new Number(adjustment.NetAmount)); } } else if (adjustment.Target is ISalesDocument) { if (adjustment.Method == (AdjustmentType.PercentDiscount)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.SUBTOTAL_PERCENT_DISCOUNT, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.PercentFee) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.SUBTOTAL_PERCENT_FEE, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.Discount) { Show("{0}\n \t{1:C}", Common.PosMessage.SUBTOTAL_PRICE_DISCOUNT, new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C}", Common.PosMessage.SUBTOTAL_PRICE_FEE, new Number(adjustment.NetAmount)); } } } catch (FormatException) { } }
public void ShowCorrect(IAdjustment ai, bool isSubTotalAdj) { primaryDisplay.ShowCorrect(ai, isSubTotalAdj); foreach (IDisplay d in auxilaryDisplays) { d.ShowCorrect(ai, isSubTotalAdj); } }
public void Show(IAdjustment ai) { primaryDisplay.Show(ai); foreach (IDisplay d in auxilaryDisplays) { d.Show(ai); } }
public static Polyface IsHasAdjustment <T>(this Polyface root, IAdjustment <T> adjustment) { Condition.Requires(root).IsNotNull(); var composited = new HasAdjustment <T>(adjustment); root.Is(composited); return(root); }
public DefaultStrategy(String strategyName, StrategyBaseInput input) { this.StrategyName = strategyName; this.Input = input; this._allocBase = new StaticAlloc(); this._opSet = new OperationSet(); this._adjustment = new DummyAdjustment(); }
public void AddAdjustment_Static(int key, IAdjustment nextAdj) { ICreditPolicy policy = new CreditPolicyStatic(1); this._adjustment = new KrxCreditDepositRateAdjustment(policy); this._adjustment.SetKey(key); this._adjustment.SetNextAdjustment(nextAdj); this._opSet.Add(new OperationRow(key, "Static", Operation.Multiply, true)); }
public void AddAdjustment_KrxCreditDepositRate(int key, IAdjustment nextAdj, double weight) { //ICreditPolicy policy = new CreditPolicyStatic(); ICreditPolicy policy = new CreditPolicyWithMA(weight); this._adjustment = new KrxCreditDepositRateAdjustment(policy); this._adjustment.SetKey(key); this._adjustment.SetNextAdjustment(nextAdj); this._opSet.Add(new OperationRow(key, "KrxCreditRate", Operation.Multiply, true)); }
public void AddAdjustment(IAdjustment adj, String description) { int caseNumber = _curCaseNumberGenerator++; adj.SetKey(caseNumber); adj.SetNextAdjustment(null); _adjs.Add(adj); _descriptions.Add(caseNumber, description); }
public void AddAdjustment_WithMA(int key, IAdjustment nextAdj, double weight) { ICreditPolicy policy = new CreditPolicyWithMA(weight); this._adjustment = new KrxCreditDepositRateAdjustment(policy); this._adjustment.SetKey(key); this._adjustment.SetNextAdjustment(nextAdj); this._opSet.Add(new OperationRow(key, String.Format("WithMA({0:n2})", weight), Operation.Multiply, true)); }
public void AddAdjustment(IAdjustment adj, String description) { int key = _keyGenerator++; IAdjustment nextAdj = this._adjustment; this._adjustment = adj; this._adjustment.SetKey(key); this._adjustment.SetNextAdjustment(nextAdj); this._opSet.Add(new OperationRow(key, description, Operation.Multiply, true)); }
/// <summary> /// Loads a <see cref="IAdjustment"/> from an XElement. /// </summary> /// <param name="element"> The source XElement. </param> /// <returns> The loaded <see cref="IAdjustment"/>. </returns> public static IAdjustment LoadIAdjustment(XElement element) { // Load string type2 = element.Attribute("Type") is XAttribute type ? type.Value : null; IAdjustment adjustment = XML.CreateAdjustment(type2); { adjustment.Load(element); } return(adjustment); }
public void ShowCorrect(IAdjustment ai, bool isSubTotalAdj) { if ((mode & Target.Cashier) == Target.Cashier) { cashierDisplay.ShowCorrect(ai, isSubTotalAdj); } if ((mode & Target.Customer) == Target.Customer) { customerDisplay.ShowCorrect(ai, isSubTotalAdj); } }
public void Show(IAdjustment ai) { if ((mode & Target.Cashier) == Target.Cashier) { cashierDisplay.Show(ai); } if ((mode & Target.Customer) == Target.Customer) { customerDisplay.Show(ai); } }
/// <summary> /// Saves the entire <see cref="IAdjustment"/> to a XElement. /// </summary> /// <param name="elementName"> The element name. </param> /// <param name="adjustment"> The destination <see cref="IAdjustment"/>. </param> public static XElement SaveIAdjustment(string elementName, IAdjustment adjustment) { XElement element = new XElement(elementName); element.Add(new XAttribute("Type", adjustment.Type)); { // SaveWith adjustment.SaveWith(element); } return(element); }
public StaticAdjustment( IAdjustment nextAdjustment, double kospiAdjustment, double bondAdjustment, double dollarAdjustment) { this._nextAdjustment = nextAdjustment; this._kospiAdjustment = kospiAdjustment; this._bondAdjustment = bondAdjustment; this._dollarAdjustment = dollarAdjustment; }
public void Build() { this._allocBase = new StaticAlloc(); this._opSet = new OperationSet(); int key = 0; this._adjustment = new DummyAdjustment(); AddAdjustment_Static(key++, this._adjustment); AddAdjustment_WithMA(key++, this._adjustment, 1); }
public IImage Edit(Tool toolType, IAdjustment adjustment) { int index = FindByType(toolType); if (index == -1) { throw new Exception("Tool not present."); } _history.addAction(new Action(ActionEnum.Edit, index, adjustment, _procedure[index])); return(Replace(index, adjustment)); }
public IPrinterResponse Print(IAdjustment ai) { guiDocument.AddLines(Formatter.Format(ai)); if (ai.Method == AdjustmentType.Discount || ai.Method == AdjustmentType.PercentDiscount) { WriteCurrentLog("Discount=" + Math.Abs(ai.NetAmount)); } else { WriteCurrentLog("Fee=" + ai.NetAmount); } return(toResponse); }
public IImage Add(IAdjustment adjustment) { if (_toolMap.ContainsKey(adjustment.ToolType)) { throw new Exception("Tool already in use."); } int index = _nextIndex; IImage image = Insert(index, adjustment); _history.addAction(new Action(ActionEnum.Add, index, adjustment)); return(image); }
public List <String> FormatVoid(IAdjustment ai) { int currentLine = GetCurrentLine(2); if (ai.Target is ISalesDocument) { if (CurrentSettings.GetProgramOption(Setting.PrintSubtTotal) == PosConfiguration.OFF) { FormatSubTotal(FiscalPrinter.Document); } } FormatLine(new Location(productNameLocation.X, CurrentPage.PageLines.Count + 1), PosMessage.CORRECTION); FormatLine(new Location(productAmountLocation.X - maxAmountWidth, CurrentPage.PageLines.Count), String.Format("{0," + maxAmountWidth + "}", "*" + new Number(-1 * ai.NetAmount).ToString("C"))); return(CurrentPage.PageLines.GetRange(currentLine, CurrentPage.PageLines.Count - currentLine)); }
public void Show(IAdjustment adjustment) { if ((mode & Target.Cashier) == Target.Cashier) { touchForm.Show(adjustment); } if (customerForm != null && (mode & Target.Customer) == Target.Customer) { customerForm.Show(adjustment); } if (external != null) { external.Show(adjustment); } }
public void ShowCorrect(IAdjustment adjustment, bool isSubTotalAdj) { if ((mode & Target.Cashier) == Target.Cashier) { touchForm.ShowCorrect(adjustment, isSubTotalAdj); } if (customerForm != null && (mode & Target.Customer) == Target.Customer) { customerForm.ShowCorrect(adjustment); } if (external != null) { external.ShowCorrect(adjustment); } }
/// <summary> /// Loads a <see cref="IAdjustment"/> from an XElement. /// </summary> /// <param name="element"> The source XElement. </param> /// <returns> The loaded <see cref="IAdjustment"/>. </returns> public static IAdjustment LoadIAdjustment(XElement element) { if (element.Attribute("Type") is XAttribute type2) { string type = type2.Value; //Load IAdjustment adjustment = XML.CreateAdjustment(type); { adjustment.Load(element); } return(adjustment); } else { return(new GrayAdjustment()); } }
internal void ShowCorrect(IAdjustment adjustment) { try { if (adjustment.Method == (AdjustmentType.PercentDiscount) || (adjustment.Method == AdjustmentType.PercentFee)) { Show("{0}\n{1:P}\t{2:C} ", Common.PosMessage.CORRECTION, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C} ", Common.PosMessage.CORRECTION, new Number(adjustment.NetAmount)); } } catch (FormatException) { } }
private IImage Replace(int index, IAdjustment adjustment) { if (index < 0 || index > _nextIndex) { throw new Exception("Invalid index"); } if (adjustment == null) { throw new Exception("Adjustment reference is null."); } if (_procedure[index].ToolType != adjustment.ToolType) { throw new Exception("Adjustments tool type isn't the same."); } adjustment.StartImage = _procedure[index].StartImage; _procedure[index] = adjustment; return(ProcessImage(index)); }
public void ShowCorrect(IAdjustment adjustment, bool isSubTotalAdj) { try { if (adjustment.Method == (AdjustmentType.PercentDiscount) || (adjustment.Method == AdjustmentType.PercentFee)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.CORRECTION, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C}", Common.PosMessage.CORRECTION, new Number(adjustment.NetAmount)); } } catch (FormatException e) { EZLogger.Log.Error("Display error. {0}", e.Message); } }
/// <summary> /// For an application of a payment to an invoice, calculates the /// value of the <see cref="ARAdjust.CuryDocBal"/> field, which is /// the remaining balance of the applied payment. /// </summary> public static void CalculateApplicationDocumentBalance( PXCache cache, ARPayment payment, IAdjustment application, CurrencyInfo paymentCurrencyInfo, CurrencyInfo invoiceCurrencyInfo) { decimal CuryDocBal = CalculateApplicationDocumentBalance( cache, paymentCurrencyInfo, invoiceCurrencyInfo, payment.DocBal, payment.CuryDocBal); if (application == null) { return; } if (application.Released == false) { if (application.CuryAdjdAmt > CuryDocBal) { // TODO: if reconsidered need to calculate RGOL. // - application.CuryDocBal = CuryDocBal; application.CuryAdjdAmt = 0m; } else { application.CuryDocBal = CuryDocBal - application.CuryAdjdAmt; } } else { application.CuryDocBal = CuryDocBal; } }
private IImage Insert(int index, IAdjustment adjustment) { if (adjustment == null) { throw new Exception("Adjustment reference is null."); } if (index < 0 || index > _nextIndex) { throw new Exception("Invalid index."); } for (int i = _nextIndex; i > index; i--) { _procedure[i] = _procedure[i - 1]; } _procedure[index] = adjustment; _toolMap.Add(adjustment.ToolType, index); _nextIndex++; _procedure[index].StartImage = (index > 0) ? _procedure[index - 1].EndImage : _baseImage; return(ProcessImage(index)); }
public static AdjRateDatum Calculate( int key, AdjRateDatum mine, IAdjustment next, OperationSet opSet, DateTime targetDate, MarketDataSet data) { if (next == null) { return mine; } OperationRow opData = opSet.GetData(key); Boolean on = opData.On; AdjRateDatum others = next.CalculateAssetWeight(opSet, targetDate, data); if (on) { Operation op = opData.Op; if (op == Operation.Multiply) { AdjRateDatum ret = AdjUtil.Multiply(mine, others); return ret; } else { Trace.Assert(false); return others; } } else { return others; } }
/// <summary> /// - Checks cashier discount and fee authorization limit /// </summary> /// <param name="adjustment"> /// - Authorization adjustment /// </param> /// <returns> /// - bool value whether cashier has authorization or not. /// </returns> public bool IsAuthorisedFor(IAdjustment adjustment) { Decimal alreadyAdjustedPrice = adjustment.Target.TotalAmount - adjustment.Target.ListedAmount; Decimal absolutePercentAdjustment = 0; bool response = false; switch (adjustment.Method) { case AdjustmentType.Discount: decimal netDiscount = -(alreadyAdjustedPrice + adjustment.NetAmount); absolutePercentAdjustment = alreadyAdjustedPrice * -100m / adjustment.Target.ListedAmount + adjustment.NetAmount * -100m / adjustment.Target.ListedAmount; response = (netDiscount <= this.priceAdjustmentLimit && absolutePercentAdjustment <= this.percentAdjustmentLimit); break; case AdjustmentType.Fee: if (this.priceAdjustmentLimit != 100) { response = (alreadyAdjustedPrice + adjustment.NetAmount <= this.priceAdjustmentLimit) && ((alreadyAdjustedPrice + adjustment.NetAmount) * 100m / adjustment.Target.ListedAmount <= this.percentAdjustmentLimit); } else { response = true; } break; case AdjustmentType.PercentDiscount: response = this.percentAdjustmentLimit >= adjustment.RequestValue; //absolutePercentAdjustment = (alreadyAdjustedPrice * -100m / adjustment.Target.ListedAmount); //response = (absolutePercentAdjustment + adjustment.RequestValue <= this.percentAdjustmentLimit); break; case AdjustmentType.PercentFee: if (this.percentAdjustmentLimit != 100) { if (adjustment.Target.ListedAmount == 0) { absolutePercentAdjustment = 100; } else { absolutePercentAdjustment = (alreadyAdjustedPrice * 100m / adjustment.Target.ListedAmount); } response = (absolutePercentAdjustment + adjustment.RequestValue <= this.percentAdjustmentLimit); } else { response = true; } break; default: break; } if (!response) { EZLogger.Log.Info("Net adjustment of {0:C} on {1} not authorised for Cashier Id: {2}", adjustment.NetAmount, adjustment.Target.GetType(), this.Id); } return(response); }
public void SetNextAdjustment(IAdjustment nextAdjustment) { this._nextAdjustment = nextAdjustment; }
public HasAdjustment(IAdjustment <T> Adjustment) { Condition.Requires(Adjustment).IsNotNull(); this.Adjustment = Adjustment; }
public void SetNextAdjustment(IAdjustment nextAdjustment) { _nextAdj = nextAdjustment; }
public void SetNextAdjustment(IAdjustment nextAdjustment) { }
public void Show(IAdjustment adjustment) { try { if (adjustment.Target is IFiscalItem) { if (adjustment.Method == (AdjustmentType.PercentDiscount)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.PRODUCT_PERCENT_DISCOUNT, new Number(adjustment.RequestValue / 100), adjustment.NetAmount); } else if (adjustment.Method == AdjustmentType.PercentFee) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.PRODUCT_PERCENT_FEE, new Number(adjustment.RequestValue / 100), adjustment.NetAmount); } else if (adjustment.Method == AdjustmentType.Discount) { Show("{0}\n \t{1:C}", Common.PosMessage.PRODUCT_PRICE_DISCOUNT, new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C}", Common.PosMessage.PRODUCT_PRICE_FEE, new Number(adjustment.NetAmount)); } SetLastItemAdjustment(adjustment.NetAmount); } else if (adjustment.Target is ISalesDocument) { if (adjustment.Method == (AdjustmentType.PercentDiscount)) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.SUBTOTAL_PERCENT_DISCOUNT, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.PercentFee) { Show("{0}\n{1:P}\t{2:C}", Common.PosMessage.SUBTOTAL_PERCENT_FEE, new Number(adjustment.RequestValue / 100), new Number(adjustment.NetAmount)); } else if (adjustment.Method == AdjustmentType.Discount) { Show("{0}\n \t{1:C}", Common.PosMessage.SUBTOTAL_PRICE_DISCOUNT, new Number(adjustment.NetAmount)); } else { Show("{0}\n \t{1:C}", Common.PosMessage.SUBTOTAL_PRICE_FEE, new Number(adjustment.NetAmount)); } SetSubtotalAdjustment(subtotalAdjustments + adjustment.NetAmount); } else { throw new InvalidProgramException("Adjustment target is incorrectly set"); } UpdateSubtotal(); } catch (FormatException e) { Display.Log.Error("Display error. {0}", e.Message); } }