public CompanySite() { Site = ApplicationDataContext.Instance.SystemEntityContext.SYS_Site.Include("SYS_Entity").FirstOrDefault(n => n.SYS_Entity.Id == ApplicationDataContext.Instance.LoggedInUser.DefaultSite.Id); Entity = Site.SYS_Entity; billingAddress = Site.SYS_Address_BillingAddress; //dataContext.EntitySystemContext.SYS_Address.FirstOrDefault(n => n.Id == Site.BillingAddress); shippingAddress = Site.SYS_Address_ShippingAddress; //dataContext.EntitySystemContext.SYS_Address.FirstOrDefault(n => n.Id == Site.ShippingAddress); printerBarcode = Site.SYS_Printer_Barcode; //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterBarcode); printerPicker = Site.SYS_Printer_Picker; //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterPicker); printerReceipt = Site.SYS_Printer_Receipt; //dataContext.EntitySystemContext.SYS_Printer.FirstOrDefault(n => n.Id == Site.PrinterReceipt); }
public SiteAccounts() { Site = ApplicationDataContext.Instance.SystemEntityContext.SYS_Site.Include("SYS_Entity").FirstOrDefault(n => n.SYS_Entity.Id == ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId); SiteEntity = Site.SYS_Entity; List <int> siteTypes = Enum.GetValues(typeof(GLX.GLX_SystemAccountType)).Cast <int>().ToList(); //SEAN: //removed && n.SystemDefaultAccount == true here List <DB.GLX_SiteAccount> siteAccounts = ApplicationDataContext.Instance.AccountingEntityContext.GLX_SiteAccount.Where(n => siteTypes.Contains(n.TypeId) && n.SiteId == Site.EntityId).ToList(); bank = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Bank); cardControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CardControl); cashControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CashControl); chequeControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.ChequeControl); costDifference = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CostDifference); costOfSales = costOfSales = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CostofSales); creditControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CreditControl); creditors = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Creditors); if (creditors != null) { creditorsEntity = ApplicationDataContext.Instance.SystemEntityContext.SYS_Entity.FirstOrDefault(n => n.Id == creditors.EntityId); } debtors = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Debtors); if (debtors != null) { debtorsEntity = ApplicationDataContext.Instance.SystemEntityContext.SYS_Entity.FirstOrDefault(n => n.Id == debtors.EntityId); } distributedReserves = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Distributedreserves); eftControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Eftcontrol); interestCharged = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.InterestCharged); inventory = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Inventory); profit = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Profit); rounding = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Rounding); sales = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Sales); settlemetnDiscountAllowed = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.SettlementDiscountAllowed); settlemetnDiscountRecieved = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.SettlementDiscountReceived); stockAdjustment = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.StockAdjustment); vatControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatControl); vatInput = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatInput); vatOutput = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatOutput); inventoryBuyout = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.InventoryBuyout); }
internal static String Save(DB.SYS_Entity entry, DataContext dataContext) { try { if (dataContext.EntitySystemContext.GetEntityState(entry) == EntityState.Detached) { dataContext.EntitySystemContext.SYS_Entity.Add(entry); } Validation.ValidateEntity(dataContext.EntitySystemContext, entry); } catch (Validation.EntityValidationException ex) { return(dataContext.PackageValidationException()); } return("Success"); }
public static void AllignCompanyAccountNames(DB.SYS_Entity entry, DataContext dataContext) { DB.SYS_Entity sysCompany = dataContext.EntitySystemContext.SYS_Entity.FirstOrDefault(n => n.CodeMain.Equals(String.Empty) && n.CodeSub == entry.CodeSub && n.TypeId == (byte)SYS.SYS_Type.Company); String CustomerAccountCode = SYS.SYS_Entity.Load(ApplicationDataContext.Instance.SiteAccounts.Debtors.EntityId, dataContext).CodeMain; String SupplierAccountCode = SYS.SYS_Entity.Load(ApplicationDataContext.Instance.SiteAccounts.Creditors.EntityId, dataContext).CodeMain; DB.SYS_Entity sysCustomerAccount = dataContext.EntitySystemContext.SYS_Entity.FirstOrDefault(n => n.CodeMain == CustomerAccountCode && n.CodeSub == entry.CodeSub && n.CodeSub != "00000" && n.TypeId == (byte)SYS.SYS_Type.Account); DB.SYS_Entity sysSupplierAccount = dataContext.EntitySystemContext.SYS_Entity.FirstOrDefault(n => n.CodeMain == SupplierAccountCode && n.CodeSub == entry.CodeSub && n.CodeSub != "00000" && n.TypeId == (byte)SYS.SYS_Type.Account); if (sysCompany != null) { sysCompany.Name = entry.Name; } if (sysCustomerAccount != null) { sysCustomerAccount.Name = entry.Name; } if (sysSupplierAccount != null) { sysSupplierAccount.Name = entry.Name; } }
public static DB.SYS_Entity CreateORG_CompanySYS_Entity(byte typeId, string codeSub, string description, string name, DataContext dataContext) { DB.SYS_Entity sys_entity = null; switch (typeId) { case (byte)ORG.ORG_Type.Customer: sys_entity = SYS.SYS_Entity.NewCustomerAccountEntity; sys_entity.CodeMain = SYS.SYS_Entity.Load(ApplicationDataContext.Instance.SiteAccounts.Debtors.EntityId, dataContext).CodeMain; break; case (byte)ORG.ORG_Type.Supplier: sys_entity = SYS.SYS_Entity.NewSupplierAccountEntity; sys_entity.CodeMain = SYS.SYS_Entity.Load(ApplicationDataContext.Instance.SiteAccounts.Creditors.EntityId, dataContext).CodeMain; break; } sys_entity.CodeSub = codeSub; sys_entity.Description = description; sys_entity.Name = name; return(sys_entity); }
public static DB.SYS_Entity GetPreviousItem(DB.SYS_Entity entry, DataContext dataContext) { return(dataContext.EntitySystemContext.SYS_Entity.OrderByDescending(o => o.Name).FirstOrDefault(n => n.Name.CompareTo(entry.Name) < 0 && n.TypeId == entry.TypeId)); }