2025-08-06 14:31:52 +06:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using Ease.CoreV35 ;
using Ease.CoreV35.Model ;
using Ease.CoreV35.Caching ;
using System.Data.Linq.Mapping ;
using Ease.CoreV35.Utility ;
using System.Data ;
namespace Payroll.BO
{
public abstract class AbstractTaxCalculator
{
#region Define Class Variable
protected SalaryMonthly _salary ;
private BonusProcess . BonusProcessDetail _bonus ;
protected Employee _employee ;
protected TaxParameter _taxParameter ;
private TaxParameter _PrvYeartaxParameter ;
protected ObjectsTemplate < TaxParameterSlab > _taxSlabs ;
private ObjectsTemplate < IncomeTax > _currentYearTax ;
private ObjectsTemplate < IncomeTax > _prvYearTotalIncomes ;
protected ObjectsTemplate < ADParameter > _adParameters ;
private ObjectsTemplate < TaxMergeMaster > _mergeItems ;
private ObjectsTemplate < ProcessItem > _processItems ;
private ObjectsTemplate < ITEmpHead > _assignedHeads ;
private ObjectsTemplate < BonusParameter > _projectionBonusParams ;
protected List < BonusParameter > _ApplicableBonusParams ;
protected double _projectedMonth ;
protected double _onceoffAmount ;
protected bool _isActualInvestment ;
ObjectsTemplate < OTProcess > _oTProcesss = null ;
#endregion Define Class Variable
public AbstractTaxCalculator ( )
{
_isActualInvestment = false ;
_salary = null ;
_taxSlabs = null ;
TaxParameter param = TaxParameter . Get ( Payroll . BO . SystemInformation . CurrentSysInfo . TaxParamID ) ;
_mergeItems = TaxMergeMaster . GetbyTaxParameter ( param . ID ) ;
if ( param ! = null )
_assignedHeads = ITEmpHead . Get ( param . ID . Integer ) ;
_processItems = ProcessItem . Get ( ) ;
_onceoffAmount = 0 ;
}
public AbstractTaxCalculator ( ID taxParameterID )
{
_isActualInvestment = false ;
_salary = null ;
_taxSlabs = null ;
TaxParameter param = TaxParameter . Get ( taxParameterID ) ;
_mergeItems = TaxMergeMaster . GetbyTaxParameter ( param . ID ) ;
if ( param ! = null )
_assignedHeads = ITEmpHead . Get ( param . ID . Integer ) ;
_processItems = ProcessItem . Get ( ) ;
_onceoffAmount = 0 ;
}
public abstract TaxParameter TaxParameter { set ; }
public abstract Employee Employee { set ; }
public abstract SalaryMonthly Salary { set ; }
public abstract ObjectsTemplate < ADParameter > AdParameters { set ; }
public ObjectsTemplate < IncomeTax > CurrentYearTax
{
get
{
if ( _currentYearTax = = null )
{
_currentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
}
return _currentYearTax ;
}
set
{
_currentYearTax = value ;
}
}
public BonusProcess . BonusProcessDetail Bonus
{
set
{
_bonus = value ;
}
}
public ObjectsTemplate < IncomeTax > Calculate ( )
{
ObjectsTemplate < IncomeTax > returnedItems = new ObjectsTemplate < IncomeTax > ( ) ;
return returnedItems ;
}
private void EmployeeSlab ( )
{
//TaxParameter.Get
}
private void Add ( IncomeTax taxItem )
{
if ( taxItem . Position = = 0 )
{
ProcessItem pitem = _processItems . Find ( delegate ( ProcessItem item )
{ return item . ItemCode = = ( int ) taxItem . ItemGroup ; } ) ;
if ( pitem = = null ) throw new ServiceException ( "Tax process item code not found in the process collection; Item Code:" + taxItem . ItemGroup . ToString ( ) ) ;
taxItem . Position = pitem . Position ;
}
IncomeTax existItem = _currentYearTax . Find ( delegate ( IncomeTax item )
{ return item . ItemGroup = = taxItem . ItemGroup & & item . ItemID = = taxItem . ItemID ; } ) ;
if ( existItem = = null ) _currentYearTax . Add ( taxItem ) ;
else
{
existItem . PreviousAmount = existItem . PreviousAmount + taxItem . PreviousAmount ;
existItem . ThisMonthAmount = existItem . ThisMonthAmount + taxItem . ThisMonthAmount ;
existItem . ProjectedAmount = existItem . ProjectedAmount + taxItem . ProjectedAmount ;
existItem . Position = taxItem . Position ;
existItem . Description = taxItem . Description ;
}
}
protected IncomeTax Add ( EnumIncomeTaxItemGroup group , int itemId ,
string description , double thismonthAmount ,
double projectedamount , EnumIncomeTaxSide side )
{
IncomeTax existItem = _currentYearTax . Find ( delegate ( IncomeTax item )
{ return item . ItemGroup = = group & & item . ItemID = = itemId ; } ) ;
if ( existItem = = null )
{
ProcessItem pitem = _processItems . Find ( delegate ( ProcessItem item )
{ return item . ItemCode = = ( int ) group ; } ) ;
if ( pitem = = null ) throw new ServiceException ( "Tax process item code not found in the process collection; Item Code:" + group . ToString ( ) ) ;
IncomeTax taxItem = new IncomeTax ( ) ;
taxItem . ItemGroup = group ;
taxItem . ItemID = itemId ;
taxItem . Description = ( description = = string . Empty ) ? pitem . UserDescription : description ;
taxItem . Position = pitem . Position ;
taxItem . PreviousAmount = projectedamount ;
taxItem . ThisMonthAmount = thismonthAmount ;
taxItem . ProjectedAmount = projectedamount ;
taxItem . EmployeeID = _employee . ID ;
taxItem . Side = side ;
_currentYearTax . Add ( taxItem ) ;
return taxItem ;
}
else
{
if ( existItem . Position = = 0 )
{
ProcessItem pitem = _processItems . Find ( delegate ( ProcessItem item )
{ return item . ItemCode = = ( int ) group ; } ) ;
if ( pitem = = null ) throw new ServiceException ( "Tax process item code not found in the process collection; Item Code:" + group . ToString ( ) ) ;
existItem . Position = pitem . Position ;
}
existItem . ThisMonthAmount = existItem . ThisMonthAmount + thismonthAmount ;
existItem . ProjectedAmount = existItem . ProjectedAmount + projectedamount ;
existItem . Description = description ;
existItem . Side = side ;
return existItem ;
}
}
protected void CalcualteprojectMonth ( )
{
//_projectedMonth = 12 - Ease.CoreV35.Utility.Global.DateFunctions.DateDiff ("m",
// SystemInformation.CurrentSysInfo.TaxYearEndDate,
// SystemInformation.CurrentSysInfo.NextPayProcessDate);
_projectedMonth = 12 - ( ( ( SystemInformation . CurrentSysInfo . NextPayProcessDate . Year - SystemInformation . CurrentSysInfo . TaxYearEndDate . Year ) * 12 )
+ SystemInformation . CurrentSysInfo . NextPayProcessDate . Month - SystemInformation . CurrentSysInfo . TaxYearEndDate . Month ) ;
if ( _projectedMonth < 0 ) _projectedMonth = 0 ;
//_projectedMonth= Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m",
// new DateTime(2010, 12, 31), new DateTime(2011, 6, 30));
if ( _employee . EndOfContractDate ! = null & & _employee . EndOfContractDate ! = DateTime . MinValue )
{
if ( _employee . EndOfContractDate < _taxParameter . FiscalyearDateTo )
_projectedMonth = GetProjectionMonth ( ( DateTime ) _employee . EndOfContractDate ) ;
}
}
protected void CalculateOT ( )
{
// find current month OT
//if (_oTProcesss == null)
// _oTProcesss = OTProcess.Get(SystemInformation.CurrentSysInfo.NextPayProcessDate);
//List<OTProcess> ops = _oTProcesss.FindAll(delegate(OTProcess item)
//{ return item.EmployeeID.Integer == _employee.ID.Integer; });
//if (ops == null) return;
//if (ops.Count == 0) return;
double opAmount = 0 ;
//foreach (OTProcess op in ops)
// opAmount += op.Amount;
foreach ( SalaryMonthlyDetail smd in _salary . Details )
{
if ( smd . ItemCode = = EnumSalaryItemCode . Over_Time_Amount )
opAmount + = smd . ChangedAmount ;
}
IncomeTax otItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . TimeCard , ( int ) EnumIncomeTaxItemGroup . TimeCard ) ;
if ( otItem = = null ) otItem = this . Add ( EnumIncomeTaxItemGroup . TimeCard , ( int ) EnumIncomeTaxItemGroup . TimeCard , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
// update this month amount
otItem . ThisMonthAmount = opAmount ;
otItem . ProjectedAmount = 0 ; // op.Amount* _projectedMonth;
otItem . Side = EnumIncomeTaxSide . Inc_SalaryIncome ;
}
private double GetProjectionMonth ( DateTime date )
{
double nFraction ;
//If Month is July then no need for Projection
if ( date . Month = = 7 )
nFraction = Convert . ToDouble ( 0 ) ;
else
nFraction = GlobalFunctions . Round ( GlobalFunctions . GetFraction ( SystemInformation . CurrentSysInfo . NextPayProcessDate . AddDays ( 1 ) , date ) ) ;
return nFraction ;
}
private double GetAmountfromSalary ( SalaryMonthlyDetail detail )
{
if ( detail . itemGroupCode = = EnumSalaryGroup . Arrear )
_onceoffAmount = _onceoffAmount + detail . ChangedAmount ;
if ( detail . itemGroupCode = = EnumSalaryGroup . Gross | | detail . itemGroupCode = = EnumSalaryGroup . Arrear )
return detail . ChangedAmount ;
else return - detail . ChangedAmount ;
}
private IncomeTax GetTaxItem ( EnumTaxMergeType type , int ItemId , string itemName )
{
IncomeTax taxItem = TaxMergeMaster . Extract (
_mergeItems , type , ItemId ) ;
if ( taxItem = = null ) throw new ServiceException ( "Tax setup not found for the Item :" + itemName ) ;
if ( taxItem ! = null )
taxItem . EmployeeID = _employee . ID ;
return taxItem ;
}
private IncomeTax GetTaxItem2 ( EnumTaxMergeType type , int ItemId , string itemName )
{
IncomeTax taxItem = TaxMergeMaster . Extract (
_mergeItems , type , ItemId ) ;
if ( taxItem = = null ) throw new ServiceException ( "Tax setup not found for the Item :" + itemName ) ;
if ( taxItem ! = null )
taxItem . EmployeeID = _employee . ID ;
return taxItem ;
}
protected void CalculateExemptionOnward2023 ( )
{
double annualIncome = this . GetAnnualIncome ( ) ;
IncomeTax exempted = _currentYearTax . FirstOrDefault ( x = > x . EmployeeID = = _employee . ID
& & x . ItemGroup = = EnumIncomeTaxItemGroup . AnnualExemption & & x . ItemID = = ( int ) EnumIncomeTaxItemGroup . AnnualExemption ) ;
if ( exempted = = null ) exempted = this . Add ( EnumIncomeTaxItemGroup . AnnualExemption ,
( int ) EnumIncomeTaxItemGroup . AnnualExemption , string . Empty , 0 , 0 ,
EnumIncomeTaxSide . Dec_AnnualIncome ) ;
if ( annualIncome > 0 )
{
exempted . ProjectedAmount = Math . Ceiling ( ( annualIncome / 3 ) * 1 ) ;
if ( exempted . ProjectedAmount > 500000 )
{
exempted . ProjectedAmount = 500000 ;
}
}
exempted . TotalAmount = exempted . ProjectedAmount ;
}
protected void InitializeForNextMonth ( )
{
//commented by ashek 15 feb 2016
//if (_currentYearTax == null || _currentYearTax.Count ==0)
//{
// _currentYearTax = new ObjectsTemplate<IncomeTax>();
// _currentYearTax = IncomeTax.Get(_employee.ID, EnumIncomeTaxDataFrom.ProcessTempData);
//}
if ( _currentYearTax = = null | | _currentYearTax . Count = = 0 )
{
_currentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
_currentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
}
foreach ( IncomeTax item in _currentYearTax )
{
item . PreviousAmount = item . PreviousAmount + item . ThisMonthAmount ;
item . ThisMonthAmount = 0 ;
item . ProjectedAmount = 0 ;
}
}
private SalaryMonthlyDetail CreateSalaryDetail ( string description , EnumSalaryItemCode itemCode , int itemid , ID supportid , double amount )
{
SalaryMonthlyDetail odetail = new SalaryMonthlyDetail ( ) ;
odetail . Description = description ;
odetail . itemGroupCode = EnumSalaryGroup . Gross ;
odetail . ItemCode = itemCode ;
odetail . ItemID = itemid ;
odetail . ChangedAmount = amount ;
odetail . SupportID = supportid ;
return odetail ;
}
protected void CalculateOnlyProjection ( )
{
foreach ( IncomeTax item in this . CurrentYearTax )
item . ProjectedAmount = 0 ;
List < ADParameter > adParams = null ;
ObjectsTemplate < ADParameterEmployee > adParamEmps = null ;
EmployeeGradeSalary oEmpGSalary = new EmployeeGradeSalary ( ) ;
List < TaxRawItem > rawItems = new List < TaxRawItem > ( ) ;
_projectedMonth = _projectedMonth + 1 ;
_salary = new SalaryMonthly ( ) ;
_salary . Details . Add ( this . CreateSalaryDetail ( "Basic Salary" , EnumSalaryItemCode . Basic_Salary , ( int ) EnumSalaryItemCode . Basic_Salary , ID . FromInteger ( 0 ) , _employee . BasicSalary ) ) ;
if ( _adParameters = = null ) _adParameters = ADParameter . Get ( EnumStatus . Regardless , EnumAllowOrDeduct . Allowance ) ;
adParams = ADParameter . GetApplicableParameters ( _employee , _employee . GradeID , _adParameters ) ;
if ( adParams ! = null )
{
foreach ( ADParameter adParam in adParams )
{
if ( adParam . EntitleType = = EnumEntitleType . Grade )
_salary . Details . Add ( this . CreateSalaryDetail ( adParam . AllowanceDeduction . Name ,
EnumSalaryItemCode . Allowance , adParam . AllowanceDeduction . ID . Integer , adParam . ID , adParam . GetGradeDefinedAmount ( _employee , _employee . BasicSalary ,
_employee . GrossSalary , new EmployeeGradeSalary ( ) ) ) ) ;
}
}
adParamEmps = ADParameterEmployee . GetByEmployee ( _employee . ID , EnumAllowOrDeduct . Allowance , EnumADEmpType . AppliedToIndividual ) ;
if ( adParamEmps ! = null )
{
foreach ( ADParameterEmployee adEmp in adParamEmps )
{
_salary . Details . Add ( this . CreateSalaryDetail ( adEmp . AllowDeduct . Name ,
EnumSalaryItemCode . Allowance , adEmp . AllowDeduct . ID . Integer , adEmp . ADParameterID , adEmp . MonthlyAmount ) ) ;
}
}
this . IncludePayslipItems ( ) ;
foreach ( IncomeTax item in this . CurrentYearTax )
{
item . PreviousAmount = 0 ;
item . ThisMonthAmount = 0 ;
}
}
private bool IsExamptedItem ( IncomeTax Item )
{
bool IsExamptedItem = false ;
if ( Item . ItemGroup = = EnumIncomeTaxItemGroup . House_Rent_Allowance )
IsExamptedItem = true ;
else if ( Item . ItemGroup = = EnumIncomeTaxItemGroup . Conveyance_Allowance )
IsExamptedItem = true ;
else if ( Item . ItemGroup = = EnumIncomeTaxItemGroup . Medical_Allowance )
IsExamptedItem = true ;
else if ( Item . ItemGroup = = EnumIncomeTaxItemGroup . LFA_Allowance )
IsExamptedItem = true ;
return IsExamptedItem ;
}
private IncomeTax PayslipAllowanceDeduction ( SalaryMonthlyDetail salaryDetail , EnumTaxMergeType type )
{
EmployeeGradeSalary oEmpGSalary = new EmployeeGradeSalary ( ) ;
IncomeTax item = null ;
ADParameter adparameter = _adParameters . GetItem ( salaryDetail . SupportID ) ;
if ( adparameter = = null )
throw new ServiceException ( "Allowance/deduction parameter not found for " + salaryDetail . Description ) ;
if ( adparameter . IsTaxable = = false ) return null ;
item = this . GetTaxItem ( type , salaryDetail . ItemID , salaryDetail . Description ) ;
item . ThisMonthAmount = GlobalFunctions . Round ( item . ThisMonthAmount + GetAmountfromSalary ( salaryDetail ) ) ;
if ( adparameter . Periodicity = = EnumPeriodicity . OneOff )
{
if ( IsExamptedItem ( item ) = = false )
_onceoffAmount = _onceoffAmount + item . ThisMonthAmount ;
}
else
{
if ( salaryDetail . itemGroupCode = = EnumSalaryGroup . Gross )
{
if ( adparameter . EntitleType = = EnumEntitleType . Grade )
item . ProjectedAmount = GlobalFunctions . Round ( adparameter . GetGradeDefinedAmount ( _employee , _employee . BasicSalary , _employee . GrossSalary , oEmpGSalary ) ) * _projectedMonth ;
else
{
DateTime fromDate = GlobalFunctions . FirstDateOfMonth ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
DateTime toDate = SystemInformation . CurrentSysInfo . NextPayProcessDate ;
if ( salaryDetail . SupportID ! = null )
{
ADParameterEmployee oempadp = salaryDetail . ADParamEmployee ;
if ( oempadp = = null )
oempadp = ADParameterEmployee . Get ( _employee . ID , ID . FromInteger ( salaryDetail . ItemID ) , salaryDetail . SupportID , EnumArrearType . NotPresent ) ;
//ADParameterEmployee oempadp = ADParameterEmployee.Get(_employee.ID, ID.FromInteger(salaryDetail.ItemID), salaryDetail.SupportID);
if ( oempadp ! = null )
{
fromDate = GlobalFunctions . FirstDateOfMonth ( SystemInformation . CurrentSysInfo . NextPayProcessDate . AddMonths ( 1 ) ) ;
if ( oempadp . TillDate = = null | | oempadp . TillDate = = DateTime . MinValue )
toDate = _taxParameter . FiscalyearDateTo ;
else toDate = ( DateTime ) oempadp . TillDate ;
double nproject = 0 ;
if ( fromDate > toDate ) nproject = 0 ;
else
{
if ( toDate > _taxParameter . FiscalyearDateTo ) toDate = _taxParameter . FiscalyearDateTo ;
nproject = GlobalFunctions . GetFraction ( fromDate , toDate ) ;
}
//if (item.ItemGroup == EnumIncomeTaxItemGroup.Other_Allowance && item.ItemID==27)
// item.ProjectedAmount = GlobalFunctions.Round(oempadp.GetAmount(_employee.BasicSalary, 0)) * 6;
//else
item . ProjectedAmount = GlobalFunctions . Round ( oempadp . GetAmount ( _employee . BasicSalary , 0 ) ) * nproject ;
}
else item . ProjectedAmount = GlobalFunctions . Round ( item . ThisMonthAmount ) * _projectedMonth ;
}
else item . ProjectedAmount = GlobalFunctions . Round ( item . ThisMonthAmount ) * _projectedMonth ;
}
}
}
return item ;
}
protected void IncludePayslipItems ( )
{
foreach ( SalaryMonthlyDetail salaryDetail in _salary . Details )
{
IncomeTax item = null ;
switch ( salaryDetail . ItemCode )
{
case EnumSalaryItemCode . Basic_Salary :
item = GetTaxItem ( EnumTaxMergeType . NONE , ( int ) EnumIncomeTaxItemGroup . Basic_Salary , salaryDetail . Description ) ;
item . ThisMonthAmount = GlobalFunctions . Round ( GetAmountfromSalary ( salaryDetail ) ) ;
if ( salaryDetail . itemGroupCode = = EnumSalaryGroup . Gross ) item . ProjectedAmount = GlobalFunctions . Round ( _employee . BasicSalary ) * _projectedMonth ;
break ;
case EnumSalaryItemCode . Over_Time_Amount :
item = GetTaxItem ( EnumTaxMergeType . OT , salaryDetail . ItemID , salaryDetail . Description ) ;
if ( item = = null ) throw new ServiceException ( "Tax grouping not found for " + salaryDetail . Description ) ;
item . ThisMonthAmount = GlobalFunctions . Round ( GetAmountfromSalary ( salaryDetail ) ) ;
this . _onceoffAmount = this . _onceoffAmount + item . ThisMonthAmount ;
break ;
case EnumSalaryItemCode . Bonus :
item = GetTaxItem ( EnumTaxMergeType . Bonus , salaryDetail . ItemID , salaryDetail . Description ) ;
if ( item = = null ) throw new ServiceException ( "Tax grouping not found for " + salaryDetail . Description ) ;
item . ThisMonthAmount = GlobalFunctions . Round ( GetAmountfromSalary ( salaryDetail ) ) ;
// this._onceoffAmount = this._onceoffAmount + item.ThisMonthAmount;
break ;
case EnumSalaryItemCode . Allowance :
item = this . PayslipAllowanceDeduction ( salaryDetail , EnumTaxMergeType . Allowance ) ;
if ( item = = null ) continue ;
if ( item . ItemGroup = = EnumIncomeTaxItemGroup . Conveyance_Allowance )
{
DataSet ds = IncomeTax . GetTaxAdj ( EnumIncomeTaxItemGroup . Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Conveyance_Allowance , _employee . ID ) ;
if ( ds ! = null & & ds . Tables . Count > 0 )
{
foreach ( DataRow dr in ds . Tables [ 0 ] . Rows )
{
item . ThisMonthAmount = Convert . ToDouble ( dr [ 6 ] . ToString ( ) ) ;
}
}
}
break ;
case EnumSalaryItemCode . Deduction :
item = this . PayslipAllowanceDeduction ( salaryDetail , EnumTaxMergeType . Deduction ) ;
if ( item = = null ) continue ; // throw new ServiceException("Tax grouping not found for " + salaryDetail.Description);
item . ThisMonthAmount = GlobalFunctions . Round ( GetAmountfromSalary ( salaryDetail ) ) ;
//if (item == null) continue;
break ;
//case EnumSalaryItemCode.PF_Contribution:
// item = GetTaxItem(EnumTaxMergeType.NONE, (int)EnumIncomeTaxItemGroup.Company_Contri_PF, salaryDetail.Description);
// item.ThisMonthAmount =GlobalFunctions.Round(GetAmountfromSalary(salaryDetail));
// break;
default :
break ;
}
if ( item ! = null )
{
if ( salaryDetail . itemGroupCode = = EnumSalaryGroup . Deductions )
{
item . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
}
else
{ item . Side = EnumIncomeTaxSide . Inc_SalaryIncome ; }
}
if ( item ! = null & & item . ThisMonthAmount ! = 0 ) this . Add ( item ) ;
}
}
protected void CalculateExamtion ( )
{
this . CalculateExemptionOnward2023 ( ) ;
return ;
#region get Examtion items from processItem
var examtionItems = from pItem in _processItems
where pItem . ItemGroup = = 7
select pItem ;
#endregion
bool monthlyexemption = true ; // ConfigurationManager.GetBoolValue("incometax", "monthlyexemption", EnumConfigurationType.Logic);
ObjectsTemplate < EmpLifeCycle > oCycles = EmpLifeCycle . GetByEmpID ( _employee . ID ) ;
foreach ( var processItem in examtionItems )
{
double tempAmount = 0 ;
#region House rent allowance
if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance )
{
IncomeTax basicItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Basic_Salary , ( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
IncomeTax HRItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . House_Rent_Allowance ) ;
if ( HRItem = = null | | HRItem . TotalAmount = = 0 ) continue ; //throw new ServiceException("House rent allowance not found in the collection while calculating HR Examtion");
//continue; //
IncomeTax HrExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance ) ;
if ( HrExption = = null ) HrExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance ,
( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
//if (oCycles != null && oCycles.Count>0)
//{
// EmpLifeCycle cycle = oCycles.Find(x => x.IsContinue==true);
// if (cycle != null)
// _employee.JoiningDate = cycle.EffectDate;
//}
if ( _employee . JoiningDate < new DateTime ( _taxParameter . FiscalyearDatefrom . Year , 7 , 1 ) )
{
monthlyexemption = false ;
}
else
monthlyexemption = true ;
if ( monthlyexemption = = false )
{
HrExption . ProjectedAmount = 0 ;
HrExption . ThisMonthAmount = 0 ;
HrExption . PreviousAmount = 0 ;
HrExption . TotalAmount = 0 ;
if ( _taxParameter . MaxHRPercent ! = 0 )
{
double hrAmount = ( basicItem . TotalAmount * _taxParameter . MaxHRPercent ) / 100 ;
if ( hrAmount > _taxParameter . MaxHRAmount )
HrExption . ProjectedAmount = _taxParameter . MaxHRAmount ;
else HrExption . ProjectedAmount = hrAmount ;
if ( HrExption . TotalAmount > HRItem . TotalAmount | | Math . Abs ( HrExption . TotalAmount - HRItem . TotalAmount ) < 10 )
HrExption . ProjectedAmount = HRItem . TotalAmount -
( HrExption . ThisMonthAmount + HrExption . PreviousAmount ) ;
}
else
{
if ( HRItem . TotalAmount > _taxParameter . MaxHRAmount )
HrExption . ProjectedAmount = _taxParameter . MaxHRAmount ;
else HrExption . ProjectedAmount = HRItem . TotalAmount ;
if ( HrExption . TotalAmount > HRItem . TotalAmount | | Math . Abs ( HrExption . TotalAmount - HRItem . TotalAmount ) < 10 )
HrExption . ProjectedAmount = HRItem . TotalAmount -
( HrExption . ThisMonthAmount + HrExption . PreviousAmount ) ;
}
}
else
{
#region monthly Examption
//if (HRItem.TotalAmount > _taxParameter.MaxHRAmount)
//{
// tempAmount = _taxParameter.MaxHRAmount - HrExption.PreviousAmount;
// HrExption.ThisMonthAmount = tempAmount / (_projectedMonth + 1);
// HrExption.ProjectedAmount = _taxParameter.MaxHRAmount -
// (HrExption.ThisMonthAmount + HrExption.PreviousAmount);
// if (HrExption.TotalAmount > _taxParameter.MaxHRAmount || Math.Abs(HrExption.TotalAmount - HRItem.TotalAmount) < 10)
// HrExption.ProjectedAmount = HrExption.TotalAmount - _taxParameter.MaxHRAmount;
//}
//else
//{
double def = 0 ;
double nFracAmount = 0 ;
#region This code needed for only this month to calculate previous month
double maxMonthlyAmount = _taxParameter . MaxHRAmount / 12 ;
if ( HrExption . PreviousAmount = = 0 & & _employee . JoiningDate < new DateTime ( _taxParameter . FiscalyearDatefrom . Year , 7 , 1 ) )
{
if ( maxMonthlyAmount * 7 < HRItem . PreviousAmount )
{
HrExption . PreviousAmount = maxMonthlyAmount * 7 ;
}
else HrExption . PreviousAmount = HRItem . PreviousAmount ;
}
else
{
if ( HRItem . ThisMonthAmount < maxMonthlyAmount )
maxMonthlyAmount = HRItem . ThisMonthAmount ;
if ( _employee . JoiningDate = = GlobalFunctions . FirstDateOfMonth ( _employee . JoiningDate ) )
def = Global . DateFunctions . DateDiff ( "m" , _employee . JoiningDate , GlobalFunctions . LastDateOfMonth ( _taxParameter . FiscalyearDateTo ) ) + 1 ;
else
{
def = Global . DateFunctions . DateDiff ( "m" , _employee . JoiningDate , GlobalFunctions . LastDateOfMonth ( _taxParameter . FiscalyearDateTo ) ) ;
TimeSpan ts = GlobalFunctions . LastDateOfMonth ( _employee . JoiningDate ) - _employee . JoiningDate ;
nFracAmount = ( maxMonthlyAmount / ( double ) DateTime . DaysInMonth ( _employee . JoiningDate . Year , _employee . JoiningDate . Month ) ) * ( ( double ) ts . Days + 1 ) ;
}
HrExption . PreviousAmount = ( maxMonthlyAmount * def ) + nFracAmount ;
}
if ( HRItem . ThisMonthAmount < maxMonthlyAmount )
{
double nBasic = basicItem . ThisMonthAmount * def ;
nBasic = ( nBasic * 50 ) / 100 ;
if ( HrExption . PreviousAmount < nBasic )
HrExption . PreviousAmount = nBasic ;
}
#endregion
if ( maxMonthlyAmount < HRItem . ThisMonthAmount )
{
HrExption . ThisMonthAmount = maxMonthlyAmount ;
HrExption . ProjectedAmount = maxMonthlyAmount * _projectedMonth ;
}
else
{
HrExption . ThisMonthAmount = HRItem . ThisMonthAmount ;
HrExption . ProjectedAmount = HRItem . ThisMonthAmount * _projectedMonth ;
if ( _salary ! = null & & _salary . Details . Any ( x = > x . itemGroupCode = = EnumSalaryGroup . UnauthLeave ) )
{
double unhraount = 0 ;
SalaryMonthlyDetail odt = _salary . Details . FirstOrDefault ( x = > x . itemGroupCode = = EnumSalaryGroup . Gross
& & x . ItemCode = = EnumSalaryItemCode . Allowance & & x . ItemID = = 1 ) ;
if ( odt ! = null )
unhraount = odt . ChangedAmount ;
HrExption . ProjectedAmount = ( unhraount + HRItem . ThisMonthAmount ) * _projectedMonth ;
}
}
// HrExption.ThisMonthAmount = HRItem.ThisMonthAmount;
//tempAmount = HRItem.TotalAmount - HrExption.PreviousAmount;
//HrExption.ThisMonthAmount = HRItem.ThisMonthAmount;
//HrExption.ProjectedAmount = HRItem.ProjectedAmount;
//if (HrExption.TotalAmount > HRItem.TotalAmount || Math.Abs(HrExption.TotalAmount - HRItem.TotalAmount) < 10)
// HrExption.ProjectedAmount = HRItem.TotalAmount -
// (HrExption.ThisMonthAmount + HrExption.PreviousAmount);
//}
#endregion monthly Examption
}
if ( _employee . JoiningDate < new DateTime ( _taxParameter . FiscalyearDatefrom . Year , 7 , 1 ) )
{
HrExption . ThisMonthAmount = GlobalFunctions . Round ( HrExption . ThisMonthAmount ) ;
HrExption . ProjectedAmount = GlobalFunctions . Round ( HrExption . ProjectedAmount ) ;
HrExption . TotalAmount = HrExption . ThisMonthAmount + HrExption . PreviousAmount + HrExption . ProjectedAmount ;
}
else
{
HrExption . ThisMonthAmount = 0 ;
HrExption . ProjectedAmount = 0 ;
}
DataSet ds = IncomeTax . GetTaxAdj ( EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , _employee . ID ) ;
if ( ds ! = null & & ds . Tables . Count > 0 )
{
foreach ( DataRow dr in ds . Tables [ 0 ] . Rows )
{
HrExption . PreviousAmount = Convert . ToDouble ( dr [ 4 ] . ToString ( ) ) ;
}
}
HrExption . TotalAmount = HrExption . PreviousAmount ;
}
#endregion House rent allowance
#region Conveyance Allowance Examtion
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance )
{
monthlyexemption = false ;
IncomeTax CnvItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Conveyance_Allowance ) ;
if ( CnvItem = = null | | CnvItem . TotalAmount = = 0 ) continue ;
IncomeTax CvExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance ) ;
if ( CvExption = = null ) CvExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
IncomeTax taxItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Cmp_Provided_car , ( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car ) ;
if ( taxItem ! = null & & taxItem . TotalAmount > 0 )
{
CvExption . ThisMonthAmount = 0 ;
CvExption . ProjectedAmount = 0 ;
CvExption . PreviousAmount = 0 ;
continue ;
}
if ( monthlyexemption = = false )
{
CvExption . TotalAmount = 0 ;
CvExption . ProjectedAmount = 0 ;
CvExption . PreviousAmount = 0 ;
CvExption . ThisMonthAmount = 0 ;
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount | | Math . Abs ( CnvItem . TotalAmount - _taxParameter . MaxConvAmount ) < 10 )
CvExption . ProjectedAmount = _taxParameter . MaxConvAmount ;
else CvExption . ProjectedAmount = CnvItem . TotalAmount ;
}
else
{
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount )
CvExption . ThisMonthAmount = _taxParameter . MaxConvAmount / 12 ;
else CvExption . ThisMonthAmount = CnvItem . ThisMonthAmount ;
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount | | Math . Abs ( CnvItem . TotalAmount - _taxParameter . MaxConvAmount ) < 10 )
{
CvExption . ProjectedAmount = _taxParameter . MaxConvAmount - (
CvExption . ThisMonthAmount + CvExption . PreviousAmount ) ;
}
else
{
CvExption . ProjectedAmount = CnvItem . TotalAmount - (
CvExption . ThisMonthAmount + CvExption . PreviousAmount ) ;
}
}
CvExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
CvExption . ThisMonthAmount = GlobalFunctions . Round ( CvExption . ThisMonthAmount ) ;
CvExption . ProjectedAmount = GlobalFunctions . Round ( CvExption . ProjectedAmount ) ;
CvExption . TotalAmount = CvExption . ThisMonthAmount + CvExption . PreviousAmount + CvExption . ProjectedAmount ;
}
#endregion Conveyance Allowance Examtion
#region Other Allowance Examption
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance )
{
monthlyexemption = false ;
IncomeTax MedicalItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Medical_Allowance ) ;
if ( MedicalItem = = null ) continue ; //throw new ServiceException("Conveyance allowance not found in the collection while calculating HR Examtion");
IncomeTax mdExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance ) ;
if ( mdExption = = null ) mdExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
IncomeTax basicItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Basic_Salary , ( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
//Sumon on 24 June 2014
double nMamount = 0 ;
if ( basicItem ! = null ) nMamount = basicItem . TotalAmount *
( double ) ( ( _taxParameter . MaxMedicalPercent ! = 0 ) ? _taxParameter . MaxMedicalPercent / 100 : 0 ) ;
if ( MedicalItem = = null | | MedicalItem . TotalAmount = = 0 )
mdExption . ProjectedAmount = 0.00 ;
else if ( nMamount > _taxParameter . MaxMedicalAmount )
mdExption . ProjectedAmount = MedicalItem . TotalAmount < _taxParameter . MaxMedicalAmount ? MedicalItem . TotalAmount : GlobalFunctions . Round ( _taxParameter . MaxMedicalAmount ) ;
else
mdExption . ProjectedAmount = MedicalItem . TotalAmount > nMamount ? MedicalItem . TotalAmount : GlobalFunctions . Round ( nMamount ) ;
//End
//mdExption.ProjectedAmount =GlobalFunctions.Round(MedicalItem.TotalAmount);
mdExption . TotalAmount = mdExption . ThisMonthAmount + mdExption . PreviousAmount + mdExption . ProjectedAmount ;
if ( MedicalItem . TotalAmount < mdExption . TotalAmount )
{
mdExption . PreviousAmount = MedicalItem . PreviousAmount ;
mdExption . ThisMonthAmount = MedicalItem . ThisMonthAmount ;
mdExption . ProjectedAmount = MedicalItem . ProjectedAmount ;
}
mdExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
// this.Add(mdExption);
}
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance )
{
IncomeTax LFAItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . LFA_Allowance ) ;
if ( LFAItem = = null ) continue ; // throw new ServiceException("LFA allowance not found in the collection while calculating HR Examtion");
//continue; //
IncomeTax lfaExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance ) ;
if ( lfaExption = = null ) lfaExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
lfaExption . ProjectedAmount = GlobalFunctions . Round ( LFAItem . TotalAmount ) ;
lfaExption . TotalAmount = lfaExption . ThisMonthAmount + lfaExption . PreviousAmount + lfaExption . ProjectedAmount ;
lfaExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
// this.Add(mdExption);
}
#endregion Other Allowance Examption
}
}
protected void CalculateExamtionPrev ( )
{
#region get Examtion items from processItem
var examtionItems = from pItem in _processItems
where pItem . ItemGroup = = 7
select pItem ;
#endregion
bool monthlyexemption = true ; // ConfigurationManager.GetBoolValue("incometax", "monthlyexemption", EnumConfigurationType.Logic);
ObjectsTemplate < EmpLifeCycle > oCycles = EmpLifeCycle . GetByEmpID ( _employee . ID ) ;
foreach ( var processItem in examtionItems )
{
double tempAmount = 0 ;
#region House rent allowance
if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance )
{
IncomeTax basicItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Basic_Salary , ( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
IncomeTax HRItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . House_Rent_Allowance ) ;
if ( HRItem = = null | | HRItem . TotalAmount = = 0 ) continue ; //throw new ServiceException("House rent allowance not found in the collection while calculating HR Examtion");
//continue; //
IncomeTax HrExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance ) ;
if ( HrExption = = null ) HrExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance ,
( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
//if (oCycles != null && oCycles.Count>0)
//{
// EmpLifeCycle cycle = oCycles.Find(x => x.IsContinue==true);
// if (cycle != null)
// _employee.JoiningDate = cycle.EffectDate;
//}
if ( _employee . JoiningDate < new DateTime ( 2016 , 7 , 1 ) )
{
monthlyexemption = false ;
}
else
monthlyexemption = true ;
if ( monthlyexemption = = false )
{
HrExption . ProjectedAmount = 0 ;
HrExption . ThisMonthAmount = 0 ;
HrExption . PreviousAmount = 0 ;
HrExption . TotalAmount = 0 ;
if ( _taxParameter . MaxHRPercent ! = 0 )
{
double hrAmount = ( basicItem . TotalAmount * _taxParameter . MaxHRPercent ) / 100 ;
if ( hrAmount > _taxParameter . MaxHRAmount )
HrExption . ProjectedAmount = _taxParameter . MaxHRAmount ;
else HrExption . ProjectedAmount = hrAmount ;
if ( HrExption . TotalAmount > HRItem . TotalAmount | | Math . Abs ( HrExption . TotalAmount - HRItem . TotalAmount ) < 10 )
HrExption . ProjectedAmount = HRItem . TotalAmount -
( HrExption . ThisMonthAmount + HrExption . PreviousAmount ) ;
}
else
{
if ( HRItem . TotalAmount > _taxParameter . MaxHRAmount )
HrExption . ProjectedAmount = _taxParameter . MaxHRAmount ;
else HrExption . ProjectedAmount = HRItem . TotalAmount ;
if ( HrExption . TotalAmount > HRItem . TotalAmount | | Math . Abs ( HrExption . TotalAmount - HRItem . TotalAmount ) < 10 )
HrExption . ProjectedAmount = HRItem . TotalAmount -
( HrExption . ThisMonthAmount + HrExption . PreviousAmount ) ;
}
}
else
{
#region monthly Examption
//if (HRItem.TotalAmount > _taxParameter.MaxHRAmount)
//{
// tempAmount = _taxParameter.MaxHRAmount - HrExption.PreviousAmount;
// HrExption.ThisMonthAmount = tempAmount / (_projectedMonth + 1);
// HrExption.ProjectedAmount = _taxParameter.MaxHRAmount -
// (HrExption.ThisMonthAmount + HrExption.PreviousAmount);
// if (HrExption.TotalAmount > _taxParameter.MaxHRAmount || Math.Abs(HrExption.TotalAmount - HRItem.TotalAmount) < 10)
// HrExption.ProjectedAmount = HrExption.TotalAmount - _taxParameter.MaxHRAmount;
//}
//else
//{
double def = 0 ;
double nFracAmount = 0 ;
#region This code needed for only this month to calculate previous month
double maxMonthlyAmount = _taxParameter . MaxHRAmount / 12 ;
if ( HrExption . PreviousAmount = = 0 & & _employee . JoiningDate < new DateTime ( 2016 , 7 , 1 ) )
{
if ( maxMonthlyAmount * 7 < HRItem . PreviousAmount )
{
HrExption . PreviousAmount = maxMonthlyAmount * 7 ;
}
else HrExption . PreviousAmount = HRItem . PreviousAmount ;
}
else
{
if ( HRItem . ThisMonthAmount < maxMonthlyAmount )
maxMonthlyAmount = HRItem . ThisMonthAmount ;
if ( _employee . JoiningDate = = GlobalFunctions . FirstDateOfMonth ( _employee . JoiningDate ) )
def = Global . DateFunctions . DateDiff ( "m" , _employee . JoiningDate , GlobalFunctions . LastDateOfMonth ( _taxParameter . FiscalyearDateTo ) ) + 1 ;
else
{
def = Global . DateFunctions . DateDiff ( "m" , _employee . JoiningDate , GlobalFunctions . LastDateOfMonth ( _taxParameter . FiscalyearDateTo ) ) ;
TimeSpan ts = GlobalFunctions . LastDateOfMonth ( _employee . JoiningDate ) - _employee . JoiningDate ;
nFracAmount = ( maxMonthlyAmount / ( double ) DateTime . DaysInMonth ( _employee . JoiningDate . Year , _employee . JoiningDate . Month ) ) * ( ( double ) ts . Days + 1 ) ;
}
HrExption . PreviousAmount = ( maxMonthlyAmount * def ) + nFracAmount ;
}
if ( HRItem . ThisMonthAmount < maxMonthlyAmount )
{
double nBasic = basicItem . ThisMonthAmount * def ;
nBasic = ( nBasic * 50 ) / 100 ;
if ( HrExption . PreviousAmount < nBasic )
HrExption . PreviousAmount = nBasic ;
}
#endregion
if ( maxMonthlyAmount < HRItem . ThisMonthAmount )
{
HrExption . ThisMonthAmount = maxMonthlyAmount ;
HrExption . ProjectedAmount = maxMonthlyAmount * _projectedMonth ;
}
else
{
HrExption . ThisMonthAmount = HRItem . ThisMonthAmount ;
HrExption . ProjectedAmount = HRItem . ThisMonthAmount * _projectedMonth ;
if ( _salary ! = null & & _salary . Details . Any ( x = > x . itemGroupCode = = EnumSalaryGroup . UnauthLeave ) )
{
double unhraount = 0 ;
SalaryMonthlyDetail odt = _salary . Details . FirstOrDefault ( x = > x . itemGroupCode = = EnumSalaryGroup . Gross
& & x . ItemCode = = EnumSalaryItemCode . Allowance & & x . ItemID = = 1 ) ;
if ( odt ! = null )
unhraount = odt . ChangedAmount ;
HrExption . ProjectedAmount = ( unhraount + HRItem . ThisMonthAmount ) * _projectedMonth ;
}
}
// HrExption.ThisMonthAmount = HRItem.ThisMonthAmount;
//tempAmount = HRItem.TotalAmount - HrExption.PreviousAmount;
//HrExption.ThisMonthAmount = HRItem.ThisMonthAmount;
//HrExption.ProjectedAmount = HRItem.ProjectedAmount;
//if (HrExption.TotalAmount > HRItem.TotalAmount || Math.Abs(HrExption.TotalAmount - HRItem.TotalAmount) < 10)
// HrExption.ProjectedAmount = HRItem.TotalAmount -
// (HrExption.ThisMonthAmount + HrExption.PreviousAmount);
//}
#endregion monthly Examption
}
if ( _employee . JoiningDate < new DateTime ( 2016 , 7 , 1 ) )
{
HrExption . ThisMonthAmount = GlobalFunctions . Round ( HrExption . ThisMonthAmount ) ;
HrExption . ProjectedAmount = GlobalFunctions . Round ( HrExption . ProjectedAmount ) ;
HrExption . TotalAmount = HrExption . ThisMonthAmount + HrExption . PreviousAmount + HrExption . ProjectedAmount ;
}
else
{
HrExption . ThisMonthAmount = 0 ;
HrExption . ProjectedAmount = 0 ;
}
DataSet ds = IncomeTax . GetTaxAdj ( EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_House_Rent_Allowance , _employee . ID ) ;
if ( ds ! = null & & ds . Tables . Count > 0 )
{
foreach ( DataRow dr in ds . Tables [ 0 ] . Rows )
{
HrExption . PreviousAmount = Convert . ToDouble ( dr [ 4 ] . ToString ( ) ) ;
HrExption . TotalAmount = HrExption . PreviousAmount ;
}
}
}
#endregion House rent allowance
#region Conveyance Allowance Examtion
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance )
{
monthlyexemption = false ;
IncomeTax CnvItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Conveyance_Allowance ) ;
if ( CnvItem = = null | | CnvItem . TotalAmount = = 0 ) continue ;
IncomeTax CvExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance ) ;
if ( CvExption = = null ) CvExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
IncomeTax taxItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Cmp_Provided_car , ( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car ) ;
if ( taxItem ! = null & & taxItem . TotalAmount > 0 )
{
CvExption . ThisMonthAmount = 0 ;
CvExption . ProjectedAmount = 0 ;
CvExption . PreviousAmount = 0 ;
continue ;
}
if ( monthlyexemption = = false )
{
CvExption . TotalAmount = 0 ;
CvExption . ProjectedAmount = 0 ;
CvExption . PreviousAmount = 0 ;
CvExption . ThisMonthAmount = 0 ;
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount | | Math . Abs ( CnvItem . TotalAmount - _taxParameter . MaxConvAmount ) < 10 )
CvExption . ProjectedAmount = _taxParameter . MaxConvAmount ;
else CvExption . ProjectedAmount = CnvItem . TotalAmount ;
}
else
{
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount )
CvExption . ThisMonthAmount = _taxParameter . MaxConvAmount / 12 ;
else CvExption . ThisMonthAmount = CnvItem . ThisMonthAmount ;
if ( CnvItem . TotalAmount > _taxParameter . MaxConvAmount | | Math . Abs ( CnvItem . TotalAmount - _taxParameter . MaxConvAmount ) < 10 )
{
CvExption . ProjectedAmount = _taxParameter . MaxConvAmount - (
CvExption . ThisMonthAmount + CvExption . PreviousAmount ) ;
}
else
{
CvExption . ProjectedAmount = CnvItem . TotalAmount - (
CvExption . ThisMonthAmount + CvExption . PreviousAmount ) ;
}
}
CvExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
CvExption . ThisMonthAmount = GlobalFunctions . Round ( CvExption . ThisMonthAmount ) ;
CvExption . ProjectedAmount = GlobalFunctions . Round ( CvExption . ProjectedAmount ) ;
CvExption . TotalAmount = CvExption . ThisMonthAmount + CvExption . PreviousAmount + CvExption . ProjectedAmount ;
}
#endregion Conveyance Allowance Examtion
#region Other Allowance Examption
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance )
{
monthlyexemption = false ;
IncomeTax MedicalItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Medical_Allowance ) ;
if ( MedicalItem = = null ) continue ; //throw new ServiceException("Conveyance allowance not found in the collection while calculating HR Examtion");
IncomeTax mdExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance ) ;
if ( mdExption = = null ) mdExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Medical_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
IncomeTax basicItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Basic_Salary , ( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
//Sumon on 24 June 2014
double nMamount = 0 ;
if ( basicItem ! = null ) nMamount = basicItem . TotalAmount *
( double ) ( ( _taxParameter . MaxMedicalPercent ! = 0 ) ? _taxParameter . MaxMedicalPercent / 100 : 0 ) ;
if ( MedicalItem = = null | | MedicalItem . TotalAmount = = 0 )
mdExption . ProjectedAmount = 0.00 ;
else if ( nMamount > _taxParameter . MaxMedicalAmount )
mdExption . ProjectedAmount = MedicalItem . TotalAmount < _taxParameter . MaxMedicalAmount ? MedicalItem . TotalAmount : GlobalFunctions . Round ( _taxParameter . MaxMedicalAmount ) ;
else
mdExption . ProjectedAmount = MedicalItem . TotalAmount > nMamount ? GlobalFunctions . Round ( nMamount ) : MedicalItem . TotalAmount ;
//End
//mdExption.ProjectedAmount =GlobalFunctions.Round(MedicalItem.TotalAmount);
mdExption . TotalAmount = mdExption . ThisMonthAmount + mdExption . PreviousAmount + mdExption . ProjectedAmount ;
mdExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
// this.Add(mdExption);
}
else if ( processItem . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance )
{
IncomeTax LFAItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . LFA_Allowance ) ;
if ( LFAItem = = null ) continue ; // throw new ServiceException("LFA allowance not found in the collection while calculating HR Examtion");
//continue; //
IncomeTax lfaExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance ) ;
if ( lfaExption = = null ) lfaExption = this . Add ( EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_LFA_Allowance , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_SalaryIncome ) ;
lfaExption . ProjectedAmount = GlobalFunctions . Round ( LFAItem . TotalAmount ) ;
lfaExption . TotalAmount = lfaExption . ThisMonthAmount + lfaExption . PreviousAmount + lfaExption . ProjectedAmount ;
lfaExption . Side = EnumIncomeTaxSide . Dec_SalaryIncome ;
// this.Add(mdExption);
}
#endregion Other Allowance Examption
}
}
protected void CalculateCPF ( )
{
if ( _employee . PFMemberType ! = EnumPFMembershipType . Live ) return ;
IncomeTax pfItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Company_Contri_PF , ( int ) EnumIncomeTaxItemGroup . Company_Contri_PF ) ;
if ( pfItem = = null ) pfItem = this . Add ( EnumIncomeTaxItemGroup . Company_Contri_PF , ( int ) EnumIncomeTaxItemGroup . Company_Contri_PF , string . Empty , 0 , 0 , EnumIncomeTaxSide . Inc_AnnualIncome ) ;
IncomeTax BasicItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Basic_Salary , ( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
if ( _salary ! = null )
pfItem . ThisMonthAmount = _salary . GetDeductAmount ( EnumSalaryItemCode . PF_Contribution , ( int ) EnumSalaryItemCode . PF_Contribution ) ;
else
pfItem . ThisMonthAmount = ( BasicItem . ThisMonthAmount
* SystemInformation . CurrentSysInfo . pFContriCompany ) / 100 ;
pfItem . ProjectedAmount = ( BasicItem . ProjectedAmount
* SystemInformation . CurrentSysInfo . pFContriCompany ) / 100 ;
pfItem . ThisMonthAmount = GlobalFunctions . Round ( pfItem . ThisMonthAmount ) ;
pfItem . ProjectedAmount = GlobalFunctions . Round ( pfItem . ProjectedAmount ) ;
}
protected void CalculateUpdateBonusProjection ( double nAmount )
{
if ( _employee . ForeignExPat = = true ) return ;
ObjectsTemplate < FestivalBonusProjection > taxProjections = FestivalBonusProjection . Get ( EnumStatus . Active ) ;
IncomeTax pfItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Bonus , ( int ) EnumIncomeTaxItemGroup . Bonus ) ;
if ( pfItem = = null ) pfItem = this . Add ( EnumIncomeTaxItemGroup . Bonus , ( int ) EnumIncomeTaxItemGroup . Bonus , "Festival Bonus" , 0 , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
pfItem . ProjectedAmount = nAmount + pfItem . ProjectedAmount ;
if ( pfItem . ProjectedAmount < = 0 )
pfItem . ProjectedAmount = 0 ;
pfItem . ProjectedAmount = GlobalFunctions . Round ( pfItem . ProjectedAmount ) ;
}
protected void CalculateBonusProjection ( )
{
List < BonusParameter > oparams = null ;
if ( _projectionBonusParams = = null )
{
_projectionBonusParams = new ObjectsTemplate < BonusParameter > ( ) ;
ObjectsTemplate < BonusParameter > ops = BonusParameter . Get ( EnumStatus . Regardless ) ;
foreach ( BonusParameter oitem in ops )
if ( oitem . IsFestival = = true )
{
oitem . SetupDetails = BonusParameter . Service . GetSetupDetail ( oitem . ID ) ;
_projectionBonusParams . Add ( oitem ) ;
}
}
if ( _projectionBonusParams = = null | | _projectionBonusParams . Count = = 0 ) return ;
oparams = BonusParameter . GetApplicableParametersByGrade ( _employee , _employee . GradeID , _projectionBonusParams ) ;
if ( oparams = = null ) return ;
_ApplicableBonusParams = oparams ;
IncomeTax pfItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Bonus , ( int ) EnumIncomeTaxItemGroup . Bonus ) ;
if ( pfItem = = null ) pfItem = this . Add ( EnumIncomeTaxItemGroup . Bonus , ( int ) EnumIncomeTaxItemGroup . Bonus , "Festival Bonus" , 0 , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
foreach ( BonusParameter item in oparams )
{
//pfItem.ProjectedAmount =0;
ObjectsTemplate < BonusParameter > paramAll = BonusParameter . Get ( EnumStatus . Regardless ) ;
List < EnmSetupManagerTranType > oSetupManagerTranTypes = SetupDetail . GetTypes ( EnumParameterSetup . Bonus ) ;
ObjectsTemplate < SetupDetail > oSetupDetails = SetupDetail . GetParameters ( EnumParameterSetup . Bonus ) ;
ObjectsTemplate < BonusParameter > oParams = BonusParameter . ApplicableParameters3 ( _employee , item . BonusID , oSetupManagerTranTypes , oSetupDetails , paramAll ) ;
ObjectsTemplate < ADParameter > adParams = ADParameter . Get ( _employee . GradeID , EnumEntitleType . Grade , EnumAllowOrDeduct . Allowance ) ;
ObjectsTemplate < ADParameterEmployee > adParamEmps = ADParameterEmployee . GetByEmployee ( _employee . ID , EnumAllowOrDeduct . Allowance , EnumADEmpType . AppliedToIndividual ) ;
ObjectsTemplate < GrossDefination > grossDefinitions = GrossDefination . Get ( ) ;
EmployeeGradeSalary ogs = EmployeeGradeSalary . GetBasicOnDate ( _employee . ID , SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
double bonusAmount = BonusCalculator . GetMonthlyGrossAmount ( _employee , adParams , adParamEmps , grossDefinitions , SystemInformation . CurrentSysInfo . NextPayProcessDate , ogs ) ;
double nPaid = BonusProcess . GetBonusPaidAmount ( _taxParameter . FiscalyearDatefrom , _taxParameter . FiscalyearDateTo , _employee . ID , item . BonusID . Integer ) ;
pfItem . ProjectedAmount = ( bonusAmount * item . PercentOfGross ) / 100 - nPaid ;
//DateTime oEndMonth = new DateTime(((item.TaxProjectInMonth <= 6) ? _taxParameter.FiscalyearDateTo.Year : _taxParameter.FiscalyearDatefrom.Year), item.TaxProjectInMonth, 1);
//if (item.TaxProjectInMonth != null && oEndMonth > Global.DateFunctions.FirstDateOfMonth(SystemInformation.CurrentSysInfo.NextPayProcessDate))
//{
// BonusCalculator ocal = new BonusCalculator();
// double nn=ocal.CalcluateBonus(item, _employee, _employee.BasicSalary, _employee.GrossSalary,
// Global.DateFunctions.LastDateOfYear(SystemInformation.CurrentSysInfo.NextPayProcessDate));
// if (_employee.ReligionID.Integer == 2)
// pfItem.ProjectedAmount = 0;
// else if (_employee.ReligionID.Integer == 4)
// pfItem.ProjectedAmount = _employee.BasicSalary*2;
// else
// pfItem.ProjectedAmount = _employee.BasicSalary;// *2;
// // if not religion islam
// // if thier is an amount in previous then no need to projection
// // else projected amount will be basic * 2;
// // for islam
// // Payroll month in between july to dec then
// // prevous amount =0 then basic * 2
// // else basic *1
// // else basic *1
// //pfItem.ProjectedAmount = pfItem.ProjectedAmount + ocal.CalcluateBonus(item, _employee, _employee.BasicSalary, _employee.GrossSalary,
// // Global.DateFunctions.LastDateOfYear(SystemInformation.CurrentSysInfo.NextPayProcessDate));
// //}
// //Non Muslim
// //////////if(_employee.ReligionID.Integer==2||_employee.ReligionID.Integer==3||_employee.ReligionID.Integer==4)
// //////////{
// ////////// if(pfItem.PreviousAmount==0)
// ////////// {
// ////////// pfItem.ProjectedAmount= _employee.BasicSalary * 2;
// ////////// }
// //////////}
// //////////else
// //////////{
// ////////// if (SystemInformation.CurrentSysInfo.NextPayProcessDate >= new DateTime(SystemInformation.CurrentSysInfo.NextPayProcessDate.Year, 7, 1)
// ////////// && SystemInformation.CurrentSysInfo.NextPayProcessDate >= GlobalFunctions.LastDateOfMonth(new DateTime(SystemInformation.CurrentSysInfo.NextPayProcessDate.Year, 12, 1)))
// ////////// {
// ////////// if (pfItem.PreviousAmount == 0)
// ////////// {
// ////////// pfItem.ProjectedAmount = _employee.BasicSalary * 2;
// ////////// }
// ////////// else
// ////////// {
// ////////// pfItem.ProjectedAmount = _employee.BasicSalary;
// ////////// }
// ////////// }
// ////////// else
// ////////// {
// ////////// pfItem.ProjectedAmount = _employee.BasicSalary;
// ////////// }
// //////////}
// //if (_employee.ReligionID.Integer == 2 || _employee.ReligionID.Integer == 4)
// //{
// // pfItem.ProjectedAmount = 0;
// //}
// //else if (_employee.ReligionID.Integer == 1)
// //{
// // pfItem.ProjectedAmount = _employee.BasicSalary;
// //}
// //else if (_employee.ReligionID.Integer == 3)
// //{
// // pfItem.ProjectedAmount = _employee.BasicSalary * 2;
// //}
//}
}
if ( Payroll . BO . SystemInformation . CurrentSysInfo . NextPayProcessDate . Month = = 6 ) // Forcely zero on month Jun
pfItem . ProjectedAmount = 0 ;
// pfItem.ProjectedAmount = pfItem.ProjectedAmount - (pfItem.PreviousAmount + pfItem.ThisMonthAmount);
if ( pfItem . ProjectedAmount < = 0 )
pfItem . ProjectedAmount = 0 ;
pfItem . ProjectedAmount = GlobalFunctions . Round ( pfItem . ProjectedAmount ) ;
}
protected void CalculateInvestment ( )
{
IncomeTax InvestmentItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Tax_Credit_On_Investment ,
( int ) EnumIncomeTaxItemGroup . Tax_Credit_On_Investment ) ;
if ( InvestmentItem = = null ) InvestmentItem = this . Add ( EnumIncomeTaxItemGroup . Tax_Credit_On_Investment , ( int ) EnumIncomeTaxItemGroup . Tax_Credit_On_Investment , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_GrossTax ) ;
if ( _employee . ForeignExPat = = true ) return ;
bool binvestmenton = ConfigurationManager . GetBoolValue ( "incometax" , "investmentwithoutpf" , EnumConfigurationType . Logic ) ;
IncomeTax AnnualItem = null ;
//if (binvestmenton == true)
// AnnualItem = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Annual_Salary_Income,
// (int)EnumIncomeTaxItemGroup.Annual_Salary_Income);
//else
AnnualItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Annual_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
double investmentCanBeShown = ( ( AnnualItem . TotalAmount * _taxParameter . MaxInvestPercent ) / 100 ) ;
if ( investmentCanBeShown > _taxParameter . MaxInvAmount ) investmentCanBeShown = _taxParameter . MaxInvAmount ;
double investAmount = investmentCanBeShown ;
_isActualInvestment = true ;
if ( _taxParameter . InvestmentActiveMonth = = null ) _isActualInvestment = false ;
//else
//{
// DateTime investmonth = new DateTime(_taxParameter.FiscalyearDatefrom.Year, ((DateTime)_taxParameter.InvestmentActiveMonth).Month, 1);
// investmonth = GlobalFunctions.LastDateOfMonth(investmonth);
// if (investmonth <= SystemInformation.CurrentSysInfo.NextPayProcessDate)
// _isActualInvestment = true;
//}
double nPFAmount = 0 ;
if ( _isActualInvestment = = true )
{
IncomeTax ActualInvestment = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Investment_Actual ,
( int ) EnumIncomeTaxItemGroup . Investment_Actual ) ;
if ( ActualInvestment = = null )
ActualInvestment = this . Add ( EnumIncomeTaxItemGroup . Investment_Actual , ( int ) EnumIncomeTaxItemGroup . Investment_Actual , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_Info_Item ) ;
IncomeTax pfItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Company_Contri_PF ,
( int ) EnumIncomeTaxItemGroup . Company_Contri_PF ) ;
investAmount = 0 ;
if ( pfItem ! = null )
{
investAmount = investAmount + ( pfItem . TotalAmount * 2 ) ;
nPFAmount = pfItem . TotalAmount * 2 ;
}
EmployeeTaxInvestment etax = new EmployeeTaxInvestment ( ) ;
double nactualInvt = etax . GetAmount ( _taxParameter . ID , _employee . ID ) ;
#region Added By ashek
double nAllowedInvestment = ( AnnualItem . TotalAmount * 25 ) / 100 ;
double nActual = nAllowedInvestment - nPFAmount ;
if ( nactualInvt > nActual )
investAmount = nActual ;
else
investAmount = nactualInvt ;
#endregion
//investAmount = investAmount + nactualInvt;
ActualInvestment . ProjectedAmount = investAmount ; //nactualInvt;
ActualInvestment . TotalAmount = investAmount ; // nactualInvt;
investAmount + = nPFAmount ;
}
IncomeTax InvestmentAllowed = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Investment_Allowed ,
( int ) EnumIncomeTaxItemGroup . Investment_Allowed ) ;
if ( InvestmentAllowed = = null ) InvestmentAllowed = this . Add ( EnumIncomeTaxItemGroup . Investment_Allowed ,
( int ) EnumIncomeTaxItemGroup . Investment_Allowed , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_Info_Item ) ;
InvestmentAllowed . ProjectedAmount = GlobalFunctions . Round ( investmentCanBeShown ) ;
InvestmentAllowed . TotalAmount = GlobalFunctions . Round ( investmentCanBeShown ) ;
double taxCredit = 0 ;
taxCredit = ( investAmount * _taxParameter . MaxInvExempPercent ) / 100 ;
double nTempRebate = ( investAmount * _taxParameter . MaxInvExempPercent ) / 100 ;
if ( nTempRebate > ( AnnualItem . TotalAmount * . 03 ) )
nTempRebate = AnnualItem . TotalAmount * . 03 ;
if ( nTempRebate > 1000000 )
nTempRebate = 1000000 ;
InvestmentItem . ProjectedAmount = GlobalFunctions . Round ( taxCredit ) ;
InvestmentItem . TotalAmount = GlobalFunctions . Round ( taxCredit ) ;
}
protected void PrvYearTaxRebate ( )
{
if ( _prvYearTotalIncomes = = null )
_prvYearTotalIncomes = IncomeTax . GetPrvYear ( _taxParameter . ID ,
EnumIncomeTaxItemGroup . Annual_Income , ( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
if ( _prvYearTotalIncomes = = null ) return ;
IncomeTax prvYearIncome = IncomeTax . Get ( _prvYearTotalIncomes , _employee . ID ,
EnumIncomeTaxItemGroup . Annual_Income , ( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
if ( prvYearIncome = = null ) return ;
IncomeTax CurrYearIncome = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Annual_Income , ( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
if ( CurrYearIncome = = null ) return ;
if ( _PrvYeartaxParameter = = null ) _PrvYeartaxParameter = Payroll . BO . TaxParameter . Get ( _taxParameter . FiscalYear ) ;
if ( _PrvYeartaxParameter = = null ) return ;
double currAmount = CurrYearIncome . TotalAmount ;
double PrvAmount = prvYearIncome . TotalAmount ;
double exemptedAmount = 0 ;
if ( PrvAmount > = _PrvYeartaxParameter . GetSlabTotal ( ) & & currAmount > _taxParameter . GetSlabTotal ( ) )
{
if ( currAmount > = ( PrvAmount + ( PrvAmount * 10 ) / 100 ) )
{
exemptedAmount = currAmount - PrvAmount ;
exemptedAmount = ( exemptedAmount * 25 ) / 100 ; // 25%
exemptedAmount = ( exemptedAmount * 10 ) / 100 ; // 10%
IncomeTax grossRebate = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Gross_Rebate , ( int ) EnumIncomeTaxItemGroup . Tax_Gross_Rebate ) ;
if ( grossRebate = = null ) grossRebate = this . Add ( EnumIncomeTaxItemGroup . Tax_Gross_Rebate , ( int ) EnumIncomeTaxItemGroup . Tax_Gross_Rebate , string . Empty , 0 , 0 , EnumIncomeTaxSide . Dec_GrossTax ) ;
grossRebate . ProjectedAmount = GlobalFunctions . Round ( exemptedAmount ) ;
this . Add ( grossRebate ) ;
}
}
}
protected void CmpProvidedHouseAndTransport ( DateTime month )
{
try
{
if ( _assignedHeads = = null ) return ;
ObjectsTemplate < ITEmpHead > Items = ITEmpHead . Get ( _assignedHeads , _employee . ID ) ;
if ( Items = = null | | Items . Count = = 0 ) return ;
DateTime fromDate = GlobalFunctions . FirstDateOfMonth ( month ) ;
DateTime toDate = GlobalFunctions . LastDateOfMonth ( month ) ;
bool bvalid = false ;
IncomeTax basicSalaryItem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Basic_Salary ,
( int ) EnumIncomeTaxItemGroup . Basic_Salary ) ;
if ( basicSalaryItem = = null ) throw new ServiceException ( "Basic salary item not found in the collection on "
+ " calculating Company provided Car/HouseRent of the Employee No:" + _employee . EmployeeNo ) ;
double tempAmount = 0 ;
double carparcent = ( ( double ) 5 / ( double ) 100 ) ;
double hrPercent = ( ( double ) 25 / ( double ) 100 ) ;
foreach ( ITEmpHead item in Items )
{
IncomeTax taxItem ;
bvalid = false ;
if ( item . StartDate > = fromDate ) { fromDate = item . StartDate ; }
if ( item . EndDate < = toDate ) { toDate = item . EndDate ; }
if ( item . StartDate < = fromDate & & item . EndDate > = fromDate ) bvalid = true ;
else bvalid = false ;
if ( item . StartDate < = toDate & & item . EndDate > = toDate ) bvalid = true ;
else bvalid = false ;
if ( bvalid = = false )
{
DataSet ds = IncomeTax . GetTaxAdj ( EnumIncomeTaxItemGroup . Cmp_Provided_car , ( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car , _employee . ID ) ;
if ( ds ! = null & & ds . Tables . Count > 0 )
{
foreach ( DataRow dr in ds . Tables [ 0 ] . Rows )
{
taxItem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Cmp_Provided_car ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car ) ;
if ( taxItem = = null ) taxItem = this . Add ( EnumIncomeTaxItemGroup . Cmp_Provided_car ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car , "Company provided car" , 0 , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
taxItem . ThisMonthAmount = Convert . ToDouble ( dr [ 6 ] . ToString ( ) ) ;
taxItem . ProjectedAmount = 0 ;
}
}
continue ;
}
//if (item.StartDate > fromDate) fromDate = item.StartDate;
//if (item.EndDate > toDate) toDate = item.EndDate;
#region Calculate Car calculation
if ( item . HeadID = = EnumIncomeTaxHead . Car )
{
taxItem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Cmp_Provided_car ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car ) ;
if ( taxItem = = null ) taxItem = this . Add ( EnumIncomeTaxItemGroup . Cmp_Provided_car ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car , "Company provided car" , 0 , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
if ( _salary = = null )
tempAmount = basicSalaryItem . ThisMonthAmount ;
else
{
SalaryMonthlyDetail detail = _salary . GetDetail ( EnumSalaryGroup . Gross , EnumSalaryItemCode . Basic_Salary , ( int ) EnumSalaryItemCode . Basic_Salary ) ;
if ( detail = = null ) continue ;
tempAmount = detail . ChangedAmount ;
#region basic salary arrear effect
foreach ( EmployeeGradeSalary gse in _salary . ArrearGradeSalaries )
{
if ( gse . TillDate > item . StartDate )
{
if ( item . StartDate > gse . EffectDate )
{
tempAmount = tempAmount + gse . BasicSalary *
GlobalFunctions . GetFraction ( item . StartDate , ( DateTime ) gse . TillDate ) ;
}
else
{
// SalaryMonthlyDetail detail = _salary.GetDetail(EnumSalaryGroup.Gross, EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary);
SalaryMonthlyDetail arreardetail = _salary . GetDetail ( EnumSalaryGroup . Arrear , EnumSalaryItemCode . Basic_Salary , ( int ) EnumSalaryItemCode . Basic_Salary ) ;
if ( arreardetail ! = null )
{
tempAmount = tempAmount + arreardetail . ChangedAmount ;
}
}
}
}
double nTemp = tempAmount ;
foreach ( EmployeeGradeSalary gse in _salary . ArrearPaidGradeSalaries )
{
if ( gse . TillDate > item . StartDate )
{
if ( item . StartDate > gse . EffectDate )
tempAmount = tempAmount - gse . BasicSalary *
GlobalFunctions . GetFraction ( item . StartDate , ( DateTime ) gse . TillDate ) ;
else
tempAmount = tempAmount - gse . BasicSalary *
GlobalFunctions . GetFraction ( gse . EffectDate , ( DateTime ) gse . TillDate ) ;
}
}
if ( tempAmount < 0 )
tempAmount = nTemp ;
#endregion basic salary arrear effect
}
// need to fractionate if from date is not first date of month
TimeSpan ts = toDate - fromDate ;
int nDaysInMonth = DateTime . DaysInMonth ( fromDate . Year , fromDate . Month ) ;
int nDays = ts . Days + 1 ;
if ( nDays < nDaysInMonth )
{
tempAmount = ( tempAmount / nDaysInMonth ) * nDays ;
}
taxItem . ThisMonthAmount = GlobalFunctions . Round ( tempAmount * carparcent ) ;
if ( item . EndDate > _taxParameter . FiscalyearDateTo ) toDate = _taxParameter . FiscalyearDateTo ;
if ( _employee . EndOfContractDate ! = null & & _employee . EndOfContractDate < toDate )
toDate = Convert . ToDateTime ( _employee . EndOfContractDate ) ;
if ( _projectedMonth = = 0 ) tempAmount = basicSalaryItem . ProjectedAmount ;
else tempAmount = basicSalaryItem . ProjectedAmount / _projectedMonth ;
double nFrac = 1 ;
if ( nDays < nDaysInMonth )
{
//nFrac = (double)nDays / (double)nDaysInMonth;
//taxItem.ProjectedAmount = (tempAmount * Math.Round(nFrac, 2) * carparcent) + (basicSalaryItem.ThisMonthAmount * (_projectedMonth - 1));
taxItem . ProjectedAmount = 0 ;
}
else
taxItem . ProjectedAmount = ( tempAmount * Math . Round ( nFrac , 2 ) * carparcent ) * _projectedMonth ;
//if (toDate == GlobalFunctions.LastDateOfMonth(toDate))
//{
// taxItem.ProjectedAmount = (tempAmount * (Global.DateFunctions.DateDiff("m", GlobalFunctions.LastDateOfMonth(month).AddDays(1), toDate) + 1) * carparcent);
//}
//else
//{
// // need to fractionate last month
// taxItem.ProjectedAmount = (tempAmount * GlobalFunctions.GetFraction(GlobalFunctions.LastDateOfMonth(month).AddDays(1), toDate)) * carparcent;
//}
DataSet ds = IncomeTax . GetTaxAdj ( EnumIncomeTaxItemGroup . Cmp_Provided_car , ( int ) EnumIncomeTaxItemGroup . Cmp_Provided_car , _employee . ID ) ;
if ( ds ! = null & & ds . Tables . Count > 0 )
{
foreach ( DataRow dr in ds . Tables [ 0 ] . Rows )
{
taxItem . ThisMonthAmount = Convert . ToDouble ( dr [ 6 ] . ToString ( ) ) ;
}
}
if ( taxItem . TotalAmount < 60000 )
taxItem . ProjectedAmount = 60000 - ( taxItem . PreviousAmount + taxItem . ThisMonthAmount ) ;
//taxItem.ProjectedAmount = 0;
if ( taxItem . TotalAmount > 0 )
{
IncomeTax CvExption = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance , ( int ) EnumIncomeTaxItemGroup . Exemption_Conveyance_Allowance ) ;
if ( CvExption ! = null & & CvExption . TotalAmount > 0 )
{
CvExption . PreviousAmount = 0 ;
CvExption . ThisMonthAmount = 0 ;
CvExption . ProjectedAmount = 0 ;
}
}
}
#endregion Calculate Car calculation
#region Calculate House rent calculation
if ( item . HeadID = = EnumIncomeTaxHead . House )
{
taxItem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Cmp_Provided_House ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_House ) ;
if ( taxItem = = null ) taxItem = this . Add ( EnumIncomeTaxItemGroup . Cmp_Provided_House ,
( int ) EnumIncomeTaxItemGroup . Cmp_Provided_House , "Company provided House" , 0 , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
if ( item . HouseRent = = 0 )
{
if ( _salary = = null )
tempAmount = basicSalaryItem . ThisMonthAmount ;
else
{
SalaryMonthlyDetail detail = _salary . GetDetail ( EnumSalaryGroup . Gross , EnumSalaryItemCode . Basic_Salary , ( int ) EnumSalaryItemCode . Basic_Salary ) ;
if ( detail = = null ) continue ;
tempAmount = detail . ChangedAmount ;
#region basic salary arrear effect
foreach ( EmployeeGradeSalary gse in _salary . ArrearGradeSalaries )
{
if ( gse . TillDate > item . StartDate )
{
if ( item . StartDate > gse . EffectDate )
tempAmount = tempAmount + gse . BasicSalary *
GlobalFunctions . GetFraction ( item . StartDate , ( DateTime ) gse . TillDate ) ;
else
{
SalaryMonthlyDetail arreardetail = _salary . GetDetail ( EnumSalaryGroup . Arrear , EnumSalaryItemCode . Basic_Salary , ( int ) EnumSalaryItemCode . Basic_Salary ) ;
if ( arreardetail ! = null )
{
tempAmount = tempAmount + arreardetail . ChangedAmount ;
}
}
}
}
foreach ( EmployeeGradeSalary gse in _salary . ArrearPaidGradeSalaries )
{
if ( gse . TillDate > item . StartDate )
{
if ( item . StartDate > gse . EffectDate )
tempAmount = tempAmount - gse . BasicSalary *
GlobalFunctions . GetFraction ( item . StartDate , ( DateTime ) gse . TillDate ) ;
else
tempAmount = tempAmount - gse . BasicSalary *
GlobalFunctions . GetFraction ( gse . EffectDate , ( DateTime ) gse . TillDate ) ;
}
}
#endregion basic salary arrear effect
}
taxItem . ThisMonthAmount = GlobalFunctions . Round ( tempAmount * hrPercent ) ;
}
else
taxItem . ThisMonthAmount = GlobalFunctions . Round ( GlobalFunctions . GetFraction ( fromDate , toDate ) * item . HouseRent ) ;
//if (item.EndDate <= toDate) continue;
//toDate = item.EndDate;
if ( item . EndDate > = _taxParameter . FiscalyearDateTo ) toDate = _taxParameter . FiscalyearDateTo ;
if ( item . HouseRent = = 0 )
{
if ( _projectedMonth = = 0 )
tempAmount = basicSalaryItem . ProjectedAmount ;
else tempAmount = basicSalaryItem . ProjectedAmount / _projectedMonth ;
if ( toDate = = GlobalFunctions . LastDateOfMonth ( toDate ) )
taxItem . ProjectedAmount = ( tempAmount * ( Global . DateFunctions . DateDiff ( "m" , GlobalFunctions . LastDateOfMonth ( month ) . AddDays ( 1 ) , toDate ) + 1 ) * hrPercent ) ;
else
taxItem . ProjectedAmount = ( tempAmount * GlobalFunctions . GetFraction ( GlobalFunctions . LastDateOfMonth ( month ) . AddDays ( 1 ) , toDate ) ) * hrPercent ;
taxItem . ProjectedAmount = GlobalFunctions . Round ( taxItem . ProjectedAmount ) ;
}
else
{
taxItem . ProjectedAmount = GlobalFunctions . GetFraction (
GlobalFunctions . LastDateOfMonth ( month ) . AddDays ( 1 ) , toDate ) * item . HouseRent ;
taxItem . ProjectedAmount = GlobalFunctions . Round ( taxItem . ProjectedAmount ) ;
}
taxItem . Side = EnumIncomeTaxSide . Inc_SalaryIncome ;
}
#endregion Calculate Car calculation
}
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
private double GetTotalSalary ( )
{
double TotGross ;
double TotExemp ;
TotGross = 0 ; TotExemp = 0 ;
foreach ( IncomeTax item in _currentYearTax )
{
if ( item . Side = = EnumIncomeTaxSide . Dec_SalaryIncome )
TotExemp = TotExemp + item . TotalAmount ;
else if ( item . Side = = EnumIncomeTaxSide . Inc_SalaryIncome )
TotGross = TotGross + item . TotalAmount ;
}
return TotGross - TotExemp ;
}
protected double GetAnnualIncome ( )
{
double TotIncome = 0 ;
foreach ( IncomeTax item in _currentYearTax )
{
if ( item . Side = = EnumIncomeTaxSide . Inc_AnnualIncome )
TotIncome = TotIncome + item . TotalAmount ;
else if ( item . Side = = EnumIncomeTaxSide . Dec_AnnualIncome )
TotIncome = TotIncome - item . TotalAmount ;
}
TotIncome = this . GetTotalSalary ( ) + TotIncome ;
return TotIncome ;
}
protected void CalculateTotalIncome ( )
{
IncomeTax salaryIncome = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Annual_Salary_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Salary_Income ) ;
if ( salaryIncome = = null ) salaryIncome = this . Add ( EnumIncomeTaxItemGroup . Annual_Salary_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Salary_Income , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
salaryIncome . TotalAmount = 0 ;
salaryIncome . PreviousAmount = 0 ;
salaryIncome . ThisMonthAmount = 0 ;
salaryIncome . ProjectedAmount = 0 ;
foreach ( IncomeTax item in _currentYearTax )
{
if ( item . Side = = EnumIncomeTaxSide . Inc_SalaryIncome )
{
salaryIncome . PreviousAmount = salaryIncome . PreviousAmount + item . PreviousAmount ;
salaryIncome . ThisMonthAmount = salaryIncome . ThisMonthAmount + item . ThisMonthAmount ;
salaryIncome . ProjectedAmount = salaryIncome . ProjectedAmount + item . ProjectedAmount ;
salaryIncome . TotalAmount = salaryIncome . TotalAmount + item . TotalAmount ;
}
else if ( item . Side = = EnumIncomeTaxSide . Dec_SalaryIncome )
{
salaryIncome . PreviousAmount = salaryIncome . PreviousAmount - item . PreviousAmount ;
salaryIncome . ThisMonthAmount = salaryIncome . ThisMonthAmount - item . ThisMonthAmount ;
salaryIncome . ProjectedAmount = salaryIncome . ProjectedAmount - item . ProjectedAmount ;
salaryIncome . TotalAmount = salaryIncome . TotalAmount - item . TotalAmount ;
}
}
salaryIncome . PreviousAmount = GlobalFunctions . Round ( salaryIncome . PreviousAmount ) ;
salaryIncome . ThisMonthAmount = GlobalFunctions . Round ( salaryIncome . ThisMonthAmount ) ;
salaryIncome . ProjectedAmount = GlobalFunctions . Round ( salaryIncome . ProjectedAmount ) ;
IncomeTax annualIncome = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Annual_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
if ( annualIncome = = null ) annualIncome = this . Add ( EnumIncomeTaxItemGroup . Annual_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Income , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
annualIncome . TotalAmount = 0 ;
annualIncome . PreviousAmount = 0 ;
annualIncome . ThisMonthAmount = 0 ;
annualIncome . ProjectedAmount = 0 ;
foreach ( IncomeTax item in _currentYearTax )
{
if ( item . Side = = EnumIncomeTaxSide . Inc_AnnualIncome )
{
annualIncome . PreviousAmount = annualIncome . PreviousAmount + item . PreviousAmount ;
annualIncome . ThisMonthAmount = annualIncome . ThisMonthAmount + item . ThisMonthAmount ;
annualIncome . ProjectedAmount = annualIncome . ProjectedAmount + item . ProjectedAmount ;
annualIncome . TotalAmount = annualIncome . TotalAmount + item . TotalAmount ;
}
else if ( item . Side = = EnumIncomeTaxSide . Dec_AnnualIncome )
{
annualIncome . PreviousAmount = annualIncome . PreviousAmount - item . PreviousAmount ;
annualIncome . ThisMonthAmount = annualIncome . ThisMonthAmount - item . ThisMonthAmount ;
annualIncome . ProjectedAmount = annualIncome . ProjectedAmount - item . ProjectedAmount ;
annualIncome . TotalAmount = annualIncome . TotalAmount - item . TotalAmount ;
}
}
annualIncome . PreviousAmount = annualIncome . PreviousAmount + salaryIncome . PreviousAmount ;
annualIncome . ThisMonthAmount = annualIncome . ThisMonthAmount + salaryIncome . ThisMonthAmount ;
annualIncome . ProjectedAmount = annualIncome . ProjectedAmount + salaryIncome . ProjectedAmount ;
annualIncome . TotalAmount = annualIncome . TotalAmount + salaryIncome . TotalAmount ;
annualIncome . PreviousAmount = GlobalFunctions . Round ( annualIncome . PreviousAmount ) ;
annualIncome . ThisMonthAmount = GlobalFunctions . Round ( annualIncome . ThisMonthAmount ) ;
annualIncome . ProjectedAmount = GlobalFunctions . Round ( annualIncome . ProjectedAmount ) ;
}
private double GetTaxRebate ( )
{
double TotIncome = 0 ;
foreach ( IncomeTax item in _currentYearTax )
{
if ( item . ItemGroup = = EnumIncomeTaxItemGroup . Tax_Gross_Rebate | |
item . ItemGroup = = EnumIncomeTaxItemGroup . Tax_Gross_Refund | |
item . ItemGroup = = EnumIncomeTaxItemGroup . Tax_Gross_OtherRebate | |
item . ItemGroup = = EnumIncomeTaxItemGroup . Tax_Gross_OtherAddable )
{
if ( item . Side = = EnumIncomeTaxSide . Inc_GrossTax )
TotIncome = TotIncome + item . TotalAmount ;
else if ( item . Side = = EnumIncomeTaxSide . Dec_GrossTax )
TotIncome = TotIncome - item . TotalAmount ;
}
}
return TotIncome ;
}
/// <summary>
/// follwing function equal the net tax payable and tax deducted amount. Adjusted amount stores in Tax refund item.
/// </summary>
protected void CalculateYearlyRefund ( )
{
IncomeTax oNetTaxPayable = IncomeTax . Get ( this . CurrentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
IncomeTax oTaxDeducted = IncomeTax . Get ( this . CurrentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( oNetTaxPayable = = null ) oNetTaxPayable = this . Add ( EnumIncomeTaxItemGroup . Net_Payable ,
( int ) EnumIncomeTaxItemGroup . Net_Payable , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
if ( oTaxDeducted = = null ) oTaxDeducted = this . Add ( EnumIncomeTaxItemGroup . Tax_Deducted ,
( int ) EnumIncomeTaxItemGroup . Tax_Deducted , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
if ( ( oNetTaxPayable . TotalAmount - oTaxDeducted . TotalAmount ) ! = 0 )
{
IncomeTax TaxRefund = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Refund_On_Current_Year , ( int ) EnumIncomeTaxItemGroup . Tax_Refund_On_Current_Year ) ;
if ( TaxRefund = = null ) TaxRefund = this . Add ( EnumIncomeTaxItemGroup . Tax_Refund_On_Current_Year ,
( int ) EnumIncomeTaxItemGroup . Tax_Refund_On_Current_Year , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
TaxRefund . ThisMonthAmount = 0 ;
TaxRefund . PreviousAmount = 0 ;
TaxRefund . ProjectedAmount = 0 ;
TaxRefund . TotalAmount = 0 ;
TaxRefund . ProjectedAmount = GlobalFunctions . Round ( oNetTaxPayable . TotalAmount - oTaxDeducted . TotalAmount ) ;
TaxRefund . TotalAmount = TaxRefund . ProjectedAmount ;
// set equal to Net_Taxable_income to Tax_deducted_current_year amount
// oTaxDeducted.TotalAmount = oNetTaxPayable.TotalAmount;
}
}
private double GetTaxonTaxAmount ( double onAmount )
{
this . CalculateTotalIncome ( ) ;
IncomeTax IncomeWithCar = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Annual_Salary_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Salary_Income ) ;
double dif = 0 ;
double onlyCarTax = this . GetTaxConciderInvestment ( IncomeWithCar . TotalAmount - onAmount ) ; ;
double taxwithCar = this . GetTaxConciderInvestment ( IncomeWithCar . TotalAmount ) ;
dif = taxwithCar - onlyCarTax ;
double addedIncome = dif + taxwithCar ;
double prvTax = taxwithCar ;
while ( dif < 0 )
{
dif = this . GetTaxConciderInvestment ( addedIncome ) ;
dif = dif - prvTax ;
prvTax = addedIncome ;
if ( dif > 0 ) addedIncome = addedIncome + dif ;
}
dif = addedIncome - taxwithCar ;
return dif ;
}
protected double GetTaxonTaxNetPayable ( )
{
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateNetPayable ( ) ;
IncomeTax annualIncome = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable ,
( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
double IncomeWithoutNetpayable = annualIncome . TotalAmount ;
IncomeTax taxOnTax = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_on_Tax_Net_Payable ,
( int ) EnumIncomeTaxItemGroup . Tax_on_Tax_Net_Payable ) ;
if ( taxOnTax = = null ) taxOnTax = this . Add ( EnumIncomeTaxItemGroup . Tax_on_Tax_Net_Payable ,
( int ) EnumIncomeTaxItemGroup . Tax_on_Tax_Net_Payable , string . Empty , IncomeWithoutNetpayable , 0 , EnumIncomeTaxSide . Inc_SalaryIncome ) ;
else
{
taxOnTax . PreviousAmount = 0 ;
taxOnTax . ThisMonthAmount = IncomeWithoutNetpayable ;
}
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateNetPayable ( ) ;
double dif = 0 ;
double onlyCarTax = this . GetTaxConciderInvestment ( IncomeWithoutNetpayable ) ; ;
double taxwithCar = this . GetTaxConciderInvestment ( annualIncome . TotalAmount ) ;
dif = taxwithCar - onlyCarTax ;
double addedIncome = dif + taxwithCar ;
double prvTax = taxwithCar ;
while ( dif < 0 )
{
dif = this . GetTaxConciderInvestment ( addedIncome ) ;
if ( dif = = 0 ) break ;
dif = dif - prvTax ;
prvTax = addedIncome ;
if ( dif > 0 ) addedIncome = addedIncome + dif ;
}
dif = addedIncome - taxwithCar ;
taxOnTax . ThisMonthAmount = taxOnTax . ThisMonthAmount + dif ;
return dif ;
}
private double GetTaxConciderInvestment ( double income )
{
double taxamount = this . GetTaxAmount ( income ) ;
if ( _employee . ForeignExPat = = true ) return taxamount ;
bool binvestmenton = ConfigurationManager . GetBoolValue ( "incometax" , "investmentwithoutpf" , EnumConfigurationType . Logic ) ;
double investmentCanBeShown = ( ( taxamount * _taxParameter . MaxInvestPercent ) / 100 ) ;
if ( investmentCanBeShown > _taxParameter . MaxInvAmount ) investmentCanBeShown = _taxParameter . MaxInvAmount ;
double investAmount = investmentCanBeShown ;
_isActualInvestment = false ;
if ( _taxParameter . InvestmentActiveMonth = = null ) _isActualInvestment = false ;
else
{
DateTime investmonth = new DateTime ( _taxParameter . FiscalyearDatefrom . Year , ( ( DateTime ) _taxParameter . InvestmentActiveMonth ) . Month , 1 ) ;
investmonth = GlobalFunctions . LastDateOfMonth ( investmonth ) ;
if ( investmonth < = SystemInformation . CurrentSysInfo . NextPayProcessDate )
_isActualInvestment = true ;
}
if ( _isActualInvestment = = true )
{
IncomeTax ActualInvestment = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Investment_Actual ,
( int ) EnumIncomeTaxItemGroup . Investment_Actual ) ;
investAmount = ActualInvestment . ThisMonthAmount ;
}
if ( investAmount > investmentCanBeShown )
investAmount = investmentCanBeShown ;
double taxCredit = 0 ;
taxCredit = ( investAmount * _taxParameter . MaxInvExempPercent ) / 100 ;
//if (income <= 1500000)
// taxCredit = investAmount * .15;
//else taxCredit = investAmount * .10;
taxamount = taxamount - taxCredit ;
return taxamount ;
}
protected void CalculateNetPayable ( )
{
IncomeTax GrossTax = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Gross_Tax , ( int ) EnumIncomeTaxItemGroup . Gross_Tax ) ;
if ( GrossTax = = null )
{
this . CalculateGrossTax ( ) ;
GrossTax = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Gross_Tax , ( int ) EnumIncomeTaxItemGroup . Gross_Tax ) ;
// this.Add(GrossTax);
}
this . CalculateGrossTax ( ) ;
IncomeTax netPayable = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
if ( netPayable = = null ) netPayable = this . Add ( EnumIncomeTaxItemGroup . Net_Payable ,
( int ) EnumIncomeTaxItemGroup . Net_Payable , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
netPayable . TotalAmount = 0 ;
netPayable . PreviousAmount = 0 ;
netPayable . ThisMonthAmount = 0 ;
netPayable . ProjectedAmount = 0 ;
if ( GrossTax . TotalAmount > 0 )
{
IncomeTax InvestItem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Credit_On_Investment , ( int ) EnumIncomeTaxItemGroup . Tax_Credit_On_Investment ) ;
if ( InvestItem = = null ) this . CalculateInvestment ( ) ;
2026-06-21 13:50:33 +06:00
netPayable . ProjectedAmount = netPayable . ProjectedAmount + GrossTax . TotalAmount - InvestItem . TotalAmount ;
#region Tax Incentive
ProcessItem pitem = _processItems . FirstOrDefault ( x = > x . ItemGroup = = ( int ) EnumIncomeTaxSide . Dec_GrossTax & & x . ItemCode = = ( int ) EnumIncomeTaxItemGroup . Tax_Incentive ) ;
if ( netPayable . ProjectedAmount > 0 & & pitem ! = null )
{
IncomeTax incentive = _currentYearTax . FirstOrDefault ( x = > x . EmployeeID = = _employee . ID & &
x . ItemGroup = = EnumIncomeTaxItemGroup . Tax_Incentive & & x . ItemID = = ( int ) EnumIncomeTaxItemGroup . Tax_Incentive ) ;
if ( incentive = = null ) incentive = this . Add ( EnumIncomeTaxItemGroup . Tax_Incentive ,
( int ) EnumIncomeTaxItemGroup . Tax_Incentive , "Tax Incentive" , 0 , 0 , EnumIncomeTaxSide . Dec_GrossTax ) ;
incentive . TotalAmount = 0 ;
incentive . PreviousAmount = 0 ;
incentive . ThisMonthAmount = 0 ;
incentive . ProjectedAmount = 0 ;
incentive . ProjectedAmount = GlobalFunctions . Round ( netPayable . ProjectedAmount * 0.05 ) ;
if ( incentive . ProjectedAmount > 25000 )
{
incentive . ProjectedAmount = 25000 ;
}
incentive . TotalAmount = GlobalFunctions . Round ( incentive . ProjectedAmount ) ;
netPayable . ProjectedAmount = netPayable . ProjectedAmount - incentive . TotalAmount ;
}
#endregion
//netPayable.ProjectedAmount = GrossTax.TotalAmount - InvestItem.TotalAmount;
2025-08-06 14:31:52 +06:00
if ( netPayable . ProjectedAmount < _taxParameter . MinTaxAmount )
netPayable . ProjectedAmount = _taxParameter . MinTaxAmount ;
}
IncomeTax rebet = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Gross_OtherRebate , 1 ) ;
double nAIT = 0 ;
if ( rebet ! = null )
nAIT = rebet . TotalAmount ;
netPayable . ProjectedAmount = netPayable . ProjectedAmount + this . GetTaxRebate ( ) - nAIT ;
netPayable . ProjectedAmount = GlobalFunctions . Round ( netPayable . ProjectedAmount ) ;
netPayable . TotalAmount = GlobalFunctions . Round ( netPayable . ProjectedAmount ) ; ;
}
protected void CalculateGrossTax ( )
{
IncomeTax GrossTax = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Gross_Tax , ( int ) EnumIncomeTaxItemGroup . Gross_Tax ) ;
if ( GrossTax = = null ) GrossTax = this . Add ( EnumIncomeTaxItemGroup . Gross_Tax ,
( int ) EnumIncomeTaxItemGroup . Gross_Tax , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
double annualIncome = this . GetAnnualIncome ( ) ;
double yearlyTax = this . GetTaxAmount ( annualIncome ) ;
GrossTax . TotalAmount = 0 ;
GrossTax . PreviousAmount = 0 ;
GrossTax . ThisMonthAmount = 0 ;
GrossTax . ProjectedAmount = GlobalFunctions . Round ( yearlyTax ) ;
GrossTax . TotalAmount = GlobalFunctions . Round ( yearlyTax ) ;
}
protected double CalculateDecutedAmount ( )
{
double nAmount = 0 ;
double nTaxAmount = 0 ;
IncomeTax TaxDeductitem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( TaxDeductitem ! = null )
{
nAmount = TaxDeductitem . ThisMonthAmount ;
TaxDeductitem . ThisMonthAmount = 0 ;
}
this . CalculateThisMonth ( ) ;
TaxDeductitem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( TaxDeductitem ! = null )
{
nTaxAmount = TaxDeductitem . ThisMonthAmount - nAmount ;
}
return nTaxAmount ;
}
protected void UndoDecutedAmount ( double nAmount )
{
IncomeTax TaxDeductitem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( TaxDeductitem ! = null )
TaxDeductitem . ThisMonthAmount = TaxDeductitem . ThisMonthAmount - nAmount ;
//this.CalculateThisMonth();
}
protected double CalculateOnceOfInvestmentAmt ( double IncomeAmount )
{
if ( _employee . ForeignExPat = = true ) return 0 ;
bool binvestmenton = ConfigurationManager . GetBoolValue ( "incometax" , "investmentwithoutpf" , EnumConfigurationType . Logic ) ;
IncomeTax AnnItem = null ;
//if (binvestmenton == true)
// AnnItem = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Annual_Salary_Income,
// (int)EnumIncomeTaxItemGroup.Annual_Salary_Income);
//else
AnnItem = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Annual_Income ,
( int ) EnumIncomeTaxItemGroup . Annual_Income ) ;
double totalIncome = IncomeAmount ;
double investmentCanBeShown = ( ( totalIncome * _taxParameter . MaxInvestPercent ) / 100 ) ;
if ( investmentCanBeShown > _taxParameter . MaxInvAmount ) investmentCanBeShown = _taxParameter . MaxInvAmount ;
double investAmount = investmentCanBeShown ;
_isActualInvestment = false ;
if ( _taxParameter . InvestmentActiveMonth = = null ) _isActualInvestment = false ;
else
{
DateTime investmonth = new DateTime ( _taxParameter . FiscalyearDatefrom . Year , ( ( DateTime ) _taxParameter . InvestmentActiveMonth ) . Month , 1 ) ;
investmonth = GlobalFunctions . LastDateOfMonth ( investmonth ) ;
if ( investmonth < = SystemInformation . CurrentSysInfo . NextPayProcessDate )
_isActualInvestment = true ;
}
if ( _isActualInvestment = = true )
{
IncomeTax ActualInvestment = IncomeTax . Get ( _currentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Investment_Actual ,
( int ) EnumIncomeTaxItemGroup . Investment_Actual ) ;
investAmount = ActualInvestment . ThisMonthAmount ;
}
if ( investAmount > investmentCanBeShown )
investAmount = investmentCanBeShown ;
double taxCredit = 0 ;
taxCredit = ( investAmount * _taxParameter . MaxInvExempPercent ) / 100 ;
double nTempRebate = ( investAmount * _taxParameter . MaxInvExempPercent ) / 100 ;
if ( nTempRebate > ( totalIncome * . 03 ) )
nTempRebate = totalIncome * . 03 ;
if ( nTempRebate > 1000000 )
nTempRebate = 1000000 ;
//if (AnnItem.TotalAmount <= 1000000)
// taxCredit = investAmount * .15;
//if (AnnItem.TotalAmount > 1000000 && AnnItem.TotalAmount <= 3000000)
// taxCredit = (investAmount > 250000) ? (250000 * .15) + (investAmount - 250000) * .12 : investAmount * .15;
//if (AnnItem.TotalAmount > 3000000)
//{
// taxCredit = (investAmount > 250000) ? (250000 * .15) : investAmount * .15;
// investAmount = investAmount - 250000;
// if (investAmount > 0)
// taxCredit = taxCredit + ((investAmount > 500000) ? (500000 * .12) + (investAmount - 500000) * .10 : investAmount * .12);
//}
return ( taxCredit ) ;
//if (_employee.ForeignExPat == true) return 0;
//bool binvestmenton = ConfigurationManager.GetBoolValue("incometax", "investmentwithoutpf", EnumConfigurationType.Logic);
//IncomeTax AnnItem = null;
//if (binvestmenton == true)
// AnnItem = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Annual_Salary_Income,
// (int)EnumIncomeTaxItemGroup.Annual_Salary_Income);
//else
// AnnItem = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Annual_Income,
// (int)EnumIncomeTaxItemGroup.Annual_Income);
//double totalIncome = AnnItem.TotalAmount - _onceoffAmount;
//double investmentCanBeShown = ((totalIncome * _taxParameter.MaxInvestPercent) / 100);
//if (investmentCanBeShown > _taxParameter.MaxInvAmount) investmentCanBeShown = _taxParameter.MaxInvAmount;
//double investAmount = investmentCanBeShown;
//_isActualInvestment = false;
//if (_taxParameter.InvestmentActiveMonth == null) _isActualInvestment = false;
//else
//{
// DateTime investmonth = new DateTime(_taxParameter.FiscalyearDatefrom.Year, ((DateTime)_taxParameter.InvestmentActiveMonth).Month, 1);
// investmonth = GlobalFunctions.LastDateOfMonth(investmonth);
// if (investmonth <= SystemInformation.CurrentSysInfo.NextPayProcessDate)
// _isActualInvestment = true;
//}
//if (_isActualInvestment == true)
//{
// IncomeTax ActualInvestment = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Investment_Actual,
// (int)EnumIncomeTaxItemGroup.Investment_Actual);
// investAmount = ActualInvestment.ThisMonthAmount;
//}
//if (investAmount > investmentCanBeShown)
// investAmount = investmentCanBeShown;
//double taxCredit = 0;
//taxCredit = (investAmount * _taxParameter.MaxInvExempPercent) / 100;
//if (AnnItem.TotalAmount <= 1000000)
// taxCredit = investAmount * .15;
//if (AnnItem.TotalAmount > 1000000 && AnnItem.TotalAmount <= 3000000)
// taxCredit = (investAmount > 250000) ? (250000 * .15) + (investAmount - 250000) * .12 : investAmount * .15;
//if (AnnItem.TotalAmount > 3000000)
//{
// taxCredit = (investAmount > 250000) ? (250000 * .15) : investAmount * .15;
// investAmount = investAmount - 250000;
// if (investAmount > 0)
// taxCredit = taxCredit + ((investAmount > 500000) ? (500000 * .12) + (investAmount - 500000) * .10 : investAmount * .12);
//}
//IncomeTax InvestmentItem = IncomeTax.Get(_currentYearTax, _employee.ID, EnumIncomeTaxItemGroup.Tax_Credit_On_Investment,
// (int)EnumIncomeTaxItemGroup.Tax_Credit_On_Investment);
//return (InvestmentItem.TotalAmount - taxCredit);
}
protected void CalculateThisMonth ( )
{
IncomeTax TaxDeductitem = IncomeTax . Get ( _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( TaxDeductitem = = null ) TaxDeductitem = this . Add ( EnumIncomeTaxItemGroup . Tax_Deducted ,
( int ) EnumIncomeTaxItemGroup . Tax_Deducted , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
double onceOffTax = 0 ;
double netPayable = IncomeTax . Get ( this . _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) . TotalAmount ;
double annualIncome = this . GetAnnualIncome ( ) ;
double grossTax = IncomeTax . Get ( this . _currentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Gross_Tax , ( int ) EnumIncomeTaxItemGroup . Gross_Tax ) . TotalAmount ;
double exptionAmount = 0 ;
var expItem = this . _currentYearTax . FirstOrDefault ( x = > x . EmployeeID = = _employee . ID & &
x . ItemGroup = = EnumIncomeTaxItemGroup . AnnualExemption & & x . ItemID = =
( int ) EnumIncomeTaxItemGroup . AnnualExemption ) ;
if ( expItem ! = null ) exptionAmount = expItem . TotalAmount ;
if ( _employee . Status = = EnumEmployeeStatus . Discontinued )
TaxDeductitem . ThisMonthAmount = netPayable - TaxDeductitem . TotalAmount ;
else
{
if ( _projectedMonth < 0 )
throw new ServiceException ( "Projected month can't be less then Zero." ) ;
if ( _onceoffAmount > 0 & & netPayable > _taxParameter . MinTaxAmount )
{
double onceofIncome = annualIncome - _onceoffAmount + exptionAmount ;
double Onceexemption = ( onceofIncome / 3 ) * 1 ;
if ( Onceexemption > 500000 )
{
onceofIncome = onceofIncome - 500000 ;
}
else onceofIncome = onceofIncome - Onceexemption ;
onceOffTax = this . GetTaxAmount ( onceofIncome ) ;
double invAmount = CalculateOnceOfInvestmentAmt ( onceofIncome ) ;
onceOffTax = onceOffTax - invAmount ;
onceOffTax = onceOffTax + this . GetTaxRebate ( ) ;
if ( _taxParameter . MinTaxAmount > onceOffTax )
onceOffTax = _taxParameter . MinTaxAmount ;
double ntp = netPayable - onceOffTax ;
if ( ntp < 0 ) ntp = 0 ;
#region Commented by ashek
double restofMonthTax = onceOffTax - TaxDeductitem . TotalAmount ; // Tax to be paid rest of the year;
if ( restofMonthTax < 0 )
{
restofMonthTax = 0 ;
ntp = ntp / _projectedMonth ;
}
TaxDeductitem . ThisMonthAmount = ntp + ( restofMonthTax / ( _projectedMonth + 1 ) ) ;
#endregion
//TaxDeductitem.ThisMonthAmount = ntp;
//onceOffTax = this.GetTaxAmount(annualIncome - _onceoffAmount);
//onceOffTax = onceOffTax - CalculateOnceOfInvestmentAmt();
//onceOffTax = onceOffTax + this.GetTaxRebate();
//if (_taxParameter.MinTaxAmount > onceOffTax)
// onceOffTax = _taxParameter.MinTaxAmount;
//double ntp = netPayable - onceOffTax;
//if (ntp <= 0) ntp = 0;
//onceOffTax = onceOffTax - TaxDeductitem.TotalAmount; // Tax to be paid rest of the year;
//TaxDeductitem.ThisMonthAmount = ntp + (onceOffTax / (_projectedMonth + 1));
}
else TaxDeductitem . ThisMonthAmount = ( ( netPayable - TaxDeductitem . TotalAmount ) / ( _projectedMonth + 1 ) ) ;
if ( TaxDeductitem . TotalAmount > netPayable )
TaxDeductitem . ThisMonthAmount = netPayable - TaxDeductitem . PreviousAmount ; // (netPayable - TaxDeductitem.PreviousAmount) / _projectedMonth;
}
if ( TaxDeductitem . ThisMonthAmount < 0 ) TaxDeductitem . ThisMonthAmount = 0 ;
//if (_employee.GradeID.Integer == 24 || _employee.GradeID.Integer == 25)
//{
// TaxDeductitem.ThisMonthAmount = 0;
//}
//else
//{
TaxDeductitem . ThisMonthAmount = GlobalFunctions . Round ( TaxDeductitem . ThisMonthAmount ) ;
//}
TaxDeductitem . ProjectedAmount = GlobalFunctions . Round ( TaxDeductitem . ProjectedAmount ) ;
if ( _salary ! = null & & ( _salary . GradeID . Integer = = 25 | | _salary . GradeID . Integer = = 24 ) )
{
SalaryMonthlyDetail dtl = _salary . Details . Find ( delegate ( SalaryMonthlyDetail detail ) { return ( detail . ItemCode = = EnumSalaryItemCode . Basic_Salary & & detail . itemGroupCode = = EnumSalaryGroup . Gross ) ; } ) ;
if ( dtl ! = null )
{
dtl . CalculatedAmount = dtl . CalculatedAmount + TaxDeductitem . ThisMonthAmount ;
dtl . ChangedAmount = dtl . CalculatedAmount ;
}
}
//IncomeTax TaxDeductitem = IncomeTax.Get(_currentYearTax, _employee.ID,
// EnumIncomeTaxItemGroup.Tax_Deducted, (int)EnumIncomeTaxItemGroup.Tax_Deducted);
//if (TaxDeductitem == null) TaxDeductitem = this.Add(EnumIncomeTaxItemGroup.Tax_Deducted,
// (int)EnumIncomeTaxItemGroup.Tax_Deducted, string.Empty, 0, 0, EnumIncomeTaxSide.Tax_fixed_Item);
//this.CalculateGrossTax();
//this.CalculateNetPayable();
//double onceOffTax = 0;
//double netPayable = IncomeTax.Get(this._currentYearTax, _employee.ID,
// EnumIncomeTaxItemGroup.Net_Payable, (int)EnumIncomeTaxItemGroup.Net_Payable).TotalAmount;
//double annualIncome = this.GetAnnualIncome();
//double grossTax = IncomeTax.Get(this._currentYearTax, _employee.ID,
// EnumIncomeTaxItemGroup.Gross_Tax, (int)EnumIncomeTaxItemGroup.Gross_Tax).TotalAmount;
//if (_onceoffAmount > 0)
//{
// onceOffTax = grossTax - this.GetTaxAmount(annualIncome - _onceoffAmount);
// onceOffTax = onceOffTax - CalculateOnceOfInvestmentAmt();
// if (onceOffTax < 0) onceOffTax = 0;
//}
//if (_employee.Status == EnumEmployeeStatus.Discontinued)
// TaxDeductitem.ThisMonthAmount = netPayable - TaxDeductitem.TotalAmount;
//else
//{
// if (_projectedMonth < 0)
// throw new ServiceException("Projected month can't be less then Zero.");
// TaxDeductitem.ThisMonthAmount = onceOffTax + (((netPayable - onceOffTax) - TaxDeductitem.TotalAmount) / (_projectedMonth + 1));
// if (TaxDeductitem.TotalAmount > netPayable)
// TaxDeductitem.ThisMonthAmount = netPayable - TaxDeductitem.PreviousAmount;
//}
//if (TaxDeductitem.ThisMonthAmount < 0)
//{
// TaxDeductitem.ThisMonthAmount = GlobalFunctions.Round(0);
//}
//else
//{
// TaxDeductitem.ThisMonthAmount = GlobalFunctions.Round(TaxDeductitem.ThisMonthAmount);
//}
//TaxDeductitem.ProjectedAmount = GlobalFunctions.Round(TaxDeductitem.ProjectedAmount);
}
protected double GetTaxAmount ( double TaxableIncome )
{
try
{
double taxAmount = 0 ;
ObjectsTemplate < TaxParameterSlab > parameterSlabs = TaxParameter . CalculateTaxOnSlab ( _taxParameter , _employee , TaxableIncome ) ;
taxAmount = TaxParameterSlab . GetTotalTaxAmount ( parameterSlabs ) ;
return taxAmount ;
}
catch
{
return 0 ;
}
}
protected void UpdateRawItems ( List < TaxRawItem > rawItems , EnumSide nSide )
{
foreach ( TaxRawItem item in rawItems )
{
if ( item . Amount = = 0 ) continue ;
IncomeTax taxItem = null ;
switch ( item . ItemType )
{
case enumIncomeTaxItemType . Basic_Salary :
taxItem = GetTaxItem ( EnumTaxMergeType . NONE , ( int ) EnumIncomeTaxItemGroup . Basic_Salary , item . Description ) ;
break ;
case enumIncomeTaxItemType . Allowance :
taxItem = GetTaxItem ( EnumTaxMergeType . Allowance , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Deduction :
taxItem = GetTaxItem ( EnumTaxMergeType . Allowance , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . OT :
taxItem = GetTaxItem ( EnumTaxMergeType . OT , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Bonus :
taxItem = GetTaxItem ( EnumTaxMergeType . Bonus , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . FinalSettlement :
taxItem = GetTaxItem ( EnumTaxMergeType . Settlement , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Other :
taxItem = GetTaxItem ( EnumTaxMergeType . Other , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . OPI :
//taxItem = GetTaxItem(EnumTaxMergeType.Bonus, item.ItemId, item.Description);
//taxItem.ThisMonthAmount = GlobalFunctions.Round(item.Amount);
break ;
case enumIncomeTaxItemType . AdjustItem :
taxItem = GetTaxItem ( EnumTaxMergeType . TaxAdjustItem , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Earned_Leave :
taxItem = GetTaxItem ( EnumTaxMergeType . Allowance , item . ItemId , item . Description ) ;
break ;
default :
break ;
}
if ( taxItem ! = null )
{
//taxItem.ThisMonthAmount = (nSide == EnumSide.Deduct) ? -GlobalFunctions.Round(item.Amount) : GlobalFunctions.Round(item.Amount);
taxItem . ThisMonthAmount = taxItem . ThisMonthAmount + item . Amount ;
if ( taxItem ! = null ) taxItem . Side = EnumIncomeTaxSide . Inc_SalaryIncome ;
this . Add ( taxItem ) ;
}
}
}
protected void UpdateRawItems2 ( List < TaxRawItem > rawItems , EnumSide nSide , int itemID )
{
foreach ( TaxRawItem item in rawItems )
{
if ( item . Amount = = 0 ) continue ;
IncomeTax taxItem = null ;
switch ( item . ItemType )
{
case enumIncomeTaxItemType . Basic_Salary :
taxItem = GetTaxItem ( EnumTaxMergeType . NONE , ( int ) EnumIncomeTaxItemGroup . Basic_Salary , item . Description ) ;
break ;
case enumIncomeTaxItemType . Allowance :
taxItem = GetTaxItem ( EnumTaxMergeType . Allowance , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Deduction :
taxItem = GetTaxItem ( EnumTaxMergeType . Allowance , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . OT :
taxItem = GetTaxItem ( EnumTaxMergeType . OT , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Bonus :
taxItem = GetTaxItem ( EnumTaxMergeType . Bonus , itemID , item . Description ) ;
break ;
case enumIncomeTaxItemType . FinalSettlement :
taxItem = GetTaxItem ( EnumTaxMergeType . Settlement , item . ItemId , item . Description ) ;
break ;
break ;
case enumIncomeTaxItemType . OPI :
//taxItem = GetTaxItem(EnumTaxMergeType.Bonus, item.ItemId, item.Description);
//taxItem.ThisMonthAmount = GlobalFunctions.Round(item.Amount);
break ;
case enumIncomeTaxItemType . AdjustItem :
taxItem = GetTaxItem ( EnumTaxMergeType . TaxAdjustItem , item . ItemId , item . Description ) ;
break ;
case enumIncomeTaxItemType . Earned_Leave :
taxItem = GetTaxItem ( EnumTaxMergeType . NONE , ( int ) EnumIncomeTaxItemGroup . Earned_Leave , item . Description ) ;
break ;
default :
break ;
}
if ( taxItem ! = null )
{
taxItem . ThisMonthAmount = ( nSide = = EnumSide . Deduct ) ? - GlobalFunctions . Round ( item . Amount ) : GlobalFunctions . Round ( item . Amount ) ;
if ( taxItem ! = null ) taxItem . Side = EnumIncomeTaxSide . Inc_SalaryIncome ;
this . Add ( taxItem ) ;
}
}
}
}
public interface ISalaryTax
{
SalaryMonthly Salary { set ; get ; }
ObjectsTemplate < IncomeTax > Calculate ( ) ;
}
public interface IBonusTax
{
BonusProcess . BonusProcessDetail Bonus { set ; get ; }
ObjectsTemplate < IncomeTax > Calculate ( ) ;
}
public interface ITaxCalculator
{
}
[Serializable]
public class TaxCalculator : AbstractTaxCalculator
{
public TaxCalculator ( )
{
}
public override ObjectsTemplate < ADParameter > AdParameters
{
set { _adParameters = value ; }
}
public override SalaryMonthly Salary
{
set { _salary = value ; }
}
public override Employee Employee
{
set
{
if ( _taxParameter = = null ) throw new ServiceException ( "Taxparameter must set before Employee" ) ;
_taxSlabs = Payroll . BO . TaxParameter . GetEmployeeSlab (
_taxParameter , value ) ;
_employee = value ;
}
}
public override TaxParameter TaxParameter
{
set
{
_taxParameter = value ;
}
}
public ObjectsTemplate < IncomeTax > SalaryTax ( )
{
string smessage = "" ;
try
{
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
smessage = "InitiazedNextMonth" ;
this . InitializeForNextMonth ( ) ;
smessage = "CalcualteprojectMonth" ;
this . CalcualteprojectMonth ( ) ;
smessage = "IncludePayslipItems" ;
this . IncludePayslipItems ( ) ;
smessage = "Calculate OT" ;
this . CalculateOT ( ) ;
smessage = "CmpProvidedHouseAndTransport" ;
this . CmpProvidedHouseAndTransport ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
smessage = "CalculateBonusProjection" ;
this . CalculateBonusProjection ( ) ;
smessage = "CalculateCPF" ;
this . CalculateCPF ( ) ;
if ( _salary ! = null & & ( _salary . GradeID . Integer = = 25 | | _salary . GradeID . Integer = = 24 ) )
{
smessage = "Tax On Tax" ;
this . GetTaxonTaxNetPayable ( ) ;
}
smessage = "CalculateExamtion" ;
this . CalculateExamtion ( ) ;
smessage = "CalculateTotalIncome" ;
this . CalculateTotalIncome ( ) ;
smessage = "CalculateInvestment" ;
this . CalculateInvestment ( ) ;
smessage = "CalculateGrossTax" ;
this . CalculateGrossTax ( ) ;
smessage = "CalculateNetPayable" ;
this . CalculateNetPayable ( ) ;
smessage = "CalculateThisMonth" ;
this . CalculateThisMonth ( ) ;
smessage = "End" ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message + "###" + smessage ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message + "###" + smessage ) ;
}
}
public ObjectsTemplate < IncomeTax > CalculateBonus ( List < TaxRawItem > rawItems , ref double ntaxAmount )
{
try
{
double nTempAmount = 0 ;
bool bStartMonth = false ;
_isActualInvestment = true ;
this . _onceoffAmount = rawItems . Sum ( x = > x . Amount ) ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
//if (datafrom == EnumIncomeTaxDataFrom.SalaryITTempData)
//{
// throw new ServiceException("Current month salary is processed and not yet finalized. Tax calculation "
// + " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax.");
//}
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
if ( SystemInformation . CurrentSysInfo . NextPayProcessDate . Month = = 7 ) // if month is july and salary not yet processed then, clear all tax data
{
bStartMonth = true ;
this . CalcualteprojectMonth ( ) ;
this . CalculateOnlyProjection ( ) ;
}
this . UpdateRawItems ( rawItems , EnumSide . Add ) ;
this . CalculateExamtion ( ) ;
this . CalculateBonusProjection ( ) ;
this . CalculateCPF ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
double totalAmount = 0 ;
IncomeTax netPayable = IncomeTax . Get ( this . CurrentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
if ( netPayable ! = null )
nTempAmount = netPayable . TotalAmount ;
ntaxAmount = 0 ;
this . CalculateNetPayable ( ) ;
//if (_ApplicableBonusParams != null)
//{s
// BonusParameter oparam = _ApplicableBonusParams.FirstOrDefault(x => x.BonusID.Integer == rawItems[0].ItemId);
// if (oparam != null && oparam.IsFestival == true) // isFestival mean bonus is projected for tax. So no need to deduct tax in bonus process
// return this.CurrentYearTax;
//}
ntaxAmount = nTempAmount ;
netPayable = IncomeTax . Get ( this . CurrentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
if ( netPayable ! = null )
if ( totalAmount > 0 )
ntaxAmount = netPayable . TotalAmount - totalAmount ;
else
ntaxAmount = ( - totalAmount - netPayable . TotalAmount ) > 0 ? 0 : netPayable . TotalAmount ;
double grossTax = IncomeTax . Get ( this . CurrentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Gross_Tax , ( int ) EnumIncomeTaxItemGroup . Gross_Tax ) . TotalAmount ;
_onceoffAmount = 0 ;
if ( _onceoffAmount > 0 )
{
double annualIncome = this . GetAnnualIncome ( ) ;
ntaxAmount = grossTax - this . GetTaxAmount ( annualIncome - _onceoffAmount ) ;
// ntaxAmount = ntaxAmount- CalculateOnceOfInvestmentAmt();
if ( ntaxAmount < 0 ) ntaxAmount = 0 ;
}
IncomeTax TaxDeductitem = IncomeTax . Get ( this . CurrentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Tax_Deducted , ( int ) EnumIncomeTaxItemGroup . Tax_Deducted ) ;
if ( TaxDeductitem = = null ) TaxDeductitem = this . Add ( EnumIncomeTaxItemGroup . Tax_Deducted ,
( int ) EnumIncomeTaxItemGroup . Tax_Deducted , string . Empty , 0 , 0 , EnumIncomeTaxSide . Tax_fixed_Item ) ;
// if (_employee.GradeID.Integer == 25)
ntaxAmount = 0 ;
TaxDeductitem . ThisMonthAmount = TaxDeductitem . ThisMonthAmount + ntaxAmount ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
public ObjectsTemplate < IncomeTax > UndoBonus ( List < TaxRawItem > rawItems , double taxAmount , int nItemID )
{
try
{
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
if ( datafrom = = EnumIncomeTaxDataFrom . SalaryITTempData )
{
throw new ServiceException ( "Current month salary is processed and not yet finalized. Tax calculation "
+ " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax." ) ;
}
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
this . UpdateRawItems2 ( rawItems , EnumSide . Deduct , nItemID ) ;
this . CalculateBonusProjection ( ) ;
if ( nItemID = = 1 )
{
IncomeTax pfItem = IncomeTax . Get ( this . CurrentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Bonus , ( int ) EnumIncomeTaxItemGroup . Bonus ) ;
pfItem . ProjectedAmount * = 2 ;
}
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . UndoDecutedAmount ( taxAmount ) ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
/// <summary>
///
/// </summary>
/// <param name="rawItems"></param>
/// <returns></returns>
public double Calculate ( List < TaxRawItem > rawItems )
{
try
{
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , datafrom ) ;
this . CalcualteprojectMonth ( ) ;
this . UpdateRawItems ( rawItems , EnumSide . Add ) ;
this . CmpProvidedHouseAndTransport ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
this . CalculateExamtion ( ) ;
this . CalculateBonusProjection ( ) ;
this . CalculateCPF ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
double totalAmount = 0 ;
IncomeTax netPayable = IncomeTax . Get ( this . CurrentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
if ( netPayable ! = null )
totalAmount = netPayable . TotalAmount ;
this . CalculateNetPayable ( ) ;
netPayable = IncomeTax . Get ( this . CurrentYearTax , _employee . ID ,
EnumIncomeTaxItemGroup . Net_Payable , ( int ) EnumIncomeTaxItemGroup . Net_Payable ) ;
if ( netPayable ! = null )
totalAmount = netPayable . TotalAmount - totalAmount ;
// if the amount is equal to yearly netpayable, the amount should be dsitributed next of the projected month
if ( totalAmount = = netPayable . TotalAmount & & netPayable . TotalAmount = = _taxParameter . MinTaxAmount & & _projectedMonth > 0 )
totalAmount = totalAmount / _projectedMonth ;
return totalAmount ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
//End OPI Calculation
/// <summary>
///
/// </summary>
/// <param name="rawItem"></param>
/// <param name="taxAmount"></param>
/// <returns></returns>
public ObjectsTemplate < IncomeTax > Calculate ( List < TaxRawItem > rawItems , ref double ntaxAmount )
{
try
{
_isActualInvestment = true ;
this . _onceoffAmount = rawItems [ 0 ] . Amount ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
if ( datafrom = = EnumIncomeTaxDataFrom . SalaryITTempData )
{
throw new ServiceException ( "Current month salary is processed and not yet finalized. Tax calculation "
+ " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax." ) ;
}
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
this . CalcualteprojectMonth ( ) ;
this . UpdateRawItems ( rawItems , EnumSide . Add ) ;
this . CmpProvidedHouseAndTransport ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
this . CalculateExamtion ( ) ;
this . CalculateBonusProjection ( ) ;
this . CalculateCPF ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
ntaxAmount = this . CalculateDecutedAmount ( ) ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
/// <summary>
///
/// </summary>
/// <param name="rawItem"></param>
/// <param name="taxAmount"></param>
/// <returns></returns>
public ObjectsTemplate < IncomeTax > CalculateSettlementTax ( List < TaxRawItem > rawItems , ref double ntaxAmount , bool isNew )
{
try
{
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
if ( datafrom = = EnumIncomeTaxDataFrom . SalaryITTempData )
{
throw new ServiceException ( "Current month salary is processed and not yet finalized. Tax calculation "
+ " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax." ) ;
}
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
this . _projectedMonth = 0 ;
foreach ( IncomeTax item in this . CurrentYearTax )
{
if ( isNew = = true ) item . PreviousAmount = item . PreviousAmount + item . ThisMonthAmount ;
item . ThisMonthAmount = 0 ;
item . ProjectedAmount = 0 ;
}
this . UpdateRawItems ( rawItems , EnumSide . Add ) ;
this . CmpProvidedHouseAndTransport ( _employee . DiscontinueDate ) ;
this . CalculateExamtion ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
ntaxAmount = this . CalculateDecutedAmount ( ) ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
/// <summary>
/// function will return total year tax,
/// </summary>
/// <param name="rawItems"></param>
/// <param name="ntaxAmount"></param>
/// <returns></returns>
public ObjectsTemplate < IncomeTax > CalculateYearlyTax ( List < TaxRawItem > rawItems , ref double ntaxAmount )
{
try
{
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
_isActualInvestment = false ;
_projectedMonth = 0 ;
this . _onceoffAmount = 0 ;
this . UpdateRawItems ( rawItems , EnumSide . Add ) ;
this . CmpProvidedHouseAndTransport ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
this . CalculateExamtion ( ) ;
this . CalculateBonusProjection ( ) ;
this . CalculateCPF ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . CalculateThisMonth ( ) ;
ntaxAmount = IncomeTax . GetAmount ( this . CurrentYearTax , _employee . ID , EnumIncomeTaxItemGroup . Tax_Deducted ) ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
public ObjectsTemplate < IncomeTax > UndoCalculate ( List < TaxRawItem > rawItems , double taxAmount )
{
try
{
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
IncomeTax oIncomeTax = new IncomeTax ( ) ;
EnumIncomeTaxDataFrom datafrom = oIncomeTax . GetEnumForSalaryIT ( _employee . ID ) ;
if ( datafrom = = EnumIncomeTaxDataFrom . SalaryITTempData )
{
throw new ServiceException ( "Current month salary is processed and not yet finalized. Tax calculation "
+ " is not allowed middle of this process. You have to Undo or finalize the salary to calculate tax." ) ;
}
this . CurrentYearTax = new ObjectsTemplate < IncomeTax > ( ) ;
this . CurrentYearTax = IncomeTax . Get ( _employee . ID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
this . CalcualteprojectMonth ( ) ;
//foreach (IncomeTax item in this.CurrentYearTax)
// item.ProjectedAmount = 0;
this . UpdateRawItems ( rawItems , EnumSide . Deduct ) ;
this . CmpProvidedHouseAndTransport ( SystemInformation . CurrentSysInfo . NextPayProcessDate ) ;
this . CalculateExamtion ( ) ;
this . CalculateBonusProjection ( ) ;
this . CalculateCPF ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . UndoDecutedAmount ( taxAmount ) ;
return this . CurrentYearTax ;
}
catch ( ServiceException ex )
{
throw new ServiceException ( ex . Message ) ;
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
}
/// <summary>
///
/// </summary>
/// <param name="naxParameterID"></param>
public ObjectsTemplate < IncomeTax > DoTaxYearEnd ( ID naxParameterID )
{
ObjectsTemplate < IncomeTax > empTaxCertificates = new ObjectsTemplate < IncomeTax > ( ) ;
try
{
// if IncomeTax.get() function not return employee order-by wise data, rest of the function will not culculate properly.
ObjectsTemplate < IncomeTax > oTaxYearly = IncomeTax . Get ( EnumIncomeTaxDataFrom . ProcessTempData ) ;
ID nCurrEmployeeid = null ;
if ( oTaxYearly . Count > 0 ) nCurrEmployeeid = oTaxYearly [ 0 ] . EmployeeID ;
_taxParameter = TaxParameter . Get ( naxParameterID ) ;
while ( true )
{
_employee = Employee . Get ( nCurrEmployeeid ) ;
this . CurrentYearTax = IncomeTax . Get ( oTaxYearly , nCurrEmployeeid ) ;
// Initialize the current data.
//foreach (IncomeTax item in this.CurrentYearTax)
//{
// item.DataTo = EnumIncomeTaxDataFrom.ProcessedData;
// item.TotalAmount = item.PreviousAmount + item.ProjectedAmount + item.ThisMonthAmount;
// item.TaxParameterID = _taxParameter.ID;
// item.PreviousAmount = 0;
// item.ThisMonthAmount = 0;
// item.ProjectedAmount = 0;
// oTaxYearly.Remove(item); // Remove from collection
//}
_isActualInvestment = true ;
this . _onceoffAmount = 0 ;
this . CalculateExamtion ( ) ;
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . CalculateYearlyRefund ( ) ;
foreach ( IncomeTax item in this . CurrentYearTax )
{
item . TaxParameterID = naxParameterID ;
empTaxCertificates . Add ( item ) ;
oTaxYearly . Remove ( item ) ;
}
if ( oTaxYearly . Count > 0 ) nCurrEmployeeid = oTaxYearly [ 0 ] . EmployeeID ;
else break ;
}
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
return empTaxCertificates ;
}
public ObjectsTemplate < IncomeTax > DoTaxYearEndReProcess ( ID nTaxParamterID , bool isMaximumInvestment )
{
ObjectsTemplate < IncomeTax > empTaxCertificates = new ObjectsTemplate < IncomeTax > ( ) ;
try
{
// if IncomeTax.get() function not return employee order-by wise data, rest of the function will not culculate properly.
ObjectsTemplate < IncomeTax > oTaxYearly = IncomeTax . GetPrvYear ( nTaxParamterID ) ;
if ( SystemInformation . CurrentSysInfo . TaxParamID = = nTaxParamterID )
oTaxYearly = IncomeTax . GetByYear ( nTaxParamterID , EnumIncomeTaxDataFrom . ProcessTempData ) ;
else
oTaxYearly = IncomeTax . GetPrvYear ( nTaxParamterID ) ;
ID nCurrEmployeeid = null ;
if ( oTaxYearly . Count > 0 ) nCurrEmployeeid = oTaxYearly [ 0 ] . EmployeeID ;
_taxParameter = TaxParameter . Get ( nTaxParamterID ) ;
while ( true )
{
_employee = Employee . Get ( nCurrEmployeeid ) ;
this . CurrentYearTax = IncomeTax . Get ( oTaxYearly , nCurrEmployeeid ) ;
// Initialize the current data.
foreach ( IncomeTax item in this . CurrentYearTax )
{
oTaxYearly . Remove ( item ) ; // Remove from collection
}
_isActualInvestment = ! isMaximumInvestment ;
//this.CalculateExamtionPrev();
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . CalculateYearlyRefund ( ) ;
foreach ( IncomeTax item in this . CurrentYearTax )
{
item . EmployeeID = _employee . ID ;
item . TaxParameterID = nTaxParamterID ;
empTaxCertificates . Add ( item ) ;
}
if ( oTaxYearly . Count > 0 ) nCurrEmployeeid = oTaxYearly [ 0 ] . EmployeeID ;
else break ;
}
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
return empTaxCertificates ;
}
public ObjectsTemplate < IncomeTax > DoTaxYearEndReProcess ( ID nTaxParamterID , bool isMaximumInvestment , Employee employee , ObjectsTemplate < IncomeTax > oTaxYearly45656 )
{
ObjectsTemplate < IncomeTax > empTaxCertificates = new ObjectsTemplate < IncomeTax > ( ) ;
try
{
_employee = employee ;
// if IncomeTax.get() function not return employee order-by wise data, rest of the function will not culculate properly.
ObjectsTemplate < IncomeTax > oTaxYearly = IncomeTax . GetPrvYear ( nTaxParamterID , _employee . ID ) ;
//if (SystemInformation.CurrentSysInfo.TaxParamID == nTaxParamterID)
// oTaxYearly = IncomeTax.GetByYear(nTaxParamterID, EnumIncomeTaxDataFrom.ProcessTempData);
//else
// oTaxYearly = IncomeTax.GetPrvYear(nTaxParamterID);
ID nCurrEmployeeid = null ;
//if (oTaxYearly.Count > 0)
nCurrEmployeeid = _employee . ID ;
_taxParameter = TaxParameter . Get ( nTaxParamterID ) ;
//while (true)
//{
//_employee = Employee.Get(nEmployeeID);
this . CurrentYearTax = IncomeTax . Get ( oTaxYearly , nCurrEmployeeid ) ;
// Initialize the current data.
foreach ( IncomeTax item in this . CurrentYearTax )
{
oTaxYearly . Remove ( item ) ; // Remove from collection
}
_isActualInvestment = ! isMaximumInvestment ;
//this.CalculateExamtionPrev();
this . CalculateTotalIncome ( ) ;
this . CalculateInvestment ( ) ;
this . CalculateGrossTax ( ) ;
this . CalculateNetPayable ( ) ;
this . CalculateYearlyRefund ( ) ;
foreach ( IncomeTax item in this . CurrentYearTax )
{
item . EmployeeID = _employee . ID ;
item . TaxParameterID = nTaxParamterID ;
empTaxCertificates . Add ( item ) ;
}
//if (oTaxYearly.Count > 0) nCurrEmployeeid = oTaxYearly[0].EmployeeID;
//else break;
//}
}
catch ( Exception ex )
{
throw new ServiceException ( ex . Message ) ;
}
return empTaxCertificates ;
}
}
public class TaxProcess
{
public void CalculateTax ( )
{
}
#region ISalaryTax Members
public void Calculate ( )
{
}
#endregion
}
}