protected virtual bool SaveDocument(FinalizeAction action = FinalizeAction.CommitDocument) { if (sale != null && chkPrintCashReceipt.Active) { action |= FinalizeAction.PrintCashReceipt | FinalizeAction.CollectSaleData; if (sale.IsVATExempt || (sale.VAT.IsZero() && sale.Total > 0)) { if (VATGroup.GetExemptGroup() == null) { MessageError.ShowDialog(string.Format(Translator.GetString("To print a receipt for a document without VAT you need to define a 0% VAT group in {0} and in the receipt printer if necessary!"), DataHelper.ProductName)); return(false); } } } HardwareErrorResponse res; do { res.Retry = false; try { BusinessDomain.DeviceManager.FinalizeOperation(new FinalizeOperationOptions { Sale = sale, Document = document, Action = action }); } catch (InvoiceNumberInUseException ex) { txtNumber.SelectRegion(0, txtNumber.Text.Length); MessageError.ShowDialog( Translator.GetString("The entered document number already exists!"), ErrorSeverity.Error, ex); return(false); } catch (HardwareErrorException ex) { res = FormHelper.HandleHardwareError(ex); if (!res.Retry) { dlgEditNewDocument.Respond(ResponseType.Cancel); return(false); } } catch (InsufficientItemAvailabilityException ex) { MessageError.ShowDialog( string.Format(Translator.GetString("The document cannot be saved due to insufficient quantities of item \"{0}\"."), ex.ItemName), ErrorSeverity.Warning, ex); dlgEditNewDocument.Respond(ResponseType.Cancel); return(false); } catch (Exception ex) { MessageError.ShowDialog( Translator.GetString("An error occurred while saving the document!"), ErrorSeverity.Error, ex); dlgEditNewDocument.Respond(ResponseType.Cancel); return(false); } } while (res.Retry); if (sale != null) { document.Signature = sale.Signature; } return(true); }
/// <summary> /// Action is invoked after all the rules are applied. /// </summary> public Faker <T> FinishWith(Action <Faker, T> action) { var rule = new FinalizeAction <T> { Action = action, RuleSet = currentRuleSet }; this.FinalizeActions.Add(currentRuleSet, rule); return(this); }
/// <summary> /// A finalizing action rule applied to <typeparamref name="T"/> after all the rules /// are executed. /// </summary> public virtual Faker <T> FinishWith(Action <Faker, T> action) { var rule = new FinalizeAction <T> { Action = action, RuleSet = currentRuleSet }; this.FinalizeActions[currentRuleSet] = rule; return(this); }
public void Mark(bool mark, FinalizeAction action, IEnumerable <TileData> subDatas = null) /// Adds generate mark if data present { if (dict.TryGetValue(action, out PerTypeData perTypeData)) { perTypeData.markRe = mark; } if (subDatas != null) { foreach (TileData subData in subDatas) { subData.finalize.Mark(mark, action, subDatas: subData.subDatas); } } }
public int GetTypeCount(FinalizeAction action, IEnumerable <TileData> subDatas = null) { int count = 0; if (dict.TryGetValue(action, out PerTypeData perTypeData)) { count += perTypeData.perOutputProducts.Count; } if (subDatas != null) { foreach (TileData subData in subDatas) { count += subData.finalize.GetTypeCount(action, subDatas: subData.subDatas); } } return(count); }
public void Remove(FinalizeAction action, IOutput output, IEnumerable <TileData> subDatas = null) { if (!dict.TryGetValue(action, out PerTypeData perTypeData)) { return; } if (!perTypeData.perOutputProducts.ContainsKey(output)) { return; } perTypeData.perOutputProducts.Remove(output); if (subDatas != null) { foreach (TileData subData in subDatas) { subData.finalize.Remove(action, output, subDatas: subData.subDatas); } } }
private void FillMarkedActions(HashSet <FinalizeAction> actions, IEnumerable <TileData> subDatas = null) { foreach (var kvp in dict) { FinalizeAction action = kvp.Key; PerTypeData perTypeData = kvp.Value; if (perTypeData.markRe && !actions.Contains(action)) { actions.Add(action); } } if (subDatas != null) { foreach (TileData subData in subDatas) { subData.finalize.FillMarkedActions(actions, subDatas: subData.subDatas); } } }
public void Add(FinalizeAction action, IOutput output, object product, MatrixWorld biomeMask) /// Adding new finalize data and marking finalize type to re-generate { PerTypeData perTypeData; if (!dict.TryGetValue(action, out perTypeData)) { perTypeData = new PerTypeData(); dict.Add(action, perTypeData); } if (!perTypeData.perOutputProducts.ContainsKey(output)) { perTypeData.perOutputProducts.Add(output, (product, biomeMask)); } else { perTypeData.perOutputProducts[output] = (product, biomeMask); } perTypeData.markRe = true; }
public bool IsMarked(FinalizeAction action, IEnumerable <TileData> subDatas = null) /// Checks if current type (=finalize action) is marked for re-generate { if (dict.TryGetValue(action, out PerTypeData perTypeData) && perTypeData.markRe) { return(true); } if (subDatas != null) { foreach (TileData subData in subDatas) { if (subData.finalize.IsMarked(action, subDatas:subData.subDatas)) { return(true); } } } return(false); }
protected override bool SaveDocument(FinalizeAction action = FinalizeAction.CommitDocument) { BusinessDomain.FeedbackProvider.TrackEvent("Invoice", action == FinalizeAction.CommitDocument ? "New" : "Reprint"); return(base.SaveDocument(action)); }