Ejemplo n.º 1
0
        public static void Seed(GLDbContext context)
        {
            var balanceSheetGst = context.GstCategories.Add(new GstCategory {
                Code = "N-T", Percent = 0
            });
            var pandlGst = context.GstCategories.Add(new GstCategory {
                Code = "GST", Percent = 10
            });

            for (int i = (int)GLCategoryEnum.Asset; i <= (int)GLCategoryEnum.OtherIncome; i++)
            {
                var IsBalSheet = IsBalanceSheet(i);
                var cat        = context.GLCategories.Add(new GLCategory {
                    Category = i, IsBalanceSheet = IsBalSheet
                });
                var gstCategory = IsBalSheet ? balanceSheetGst : pandlGst;
                var account     = new Account {
                    Code = $"0{i}", Category = cat, GstCategory = gstCategory
                };
                var child1 = new Account {
                    Code = $"0{i}-0100", Category = cat, GstCategory = gstCategory, Parent = account
                };
                account.Children.Add(child1);
                var child2 = new Account {
                    Code = $"0{i}-0200", Category = cat, GstCategory = gstCategory, Parent = account
                };
                account.Children.Add(child2);
                var child3 = new Account {
                    Code = $"0{i}-0300", Category = cat, GstCategory = gstCategory, Parent = account
                };
                account.Children.Add(child3);

                context.Accounts.Add(account);
                context.Accounts.Add(child1);
                context.Accounts.Add(child2);
                context.Accounts.Add(child3);

                for (int j = 0; j < 20; j++)
                {
                    var grandchild = new Account {
                        Code = $"0{i}-gc{j:D2}", Category = cat, GstCategory = gstCategory, Parent = child3
                    };
                    child3.Children.Add(grandchild);
                }
            }

            context.SaveChanges();
        }
Ejemplo n.º 2
0
        private static Setting MakeSetting(string settingName, string defaultValue)
        {
            using (var connect = new GLDbContext())
            {
                var setting = new Setting {
                    Name = settingName, Value = defaultValue
                };
                connect.Settings.Add(setting);
                connect.SaveChanges();

                var newSetting = connect.Settings.SingleOrDefault(x => x.Name == setting.Name);
                if (newSetting == null)
                {
                    throw new Exception("Expected setting to be found");
                }

                return(newSetting);
            }
        }