public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList <TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer) { UnLock(); var order = new Order(); order.UpdateMenuItem(userName, menuItem, taxTemplates, portion, priceTag, 1); order.AccountTransactionTypeId = template.Id; order.WarehouseId = department.WarehouseId; order.DepartmentId = department.Id; TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts()); if (taxTemplates != null) { foreach (var taxTemplate in taxTemplates) { TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id, taxTemplate.AccountTransactionType, GetTicketAccounts()); } } order.UpdateProductTimer(timer); Orders.Add(order); return(order); }
public bool CanMakeAccountTransaction(TicketEntity ticketEntity, AccountTransactionType accountTransactionType, decimal targetBalance) { if (ticketEntity.AccountId == 0) { return(false); } var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId); var typeId = accountTransactionType.TargetAccountTypeId; if (accountTransactionType.DefaultSourceAccountId == 0) { typeId = accountTransactionType.SourceAccountTypeId; } var result = entityType.AccountTypeId == typeId; if (result) { var accountType = _cacheService.GetAccountTypeById(entityType.AccountTypeId); if (accountType.WorkingRule != 0) { if (accountType.WorkingRule == 1 && targetBalance < 0) { return(false); //disallow credit } if (accountType.WorkingRule == 2 && targetBalance > ticketEntity.GetCustomDataAsDecimal(Resources.CreditLimit)) { return(false); //disallow debit } } } return(result); }
public AccountTransactionType Build() { var result = new AccountTransactionType { Id = _id }; return(result); }
public static OrderBuilder Create(AccountTransactionType accountTransactionType, Department department) { var result = Create(); result.WithDepartment(department); result.WithAccountTransactionType(accountTransactionType); return(result); }
public void AddAccountPaymentTransaction(int customerAccount, AccountTransactionType accountTransactionType, decimal amount, DateTime transactionDateTime) { AddAccountTransaction(new AccountTransaction { CustomerAccountId = customerAccount, AccountTransactionType = accountTransactionType, Amount = -amount, AccountTransactionInputType = AccountTransactionInputType.Payment, TransactionDate = transactionDateTime }); }
private IEnumerable <Account> GetAccounts(AccountTransactionType accountTransactionType) { var accountType = accountTransactionType.GetDefaultTransactionType(); if (accountType == 0) { accountType = accountTransactionType.TargetAccountTypeId; } return(AccountTransactionType != null ? Workspace.All <Account>(x => x.AccountTypeId == accountType).ToList() : new List <Account>()); }
private AccountTransactionType CreateTransactionType(Account sourceAccount, Account targetAccount, ForeignCurrency foreignCurrency) { var result = new AccountTransactionType { SourceAccountTypeId = sourceAccount.AccountTypeId, TargetAccountTypeId = targetAccount.AccountTypeId, DefaultSourceAccountId = sourceAccount.Id, DefaultTargetAccountId = targetAccount.Id, ForeignCurrencyId = foreignCurrency.Id }; Workspace.Add(result); Workspace.CommitChanges(); return(result); }
public void AddAccountChargeTransaction(int customerAccount, AccountTransactionType accountTransactionType, decimal amount, DateTime transactionDateTime, bool saveIfZeroAmount = false) { if (amount != 0 || saveIfZeroAmount) { AddAccountTransaction(new AccountTransaction { CustomerAccountId = customerAccount, AccountTransactionType = accountTransactionType, Amount = amount, AccountTransactionInputType = AccountTransactionInputType.Charge, TransactionDate = transactionDateTime }); } }
public void AddAccountTransaction(int customerAccount, AccountTransactionType accountTransactionType, decimal amount, DateTime transactionTime, AccountTransactionInputType accountTransactionInputType, int groupingId = 0, string note = "", bool saveIfZeroAmount = false) { AddAccountTransaction(new AccountTransaction { CustomerAccountId = customerAccount, AccountTransactionType = accountTransactionType, AccountTransactionInputType = accountTransactionInputType, Amount = amount, TransactionDate = transactionTime, GroupId = groupingId, Note = note }, saveIfZeroAmount); }
internal protected AccountTransaction( string requestId, AccountTransactionType type, AccountTransactionStatus status, decimal amount, DateTime?transactionDate = null, string externalId = null) { Status = status; Type = type; RequestId = requestId; TransactionUN = externalId; Amount = amount; TransactionDate = transactionDate ?? DateTime.UtcNow; ValidFrom = TransactionDate; }
protected void LogTransactionEvent(UserCommandType command, string action) { AccountTransactionType transaction = new AccountTransactionType() { timestamp = Unix.TimeStamp.ToString(), server = ServiceDetails.Abbr, transactionNum = command.transactionNum, action = action, username = command.username }; if (command.fundsSpecified) { transaction.funds = command.funds / 100m; } Auditor.WriteRecord(transaction); }
public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList <TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer) { UnLock(); var order = OrderBuilder.Create() .WithDepartment(department) .ForMenuItem(menuItem) .WithUserName(userName) .WithTaxTemplates(taxTemplates) .WithPortion(portion) .WithPriceTag(priceTag) .WithAccountTransactionType(template) .WithProductTimer(timer) .Build(); AddOrder(order, taxTemplates, template, userName); return(order); }
public void AddOrder(Order order, IEnumerable <TaxTemplate> taxTemplates, AccountTransactionType template, string userName) { TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts()); if (taxTemplates != null) { foreach (var taxTemplate in taxTemplates) { TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id, taxTemplate.AccountTransactionType, GetTicketAccounts()); } } Orders.Add(order); LastModifiedUserName = userName; }
public Order AddOrder(AccountTransactionType template, string userName, MenuItem menuItem, MenuItemPortion portion, string priceTag, ProductTimer timer) { Locked = false; var order = new Order(); order.UpdateMenuItem(userName, menuItem, portion, priceTag, 1); order.AccountTransactionTypeId = template.Id; TransactionDocument.AddSingletonTransaction(template.Id, template, AccountTypeId, AccountId); if (menuItem.TaxTemplate != null) { TransactionDocument.AddSingletonTransaction(order.TaxTempleteAccountTransactionTypeId, menuItem.TaxTemplate.AccountTransactionType, AccountTypeId, AccountId); } order.UpdateProductTimer(timer); Orders.Add(order); return(order); }
public IAccountWallet GetWallet(Account account, AccountTransactionType transactionType) { return(_walletFactory(account, transactionType)); }
public AccountWallet(Account account, AccountTransactionType transactionType) { _account = account; _transactionType = transactionType; }
public void AddAccountChargeTransaction(int customerAccount, AccountTransactionType accountTransactionType, decimal amount) { AddAccountChargeTransaction(customerAccount, accountTransactionType, amount, DateTime.Now); }
public MtProduct GetByAccountTransactionType(AccountTransactionType type) { return(_mtProductRepository.Get(type.ToString())); }
public void Setup() { Pizza = CreateMenuItem(1, "Pizza", 10); Cola = CreateMenuItem(2, "Cola", 5); Beer = CreateMenuItem(3, "Beer", 10); var saleAccountType = new AccountType { Name = "Sales Accounts", Id = 1 }; var taxAccountType = new AccountType { Name = "Tax Accounts", Id = 2 }; var receivableAccountType = new AccountType { Name = "Receivable Accounts", Id = 3 }; var discountAccountType = new AccountType { Name = "Discount Accounts", Id = 4 }; var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = "Sales", Id = 1 }; ReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = "Receivables", Id = 2 }; var stateTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "State Tax", Id = 3 }; var localTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "Local Tax", Id = 4 }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = "Discount", Id = 5 }; var saleTransactionType = new AccountTransactionType { Id = 1, Name = "Sale Transaction", SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = ReceivableAccount.Id }; var localTaxTransactionType = new AccountTransactionType { Id = 2, Name = "Local Tax Transaction", SourceAccountTypeId = taxAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = localTaxAccount.Id, DefaultTargetAccountId = ReceivableAccount.Id }; var stateTaxTransactionType = new AccountTransactionType { Id = 3, Name = "State Tax Transaction", SourceAccountTypeId = taxAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = stateTaxAccount.Id, DefaultTargetAccountId = ReceivableAccount.Id }; DiscountTransactionType = new AccountTransactionType { Id = 4, Name = "Discount Transaction", SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = ReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var stateTax = new TaxTemplate { Name = "State Tax", Rate = 25, Id = 1 }; stateTax.TaxTemplateMaps.Add(new TaxTemplateMap()); stateTax.AccountTransactionType = stateTaxTransactionType; var localTax = new TaxTemplate { Name = "Local Tax", Rate = 3, Id = 2 }; localTax.TaxTemplateMaps.Add(new TaxTemplateMap { MenuItemId = Cola.Id }); localTax.TaxTemplateMaps.Add(new TaxTemplateMap { MenuItemId = Beer.Id }); localTax.AccountTransactionType = localTaxTransactionType; TaxTemplates = new List <TaxTemplate> { stateTax, localTax }; TicketType = new TicketType { SaleTransactionType = saleTransactionType, TaxIncluded = true }; }
public void CreateData() { CreateDefaultCurrenciesIfNeeded(); if (!ShouldCreateData()) { return; } var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerResourceType = new ResourceType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id }; customerResourceType.ResoruceCustomFields.Add(new ResourceCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerResourceType.AccountNameTemplate = "[Name]-[Phone]"; var tableResourceType = new ResourceType { Name = Resources.Tables, EntityName = Resources.Table }; _workspace.Add(customerResourceType); _workspace.Add(tableResourceType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = "Customer Account Transaction", SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = "Customer Cash Payment", SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = "Customer Credit Card Payment", SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var customerCashDocument = new AccountTransactionDocumentType { Name = "Customer Cash", ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = "Customer Credit Card", ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); var printBillAutomation = new AutomationCommand { Name = Resources.PrintBill, ButtonHeader = Resources.PrintBill }; printBillAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { VisualBehaviour = 1 }); _workspace.Add(printBillAutomation); var unlockTicketAutomation = new AutomationCommand { Name = Resources.UnlockTicket, ButtonHeader = Resources.UnlockTicket }; unlockTicketAutomation.AutomationCommandMaps.Add(new AutomationCommandMap { VisualBehaviour = 2 }); _workspace.Add(unlockTicketAutomation); var addTicketAutomation = new AutomationCommand { Name = string.Format(Resources.Add_f, Resources.Ticket), ButtonHeader = string.Format(Resources.Add_f, Resources.Ticket) }; addTicketAutomation.AddAutomationCommandMap(); _workspace.Add(addTicketAutomation); _workspace.CommitChanges(); var ticketTemplate = new TicketTemplate { Name = Resources.TicketTemplate, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, }; var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap { DisplayAtPaymentScreen = true }); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(ticketTemplate); _workspace.Add(accountPayment); var department = new Department { Name = Resources.Restaurant, TicketTemplate = ticketTemplate, ScreenMenuId = screen.Id, }; _workspace.Add(department); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketPrinterTemplate = new PrinterTemplate { Name = Resources.TicketTemplate, Template = Resources.TicketTemplateValue }; var kitchenPrinterTemplate = new PrinterTemplate { Name = Resources.KitchenOrderTemplate, Template = Resources.KitchenTemplateValue }; _workspace.Add(ticketPrinterTemplate); _workspace.Add(kitchenPrinterTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinter = printer1, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, LocksTicket = true, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, WhatToPrint = (int)WhatToPrintTypes.NewLines, }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); _workspace.Add(t); var orderTag1 = new OrderStateGroup { Name = Resources.Gift, ButtonHeader = Resources.Gift, CalculateOrderPrice = false, DecreaseOrderInventory = true }; orderTag1.OrderStates.Add(new OrderState { Name = Resources.Gift }); orderTag1.AddOrderStateMap(); _workspace.Add(orderTag1); var orderTag2 = new OrderStateGroup { Name = Resources.Void, ButtonHeader = Resources.Void, CalculateOrderPrice = false, DecreaseOrderInventory = false }; orderTag2.OrderStates.Add(new OrderState { Name = Resources.Void }); orderTag2.UnlocksOrder = true; orderTag2.AddOrderStateMap(); _workspace.Add(orderTag2); const string parameterFormat = "[{{\"Key\":\"{0}\",\"Value\":\"{1}\"}}]"; //const string doubleParameterFormat = "[{{\"Key\":\"{0}\",\"Value\":\"{1}\"}},{{\"Key\":\"{2}\",\"Value\":\"{3}\"}}]"; var newOrderState = new ResourceState { Name = "New Orders", Color = "Orange" }; _workspace.Add(newOrderState); var availableState = new ResourceState { Name = "Available", Color = "White" }; _workspace.Add(availableState); var billRequestedState = new ResourceState { Name = "Bill Requested", Color = "Maroon" }; _workspace.Add(billRequestedState); var newOrderAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update New Order State", Parameter = string.Format(parameterFormat, "ResourceState", "New Orders") }; _workspace.Add(newOrderAction); var availableAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update Available State", Parameter = string.Format(parameterFormat, "ResourceState", "Available") }; _workspace.Add(availableAction); var billRequestedAction = new AppAction { ActionType = "UpdateResourceState", Name = "Update Bill Requested State", Parameter = string.Format(parameterFormat, "ResourceState", "Bill Requested") }; _workspace.Add(billRequestedAction); var createTicketAction = new AppAction { ActionType = "CreateTicket", Name = string.Format(Resources.Create_f, Resources.Ticket), Parameter = "" }; _workspace.Add(createTicketAction); var closeTicketAction = new AppAction { ActionType = "CloseActiveTicket", Name = Resources.CloseTicket, Parameter = "" }; _workspace.Add(closeTicketAction); var printBillAction = new AppAction { ActionType = "ExecutePrintJob", Name = "Execute Bill Print Job", Parameter = string.Format(parameterFormat, "PrintJobName", Resources.PrintBill) }; _workspace.Add(printBillAction); var printKitchenOrdersAction = new AppAction { ActionType = "ExecutePrintJob", Name = "Execute Kitchen Orders Print Job", Parameter = string.Format(parameterFormat, "PrintJobName", Resources.PrintOrdersToKitchenPrinter) }; _workspace.Add(printKitchenOrdersAction); var unlockTicketAction = new AppAction { ActionType = "UnlockTicket", Name = Resources.UnlockTicket, Parameter = "" }; _workspace.Add(unlockTicketAction); _workspace.CommitChanges(); var newOrderRule = new AppRule { Name = "Update New Order Resource Color", EventName = "TicketClosing", EventConstraints = "NewOrderCount;>;0" }; newOrderRule.Actions.Add(new ActionContainer(printKitchenOrdersAction)); newOrderRule.Actions.Add(new ActionContainer(newOrderAction)); newOrderRule.AddRuleMap(); _workspace.Add(newOrderRule); var availableRule = new AppRule { Name = "Update Available Resource Color", EventName = "ResourceUpdated", EventConstraints = "OpenTicketCount;=;0" }; var ac2 = new ActionContainer(availableAction); availableRule.Actions.Add(ac2); availableRule.AddRuleMap(); _workspace.Add(availableRule); var movingRule = new AppRule { Name = "Update Moved Resource Color", EventName = "TicketResourceChanged", EventConstraints = "OrderCount;>;0" }; var ac3 = new ActionContainer(newOrderAction); movingRule.Actions.Add(ac3); movingRule.AddRuleMap(); _workspace.Add(movingRule); var printBillRule = new AppRule { Name = "Print Bill Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;" + Resources.PrintBill }; printBillRule.Actions.Add(new ActionContainer(printBillAction)); printBillRule.Actions.Add(new ActionContainer(billRequestedAction)); printBillRule.Actions.Add(new ActionContainer(closeTicketAction)); printBillRule.AddRuleMap(); _workspace.Add(printBillRule); var unlockTicketRule = new AppRule { Name = "Unlock Ticket Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;Unlock Ticket" }; unlockTicketRule.Actions.Add(new ActionContainer(unlockTicketAction)); unlockTicketRule.AddRuleMap(); _workspace.Add(unlockTicketRule); var createTicketRule = new AppRule { Name = "Create Ticket Rule", EventName = RuleEventNames.AutomationCommandExecuted, EventConstraints = "AutomationCommandName;=;Add Ticket" }; createTicketRule.Actions.Add(new ActionContainer(createTicketAction)); createTicketRule.AddRuleMap(); _workspace.Add(createTicketRule); var updateMergedTicket = new AppRule { Name = "Update Merged Tickets State", EventName = RuleEventNames.TicketsMerged }; updateMergedTicket.Actions.Add(new ActionContainer(newOrderAction)); updateMergedTicket.AddRuleMap(); _workspace.Add(updateMergedTicket); ImportMenus(screen); ImportTableResources(tableResourceType, availableState.Id); var customerScreen = new ResourceScreen { Name = "Customer Search", DisplayMode = 2, ResourceTypeId = customerResourceType.Id }; customerScreen.ResourceScreenMaps.Add(new ResourceScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new ResourceScreen { Name = "Customer Tickets", DisplayMode = 0, ResourceTypeId = customerResourceType.Id, StateFilterId = newOrderState.Id, ColumnCount = 6, RowCount = 6 }; customerTicketScreen.ResourceScreenMaps.Add(new ResourceScreenMap()); _workspace.Add(customerTicketScreen); ImportItems(BatchCreateResources); ImportItems(BatchCreateTransactionTypes); ImportItems(BatchCreateTransactionTypeDocuments); _workspace.CommitChanges(); _workspace.Dispose(); }
public void AddAccountTransaction(int customerAccount, AccountTransactionType accountTransactionType, decimal amount, AccountTransactionInputType accountTransactionInputType, int groupingId = 0, string note = "") { AddAccountTransaction(customerAccount, accountTransactionType, amount, DateTime.Now, accountTransactionInputType, groupingId, note); }
public AccountTransactionLogEvent(Account account, AccountTransactionType transactionType) { Account = account; TransactionType = transactionType; }
public string GetExistAccountTransaction(string TrID, out AccountTransactionType.AccountTransactionDataType _ExistData) { _ExistData = new AccountTransactionType.AccountTransactionDataType(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Select " + "TrID," + "CompanyID," + "AccountID," + "MainRef," + "RelRef," + "Description," + "CurRate," + "Dr," + "Cr," + "FDr," + "FCr," + "VoucherID," + "PayMethod," + "AnyOtherRemarks," + "TrDate," + "TrTime," + "TrUser," + "TrMachine," + "AccountYear," + "SysID," + "TransType," + "ActualDate" + " from tblaccounttransaction" + " Where 1=1 " + " and [email protected]"; oSqlCommand.Parameters.AddWithValue("@TrID", TrID); DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand, "Get Exist data AccountTransaction"); if (r != null) { try { bool resp = false; _ExistData.TrID = r["TrID"].ToString(); int inCompanyID = 0; resp = int.TryParse(r["CompanyID"].ToString(), out inCompanyID); _ExistData.CompanyID = inCompanyID; _ExistData.AccountID = r["AccountID"].ToString(); _ExistData.MainRef = r["MainRef"].ToString(); _ExistData.RelRef = r["RelRef"].ToString(); _ExistData.Description = r["Description"].ToString(); decimal deCurRate = 0; resp = decimal.TryParse(r["CurRate"].ToString(), out deCurRate); _ExistData.CurRate = deCurRate; decimal deDr = 0; resp = decimal.TryParse(r["Dr"].ToString(), out deDr); _ExistData.Dr = deDr; decimal deCr = 0; resp = decimal.TryParse(r["Cr"].ToString(), out deCr); _ExistData.Cr = deCr; decimal deFDr = 0; resp = decimal.TryParse(r["FDr"].ToString(), out deFDr); _ExistData.FDr = deFDr; decimal deFCr = 0; resp = decimal.TryParse(r["FCr"].ToString(), out deFCr); _ExistData.FCr = deFCr; _ExistData.VoucherID = r["VoucherID"].ToString(); int inPayMethod = 0; resp = int.TryParse(r["PayMethod"].ToString(), out inPayMethod); _ExistData.PayMethod = inPayMethod; _ExistData.AnyOtherRemarks = r["AnyOtherRemarks"].ToString(); DateTime dtTrDate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["TrDate"].ToString(), out dtTrDate); if (resp) _ExistData.TrDate = dtTrDate; else _ExistData.TrDate = new DateTime(1900, 1, 1); _ExistData.TrTime = r["TrTime"].ToString(); _ExistData.TrUser = r["TrUser"].ToString(); _ExistData.TrMachine = r["TrMachine"].ToString(); int inAccountYear = 0; resp = int.TryParse(r["AccountYear"].ToString(), out inAccountYear); _ExistData.AccountYear = inAccountYear; int inSysID = 0; resp = int.TryParse(r["SysID"].ToString(), out inSysID); _ExistData.SysID = inSysID; int inTransType = 0; resp = int.TryParse(r["TransType"].ToString(), out inTransType); _ExistData.TransType = inTransType; DateTime dtActualDate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["ActualDate"].ToString(), out dtActualDate); if (resp) _ExistData.ActualDate = dtActualDate; else _ExistData.ActualDate = new DateTime(1900, 1, 1); return "True"; } catch (Exception ex) { return ex.Message; } } else return "data not found "; }
public string UpdateAccountTransaction(AccountTransactionType.AccountTransactionDataType _Update) { MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Update tblaccounttransaction Set " + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected]," + "[email protected],[email protected]" + " Where 1=1 " + " and [email protected]"; try { oSqlCommand.Parameters.AddWithValue("@TrID", _Update.TrID); oSqlCommand.Parameters.AddWithValue("@CompanyID", _Update.CompanyID); oSqlCommand.Parameters.AddWithValue("@AccountID", _Update.AccountID); oSqlCommand.Parameters.AddWithValue("@MainRef", _Update.MainRef); oSqlCommand.Parameters.AddWithValue("@RelRef", _Update.RelRef); oSqlCommand.Parameters.AddWithValue("@Description", _Update.Description); oSqlCommand.Parameters.AddWithValue("@CurRate", _Update.CurRate); oSqlCommand.Parameters.AddWithValue("@Dr", _Update.Dr); oSqlCommand.Parameters.AddWithValue("@Cr", _Update.Cr); oSqlCommand.Parameters.AddWithValue("@FDr", _Update.FDr); oSqlCommand.Parameters.AddWithValue("@FCr", _Update.FCr); oSqlCommand.Parameters.AddWithValue("@VoucherID", _Update.VoucherID); oSqlCommand.Parameters.AddWithValue("@PayMethod", _Update.PayMethod); oSqlCommand.Parameters.AddWithValue("@AnyOtherRemarks", _Update.AnyOtherRemarks); oSqlCommand.Parameters.AddWithValue("@TrDate", _Update.TrDate); oSqlCommand.Parameters.AddWithValue("@TrTime", _Update.TrTime); oSqlCommand.Parameters.AddWithValue("@TrUser", _Update.TrUser); oSqlCommand.Parameters.AddWithValue("@TrMachine", _Update.TrMachine); oSqlCommand.Parameters.AddWithValue("@AccountYear", _Update.AccountYear); oSqlCommand.Parameters.AddWithValue("@TransType", _Update.TransType); oSqlCommand.Parameters.AddWithValue("@ActualDate", _Update.ActualDate); if (_Update.CurRate==1) oSqlCommand.Parameters.AddWithValue("@IsBaseCurreny", 1); else oSqlCommand.Parameters.AddWithValue("@IsBaseCurreny", 0); string respond = Mycommon.ExicuteAnyCommandAccount(sqlQuery, oSqlCommand,"Update AccountTransaction"); return respond; } catch (Exception ex) { return ex.Message; } }
public string SaveAccountTransaction(AccountTransactionType.AccountTransactionDataType _SaveData) { MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Insert Into tblaccounttransaction (" + "TrID," + "CompanyID," + "AccountID," + "MainRef," + "RelRef," + "Description," + "CurRate," + "Dr," + "Cr," + "FDr," + "FCr," + "VoucherID," + "PayMethod," + "AnyOtherRemarks," + "TrDate," + "TrTime," + "TrUser," + "TrMachine," + "AccountYear," + "SysID," + "TransType," + "ActualDate,IsBaseCurreny)" + " Values (" + "@TrID," + "@CompanyID," + "@AccountID," + "@MainRef," + "@RelRef," + "@Description," + "@CurRate," + "@Dr," + "@Cr," + "@FDr," + "@FCr," + "@VoucherID," + "@PayMethod," + "@AnyOtherRemarks," + "@TrDate," + "@TrTime," + "@TrUser," + "@TrMachine," + "@AccountYear," + "@SysID," + "@TransType," + "@ActualDate,@IsBaseCurreny)"; try { oSqlCommand.Parameters.AddWithValue("@TrID", _SaveData.TrID); oSqlCommand.Parameters.AddWithValue("@CompanyID", _SaveData.CompanyID); oSqlCommand.Parameters.AddWithValue("@AccountID", _SaveData.AccountID); oSqlCommand.Parameters.AddWithValue("@MainRef", _SaveData.MainRef); oSqlCommand.Parameters.AddWithValue("@RelRef", _SaveData.RelRef); oSqlCommand.Parameters.AddWithValue("@Description", _SaveData.Description); oSqlCommand.Parameters.AddWithValue("@CurRate", _SaveData.CurRate); oSqlCommand.Parameters.AddWithValue("@Dr", _SaveData.Dr); oSqlCommand.Parameters.AddWithValue("@Cr", _SaveData.Cr); oSqlCommand.Parameters.AddWithValue("@FDr", _SaveData.FDr); oSqlCommand.Parameters.AddWithValue("@FCr", _SaveData.FCr); oSqlCommand.Parameters.AddWithValue("@VoucherID", _SaveData.VoucherID); oSqlCommand.Parameters.AddWithValue("@PayMethod", _SaveData.PayMethod); oSqlCommand.Parameters.AddWithValue("@AnyOtherRemarks", _SaveData.AnyOtherRemarks); oSqlCommand.Parameters.AddWithValue("@TrDate", _SaveData.TrDate); oSqlCommand.Parameters.AddWithValue("@TrTime", _SaveData.TrTime); oSqlCommand.Parameters.AddWithValue("@TrUser", _SaveData.TrUser); oSqlCommand.Parameters.AddWithValue("@TrMachine", _SaveData.TrMachine); oSqlCommand.Parameters.AddWithValue("@AccountYear", _SaveData.AccountYear); oSqlCommand.Parameters.AddWithValue("@SysID", _SaveData.SysID); oSqlCommand.Parameters.AddWithValue("@TransType", _SaveData.TransType); oSqlCommand.Parameters.AddWithValue("@ActualDate", _SaveData.ActualDate); if (_SaveData.CurRate==1) oSqlCommand.Parameters.AddWithValue("@IsBaseCurreny",1); else oSqlCommand.Parameters.AddWithValue("@IsBaseCurreny", 0); string respond = Mycommon.ExicuteAnyCommandAccount(sqlQuery, oSqlCommand, "Save AccountTransaction"); return respond; } catch (Exception ex) { return ex.Message; } }
public void CreateData() { CreateDefaultCurrenciesIfNeeded(); if (!ShouldCreateData()) { return; } var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); _workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10 }); ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Restaurant, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketPrinterTemplate = new PrinterTemplate { Name = Resources.TicketTemplate, Template = GetDefaultTicketPrintTemplate() }; var kitchenPrinterTemplate = new PrinterTemplate { Name = Resources.KitchenOrderTemplate, Template = GetDefaultKitchenPrintTemplate() }; var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = GetDefaultCustomerReceiptTemplate() }; _workspace.Add(ticketPrinterTemplate); _workspace.Add(kitchenPrinterTemplate); _workspace.Add(customerReceiptTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinterId = printer1.Id, TransactionPrinterId = printer1.Id, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); _workspace.Add(t); new RuleGenerator().GenerateSystemRules(_workspace); ImportMenus(screen); ImportTableResources(tableEntityType, ticketType); var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); ImportItems(BatchCreateEntities); ImportItems(BatchCreateTransactionTypes); ImportItems(BatchCreateTransactionTypeDocuments); _workspace.CommitChanges(); _workspace.Dispose(); }
public IEnumerable <AccountTransactionType> BatchCreateTransactionTypes(string[] values, IWorkspace workspace) { IList <AccountTransactionType> result = new List <AccountTransactionType>(); if (values.Length > 0) { foreach (var item in values) { var parts = item.Split(';'); if (parts.Count() > 2) { var name = parts[0].Trim(); if (workspace.Single <AccountTransactionType>(x => x.Name.ToLower() == name.ToLower()) != null) { continue; } var sTempName = parts[1].Trim(); var tTempName = parts[2].Trim(); var dsa = parts.Length > 2 ? parts[3].Trim() : ""; var dta = parts.Length > 3 ? parts[4].Trim() : ""; var sAccTemplate = workspace.Single <AccountType>(x => x.Name.ToLower() == sTempName.ToLower()); if (sAccTemplate == null) { using (var w = WorkspaceFactory.Create()) { sAccTemplate = new AccountType { Name = sTempName }; w.Add(sAccTemplate); w.CommitChanges(); } } var tAccTemplate = workspace.Single <AccountType>(x => x.Name.ToLower() == tTempName.ToLower()); if (tAccTemplate == null) { using (var w = WorkspaceFactory.Create()) { tAccTemplate = new AccountType { Name = tTempName }; w.Add(tAccTemplate); w.CommitChanges(); } } var sa = !string.IsNullOrEmpty(dsa) ? workspace.Single <Account>(x => x.Name.ToLower() == dsa.ToLower()) : null; if (!string.IsNullOrEmpty(dsa) && sa == null) { using (var w = WorkspaceFactory.Create()) { sa = new Account { Name = dsa, AccountTypeId = sAccTemplate.Id }; w.Add(sa); w.CommitChanges(); } } var ta = !string.IsNullOrEmpty(dta) ? workspace.Single <Account>(x => x.Name.ToLower() == dta.ToLower()) : null; if (!string.IsNullOrEmpty(dta) && ta == null) { using (var w = WorkspaceFactory.Create()) { ta = new Account { Name = dta, AccountTypeId = tAccTemplate.Id }; w.Add(ta); w.CommitChanges(); } } var resultItem = new AccountTransactionType { Name = name, SourceAccountTypeId = sAccTemplate.Id, TargetAccountTypeId = tAccTemplate.Id }; if (sa != null) { resultItem.DefaultSourceAccountId = sa.Id; } if (ta != null) { resultItem.DefaultTargetAccountId = ta.Id; } result.Add(resultItem); } } } return(result); }
public void Setup() { Pizza = CreateMenuItem(1, "Pizza", 10); Cola = CreateMenuItem(2, "Cola", 5); Beer = CreateMenuItem(3, "Beer", 10); Product = CreateMenuItem(4, "Product", 1); var saleAccountType = new AccountType { Name = "Sales Accounts", Id = 1 }; var taxAccountType = new AccountType { Name = "Tax Accounts", Id = 2 }; var receivableAccountType = new AccountType { Name = "Receivable Accounts", Id = 3 }; var discountAccountType = new AccountType { Name = "Discount Accounts", Id = 4 }; var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = "Sales", Id = 1 }; var receivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = "Receivables", Id = 2 }; var stateTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "State Tax", Id = 3 }; var localTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "Local Tax", Id = 4 }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = "Discount", Id = 5 }; var saleTransactionType = new AccountTransactionType { Id = 1, Name = "Sale Transaction", SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = receivableAccount.Id }; var localTaxTransactionType = new AccountTransactionType { Id = 2, Name = "Local Tax Transaction", SourceAccountTypeId = taxAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = localTaxAccount.Id, DefaultTargetAccountId = receivableAccount.Id }; var stateTaxTransactionType = new AccountTransactionType { Id = 3, Name = "State Tax Transaction", SourceAccountTypeId = taxAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = stateTaxAccount.Id, DefaultTargetAccountId = receivableAccount.Id }; DiscountTransactionType = new AccountTransactionType { Id = 4, Name = "Discount Transaction", SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = receivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var stateTax = TaxTemplateBuilder.Create("State Tax") .WithRate(25) .WithRounding(2) .WithAccountTransactionType(stateTaxTransactionType) .AddDefaultTaxTemplateMap() .Build(); var localTax = TaxTemplateBuilder.Create("Local Tax").WithRate(3) .AddTaxTemplateMap(new TaxTemplateMap { MenuItemId = Cola.Id }) .AddTaxTemplateMap(new TaxTemplateMap { MenuItemId = Beer.Id }) .WithAccountTransactionType(localTaxTransactionType) .WithRounding(2) .Build(); TaxTemplates = new List <TaxTemplate> { stateTax, localTax }; TicketType = new TicketType { SaleTransactionType = saleTransactionType, TaxIncluded = true }; }
public TaxTemplateBuilder WithAccountTransactionType(AccountTransactionType accountTransactionType) { _accountTransactionType = accountTransactionType; return(this); }
public CalculationTypeBuilder WithAccountTransactionType(AccountTransactionType accountTransactionType) { _accountTransactionType = accountTransactionType; return(this); }
public void Create(DataCreationService dataCreationService, IWorkspace workspace) { this._workspace = workspace; var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); //_workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Retail, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); AddDefaultUsers(); PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal(); new RuleGenerator().GenerateSystemRules(_workspace); dataCreationService.ImportMenus(screen); //dataCreationService.ImportTableResources(tableEntityType, ticketType); //RL - import data and associate with an entity. //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); }
public OrderBuilder WithAccountTransactionType(AccountTransactionType accountTransactionType) { _accountTransactionType = accountTransactionType; return(this); }