﻿--------------------------Mostafa 2021-10-24----------------------


INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage])
VALUES(565,N'Branch',N'فرع',357,N'/Inventory/FinancialBranch',N'Index','fa fa-thumb-tack',N'get',4,1,1)
Go

INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(565,12)
Go

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14202,N'فرع',N'Branch',565,1)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14203,N'عرض فرع',N'View Branch',565,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14204,N'إضافة فرع',N'Add Branch',565,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14205,N'تعديل فرع',N'Edit Branch',565,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14206,N'حذف فرع',N'Delete Branch',565,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(14207,N'حفظ فرع',N'Save Branch',565,2)
Go

-- SSTAuthorizationActionFilterBefore (script only not added in db Check it and run if you want) 

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(866,N'Inventory',N'FinancialBranch',N'Index',0,N'get',14202)

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(867,N'Inventory',N'FinancialBranch',N'FinancialBranch_Read',0,N'post',14203)

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(868,N'Inventory',N'FinancialBranch',N'Save',1,N'get',14204)

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(869,N'Inventory',N'FinancialBranch',N'Save',2,N'get',14205)

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(870,N'Inventory',N'FinancialBranch',N'Delete',0,N'post',14206)

INSERT [dbo].[SecurityPrivilegeActions] ([ID], [AreaName], [ControllerName], [ActionName], [ActionType], [HTTPMethod], [SecurityPrivilegeID]) VALUES(871,N'Inventory',N'FinancialBranch',N'Save',0,N'post',14207)

--------------------------End 2021-10-24----------------------

--------------------------Ali 2021-10-25----------------------

 INSERT[dbo].[ConfigParameter]  ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId])
VALUES(N'APPCalcAnnualWorkIncentive',N'Calculation Annual Work Incentive',N'احتساب حافز العمل السنوي',N'83',10,16,6,1,Null,Null,Null)
Go
INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) VALUES (83, N'Employee Evaluation', N'تقييم الموظفين', N'APPCalcAnnualWorkIncentive')
INSERT [dbo].[ConfigLookup] ([ConfigLookupCode], [Name], [Arabic_Name], [ConfigKey]) VALUES (84, N'Evaluation Curve', N'منحنى التقييم', N'APPCalcAnnualWorkIncentive')
Go
--------------------------End 2021-10-25----------------------
--------------------------Mostafa 2021-10-26----------------------
insert into  ConfigParameter 
(ConfigKey,Name,Arabic_Name,ConfigValue,ConfigCategoryCode,OrderNo,ConfigType,IsVisible)
VALUES ('AddRequestForBonusToAnnual','Add Request For Bonus To Annual',N'اضافة طلب علاوة للحافز السنوي '
,'false',10,17,1,N'True')

insert into  ConfigParameter 
(ConfigKey,Name,Arabic_Name,ConfigValue,ConfigCategoryCode,OrderNo,ConfigType,IsVisible)
VALUES ('AddRequestPromotionForAnnual','Add Request Promotion For Annual',N'اضافة طلب ترقية للزيادات السنوية '
,'false',10,18,1,N'True')
--------------------------End 2021-10-26----------------------
--------------------------Mostafa 2021-10-26----------------------

  ALTER TABLE [dbo].WF_Track ADD
	RelatedBonusAppraisal bit Not NULL  default 0
GO

  ALTER TABLE [dbo].WF_Track ADD
	RelatedPromotionIncrease  bit Not NULL   default 0
GO
--------------------------End 2021-10-26----------------------
--------------------------AK 2021-10-26----------------------

 /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_Posted
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_Asset
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_Stock
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_Payroll
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_Closed
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_F26
GO
ALTER TABLE dbo.ChartOfAccounts
	DROP CONSTRAINT DF_ChartOfAccounts_PosttoNextYear
GO
CREATE TABLE dbo.Tmp_ChartOfAccounts
	(
	AccountId int NOT NULL IDENTITY (1, 1),
	AccountCode nvarchar(15) NOT NULL,
	Name nvarchar(150) NULL,
	Arabic_Name nvarchar(150) NULL,
	MyFather nvarchar(14) NULL,
	Account_Type tinyint NULL,
	Follow_List tinyint NULL,
	SecurityLevel tinyint NULL,
	CostCenterType int NULL,
	[Level] tinyint NULL,
	CostCenterCode nvarchar(9) NULL,
	BudgetCode smallint NULL,
	Posted smallint NULL,
	ClosingAccount nvarchar(15) NULL,
	Asset bit NULL,
	Stock bit NULL,
	Payroll bit NULL,
	AoutoSerial int NULL,
	RecordAddBy nvarchar(20) NULL,
	RecordAddDate datetime NULL,
	RecordLastChangeBy nvarchar(20) NULL,
	RecordChangeDate datetime NULL,
	Closed bit NULL,
	F23 nvarchar(255) NULL,
	F24 nvarchar(255) NULL,
	F25 nvarchar(255) NULL,
	F26 bit NULL,
	PosttoNextYear bit NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts SET (LOCK_ESCALATION = TABLE)
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_Posted DEFAULT ((0)) FOR Posted
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_Asset DEFAULT ((0)) FOR Asset
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_Stock DEFAULT ((0)) FOR Stock
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_Payroll DEFAULT ((0)) FOR Payroll
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_Closed DEFAULT ((0)) FOR Closed
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_F26 DEFAULT ((0)) FOR F26
GO
ALTER TABLE dbo.Tmp_ChartOfAccounts ADD CONSTRAINT
	DF_ChartOfAccounts_PosttoNextYear DEFAULT ((0)) FOR PosttoNextYear
GO
SET IDENTITY_INSERT dbo.Tmp_ChartOfAccounts OFF
GO
IF EXISTS(SELECT * FROM dbo.ChartOfAccounts)
	 EXEC('INSERT INTO dbo.Tmp_ChartOfAccounts (AccountCode, Name, Arabic_Name, MyFather, Account_Type, Follow_List, SecurityLevel, CostCenterType, [Level], CostCenterCode, BudgetCode, Posted, ClosingAccount, Asset, Stock, Payroll, AoutoSerial, RecordAddBy, RecordAddDate, RecordLastChangeBy, RecordChangeDate, Closed, F23, F24, F25, F26, PosttoNextYear)
		SELECT AccountCode, Name, Arabic_Name, MyFather, Account_Type, Follow_List, SecurityLevel, CostCenterType, [Level], CostCenterCode, BudgetCode, Posted, ClosingAccount, Asset, Stock, Payroll, AoutoSerial, RecordAddBy, RecordAddDate, RecordLastChangeBy, RecordChangeDate, Closed, F23, F24, F25, F26, PosttoNextYear FROM dbo.ChartOfAccounts WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.ChartOfAccounts
GO
EXECUTE sp_rename N'dbo.Tmp_ChartOfAccounts', N'ChartOfAccounts', 'OBJECT' 
GO
ALTER TABLE dbo.ChartOfAccounts ADD CONSTRAINT
	PK_ChartOfAccounts PRIMARY KEY CLUSTERED 
	(
	AccountId
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT

Update inv.Supplier SET AccountNoCode=(select AccountId from ChartOfAccounts where AccountCode=AccountNoCode) WHERE AccountNoCode IS NOT NULL
Update inv.SupplierGroup SET AccountCode=(select AccountId from ChartOfAccounts where AccountCode=inv.SupplierGroup.AccountCode) WHERE AccountCode IS NOT NULL
Update inv.Store SET AccountCode=(select AccountId from ChartOfAccounts where AccountCode=inv.Store.AccountCode) WHERE AccountCode IS NOT NULL
Update inv.StoreTransactionMaster SET AccountCode=(select AccountId from ChartOfAccounts where AccountCode=inv.StoreTransactionMaster.AccountCode) WHERE AccountCode IS NOT NULL
GO

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.ChartOfCostCenters
	DROP CONSTRAINT DF_ChartOfCostCenters_Stock
GO
ALTER TABLE dbo.ChartOfCostCenters
	DROP CONSTRAINT DF_ChartOfCostCenters_Payroll
GO
ALTER TABLE dbo.ChartOfCostCenters
	DROP CONSTRAINT DF_ChartOfCostCenters_Closed
GO
CREATE TABLE dbo.Tmp_ChartOfCostCenters
	(
	CostCenterId int NOT NULL IDENTITY (1, 1),
	CostCenterCode nvarchar(9) NOT NULL,
	Name nvarchar(30) NULL,
	Arabic_Name nvarchar(30) NULL,
	MyFather nvarchar(8) NULL,
	ClosingAccount nvarchar(15) NULL,
	CostCenterLevel smallint NULL,
	Stock bit NULL,
	Payroll bit NULL,
	Closed bit NULL,
	Posted int NULL,
	RecordAddBy nvarchar(20) NULL,
	RecordAddDate datetime NULL,
	RecordLastChangeBy nvarchar(20) NULL,
	RecordChangeDate datetime NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_ChartOfCostCenters SET (LOCK_ESCALATION = TABLE)
GO
ALTER TABLE dbo.Tmp_ChartOfCostCenters ADD CONSTRAINT
	DF_ChartOfCostCenters_Stock DEFAULT ((0)) FOR Stock
GO
ALTER TABLE dbo.Tmp_ChartOfCostCenters ADD CONSTRAINT
	DF_ChartOfCostCenters_Payroll DEFAULT ((0)) FOR Payroll
GO
ALTER TABLE dbo.Tmp_ChartOfCostCenters ADD CONSTRAINT
	DF_ChartOfCostCenters_Closed DEFAULT ((0)) FOR Closed
GO
IF EXISTS(SELECT * FROM dbo.ChartOfCostCenters)
	 EXEC('INSERT INTO dbo.Tmp_ChartOfCostCenters (CostCenterCode, Name, Arabic_Name, MyFather, ClosingAccount, CostCenterLevel, Stock, Payroll, Closed, Posted, RecordAddBy, RecordAddDate, RecordLastChangeBy, RecordChangeDate)
		SELECT CostCenterCode, Name, Arabic_Name, MyFather, ClosingAccount, CostCenterLevel, Stock, Payroll, Closed, Posted, RecordAddBy, RecordAddDate, RecordLastChangeBy, RecordChangeDate FROM dbo.ChartOfCostCenters WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.ChartOfCostCenters
GO
EXECUTE sp_rename N'dbo.Tmp_ChartOfCostCenters', N'ChartOfCostCenters', 'OBJECT' 
GO
ALTER TABLE dbo.ChartOfCostCenters ADD CONSTRAINT
	PK_ChartOfCostCenters PRIMARY KEY CLUSTERED 
	(
	CostCenterId
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT

Update inv.Store SET CostCenterCode=(select CostCenterId from ChartOfCostCenters where CostCenterCode=inv.Store.CostCenterCode) WHERE CostCenterCode IS NOT NULL
Update inv.StoreTransactionMaster SET CostCenterCode=(select CostCenterId from ChartOfCostCenters where CostCenterCode=inv.StoreTransactionMaster.CostCenterCode) WHERE CostCenterCode IS NOT NULL
GO
--------------------------End 2021-10-26----------------------

--------------------------MOstafa 2021-10-26----------------------

INSERT [dbo].[SystemMenu] ([SystemMenuCode], [Name], [Arabic_Name], [ParentID], [ControllerName], [ActionName], [ImageURL], [HTTPMethod], [Sequence], [IsVisible], [ShowInPrivilegePage])
VALUES(567,N'Calculating Annual Increase',N'احتساب الزيادة السنوية',161,N'/Appraisal/CalculatingAnnualIncrease',N'Index','fa fa-thumb-tack',N'get',21,1,1)
Go

INSERT[dbo].[SystemMenuModule]( [SystemMenuCode], [AppModuleCode]) VALUES(567,8)
Go

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(10096,N'احتساب الزيادة السنوية',N'Calculating Annual Increase',567,1)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(10097,N'عرض احتساب الزيادة السنوية',N'View Calculating Annual Increase',567,2)

INSERT[dbo].[SecurityPrivilege]([ID], [DescriptionAR], [DescriptionEN], [SystemMenuCode], [PrivilegeType]) VALUES(10098,N'إضافة احتساب الزيادة السنوية',N'Add Calculating Annual Increase',567,2)


Go
--------------------------End 2021-10-26----------------------
--------------------------Hammad 2021-10-26-------------------
update ConfigParameter set Arabic_Name=N'السماح باستخدام الوزن النسبى لطرق التقيم'
 where ConfigKey='APPrAllowedUseRelativeWeightElements'
 GO

INSERT [dbo].[ConfigParameter] ([ConfigKey], [Name], [Arabic_Name], [ConfigValue], [ConfigCategoryCode], [OrderNo], [ConfigType], [IsVisible], [ModifiedBy], [ModificationDate], [RequestTypeId]) VALUES 
(N'APPrCalcEvaluationByWeightElements', N'Calc Evaluation By Weight Elements', N'السماح باستخدام الوزن النسبى للعناصر', N'false', 10, 16, 1, 1, NULL, NULL, NULL)
Go
--------------------------End 2021-10-26-------------------