public string GenerateCommodity(string exclude = null) { string comm; do { comm = GenerateString(SixGen.Value(), true); }while (comm == exclude || comm == "h" || comm == "m" || comm == "s" || comm == "and" || comm == "any" || comm == "all" || comm == "div" || comm == "false" || comm == "or" || comm == "not" || comm == "true" || comm == "if" || comm == "else"); return(comm); }
public string GenerateXact() { StringBuilder sb = new StringBuilder(); sb.Append(Times.TimesCommon.Current.FormatDate(NextDate, FormatTypeEnum.FMT_WRITTEN)); NextDate = NextDate.AddDays(SixGen.Value()); if (TruthGen.Value()) { sb.Append('='); sb.Append(Times.TimesCommon.Current.FormatDate(NextAuxDate, FormatTypeEnum.FMT_WRITTEN)); NextAuxDate = NextAuxDate.AddDays(SixGen.Value()); } sb.Append(' '); sb.Append(GenerateState()); sb.Append(GenerateCode()); sb.Append(GeneratePayee()); if (TruthGen.Value()) { sb.Append(GenerateNote()); } sb.AppendLine(); int count = ThreeGen.Value() * 2; bool hasMustBalance = false; for (int i = 0; i < count; i++) { if (GeneratePost(sb)) { hasMustBalance = true; } } if (hasMustBalance) { GeneratePost(sb, true); } sb.AppendLine(); return(sb.ToString()); }
public string GenerateCode() { return(String.Format("({0})", GenerateString(SixGen.Value()))); }
public string GenerateAmount(StringBuilder sbOut, Value notThisAmount = null, bool noNegative = false, string exclude = null) { StringBuilder sb = new StringBuilder(); if (TruthGen.Value()) { // commodity goes in front sb.Append(GenerateCommodity(exclude)); if (TruthGen.Value()) { sb.Append(' '); } if (noNegative || TruthGen.Value()) { sb.Append(PosNumberGen.Value().ToString("G15")); } else { sb.Append(NegNumberGen.Value().ToString("G15")); } } else { if (noNegative || TruthGen.Value()) { sb.Append(PosNumberGen.Value().ToString("G15")); } else { sb.Append(NegNumberGen.Value().ToString("G15")); } if (TruthGen.Value()) { sb.Append(' '); } sb.Append(GenerateCommodity(exclude)); } // Possibly generate an annotized commodity, but make it rarer if (!noNegative && ThreeGen.Value() == 1) { if (ThreeGen.Value() == 1) { sb.Append(" {"); GenerateAmount(sb, Value.Empty, true); sb.Append('}'); } if (SixGen.Value() == 1) { sb.Append(" ["); sb.Append(GenerateDate()); sb.Append(']'); } if (SixGen.Value() == 1) { sb.Append(" ("); sb.Append(GenerateString(SixGen.Value())); sb.Append(')'); } } if (!Value.IsNullOrEmpty(notThisAmount) && Value.Get(sb.ToString()).AsAmount.Commodity == notThisAmount.AsAmount.Commodity) { return(String.Empty); } sbOut.Append(sb.ToString()); return(sb.ToString()); }