Exemplo n.º 1
0
 /// <summary>
 /// Soft Supprime Un Recue
 /// </summary>
 /// <param name="myPayOff">Guid du Ticket</param>
 /// <returns>True pour Success</returns>
 protected internal static bool DeleteFeeReceipt(BillPayOff myPayOff)
 {
     using (var db = new EconomatContext())
     {
         //db.FeeReceipts.Attach(myReceipt);
         db.Entry(myPayOff).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Modifier un Recue
        /// </summary>
        /// <param name="myPayOff"></param>
        /// <returns>True pour Success</returns>
        protected internal static bool UpdateFeeReceipt(BillPayOff myPayOff)
        {
            //myPayement.DateEdited = DateTime.Now;

            using (var db = new EconomatContext())
            {
                //db.FeeReceipts.Attach(myReceipt);
                db.Entry(myPayOff).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Modifier les information d'un salaire
        /// </summary>
        /// <param name="salary"></param>
        /// <exception cref="NotImplementedException"></exception>
        public bool CancelSalary(Salary salary)
        {
            if (string.IsNullOrEmpty(salary.Designation))
            {
                throw new InvalidOperationException("DESIGNATION_CAN_NOT_BE_EMPTY");
            }
            if (salary.StartDate > salary.EndDate)
            {
                throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            }
            if (salary.EndDate < DateTime.Today)
            {
                throw new InvalidOperationException("END_DATE_CAN_NOT_BE_LESS_THAN_TODAY");
            }

            Employment emp;

            using (var db = new EconomatContext()) emp = db.Employments.Find(salary.EmploymentGuid);
            if (emp == null)
            {
                throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
            }
            if ((salary.StartDate < emp.StartDate) || (salary.EndDate > emp.EndDate))
            {
                throw new InvalidOperationException("DATES_CAN_NOT_BE_OUT_OF_EMPLOYMENT_BOUNDRIES");
            }

            using (var db = new EconomatContext())
            {
                var newSalary = db.Salaries.Find(salary.SalaryGuid);
                if (newSalary == null)
                {
                    throw new InvalidOperationException("SALARY_REFERENCE_NOT_FOUND");
                }

                newSalary.EndDate     = salary.EndDate;
                newSalary.Description = salary.Description;

                var user = Membership.GetUser();
                if (user == null)
                {
                    throw new SecurityException("USER_CAN_NOT_DETERMINED");
                }

                // ReSharper disable once PossibleNullReferenceException
                newSalary.LastEditUserGuid = (Guid)user.ProviderUserKey;
                newSalary.LastEditDate     = DateTime.Now;

                db.Salaries.Attach(newSalary);
                db.Entry(newSalary).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Modifier les information d'un employement
        /// </summary>
        /// <param name="employ"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public bool UpdateEmployment(Employment employ)
        {
            if (string.IsNullOrEmpty(employ.Position))
            {
                throw new InvalidOperationException("POSITION_CAN_NOT_BE_EMPTY");
            }
            if (employ.StartDate > employ.EndDate)
            {
                throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            }
            using (var db = new SchoolContext()) if (db.Staffs.Find(employ.StaffGuid) == null)
                {
                    throw new InvalidOperationException("STAFF_REFERENCE_NOT_FOUND");
                }

            using (var db = new EconomatContext())
            {
                var newEmploy = db.Employments.Find(employ.EmploymentGuid);
                if (newEmploy == null)
                {
                    throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
                }

                //todo cancel Employ
                newEmploy.Position    = employ.Position;
                newEmploy.Category    = employ.Category;
                newEmploy.Project     = employ.Project;
                newEmploy.Grade       = employ.Grade;
                newEmploy.Departement = employ.Departement;
                newEmploy.Division    = employ.Division;
                newEmploy.ReportTo    = employ.ReportTo;
                //newEmploy.SalaryRecurrence = employ.SalaryRecurrence;
                //newEmploy.StartDate        = employ.StartDate;
                //newEmploy.EndDate          = employ.EndDate;
                newEmploy.Description = employ.Description;

                newEmploy.LastEditDate     = DateTime.Now;
                newEmploy.LastEditUserGuid = Guid.Empty;

                db.Employments.Attach(newEmploy);
                db.Entry(newEmploy).State = EntityState.Modified;

                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Confirmer paiement d'un salaire
        /// </summary>
        /// <param name="payrollGuid"></param>
        /// <param name="finalPaycheck"></param>
        /// <param name="numeroReference"></param>
        /// <param name="totalHoursWorked"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public bool Paycheck(Guid payrollGuid, double?finalPaycheck = null, string numeroReference = null, TimeSpan?totalHoursWorked = null)
        {
            using (var db = new EconomatContext()) {
                var payroll = db.Payrolls.Find(payrollGuid);
                if (payroll == null)
                {
                    throw new InvalidOperationException("PAYROLL_REFERENCE_NOT_FOUND");
                }

                if (payroll.IsPaid)
                {
                    throw new InvalidOperationException("PAYCHECK_ALREADY_PAID");
                }

                if (!string.IsNullOrEmpty(numeroReference) && SalarySlipExist(numeroReference))
                {
                    throw new InvalidOperationException("PAYSLIP_REFERENCE_DUPLICATE");
                }

                if (totalHoursWorked != null)
                {
                    payroll.HoursWorked = (TimeSpan)totalHoursWorked;
                }

                if (finalPaycheck == null)
                {
                    finalPaycheck = (new PayrollCard(payroll)).TotalSalary;
                }

                payroll.FinalPaycheck   = (double)finalPaycheck;
                payroll.IsPaid          = true;
                payroll.IsPaidTo        = Guid.Empty;
                payroll.DatePaid        = DateTime.Now;
                payroll.NumeroReference = string.IsNullOrEmpty(numeroReference) ? GetNewSalarySlipRef() : numeroReference;

                payroll.LastEditDate     = DateTime.Now;
                payroll.LastEditUserGuid = Guid.Empty;

                db.Payrolls.Attach(payroll);
                db.Entry(payroll).State = EntityState.Modified;

                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Payer Frais d'Etude
        /// </summary>
        /// <param name="myPayOff"></param>
        /// <exception cref="InvalidDataException">CAN_NOT_FIND_SCHOOL_FEE_REFERENCE</exception>
        /// <exception cref="InvalidOperationException">SCHOOL_FEE_ALREADY_PAID</exception>
        /// <returns>True pour Success</returns>
        public bool PaySchoolFee(BillPayOff myPayOff)
        {
            using (var db = new EconomatContext())
            {
                var newSchoolFee = db.SchoolFees.Find(myPayOff.SchoolFeeGuid);

                if (newSchoolFee == null)
                {
                    throw new InvalidOperationException("CAN_NOT_FIND_BILL_REFERENCE");
                }
                if (newSchoolFee.IsPaid)
                {
                    throw new InvalidOperationException("BILL_ALREADY_PAID");
                }
                if (string.IsNullOrEmpty(newSchoolFee.NumeroReference))
                {
                    newSchoolFee.NumeroReference = GetNewReceipRef();
                }
                if (RefRecueExist(newSchoolFee.NumeroReference))
                {
                    throw new InvalidOperationException("RECEIPT_REFERENCE_ALREADY_EXIST");
                }
                if (string.IsNullOrEmpty(newSchoolFee.Description))
                {
                    newSchoolFee.Description = "Reglement effectuer le " + DateTime.Now;
                }

                newSchoolFee.IsPaid          = true;
                newSchoolFee.IsPaidBy        = myPayOff.IsPaidBy;
                newSchoolFee.PaymentMethode  = myPayOff.PaymentMethode;
                newSchoolFee.NumeroReference = myPayOff.NumeroReference;
                newSchoolFee.NumeroVirement  = myPayOff.NumeroVirement;
                newSchoolFee.Bank            = myPayOff.Bank;
                newSchoolFee.Description     = myPayOff.Description;

                newSchoolFee.LastEditDate = DateTime.Now;
                newSchoolFee.DatePaid     = DateTime.Now;

                db.SchoolFees.Attach(newSchoolFee);
                db.Entry(newSchoolFee).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transactionGuid"></param>
        /// <returns></returns>
        public bool CancelTransaction(Guid transactionGuid)
        {
            using (var db = new EconomatContext())
            {
                var theTransaction = db.Transactions.Find(transactionGuid);
                if (theTransaction == null)
                {
                    throw new InvalidOperationException("CAN_NOT_FIND_REFERENCE_TRANSACTION");
                }

                theTransaction.IsDeleted      = true;
                theTransaction.DeleteDate     = DateTime.Now;
                theTransaction.DeleteUserGuid = Guid.Empty;

                theTransaction.LastEditDate     = DateTime.Now;
                theTransaction.LastEditUserGuid = Guid.Empty;

                db.Transactions.Attach(theTransaction);
                db.Entry(theTransaction).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Annuler un Paiement d'un salaire
        /// </summary>
        /// <param name="payrollGuid"></param>
        /// <param name="totalSalary"></param>
        public bool CancelPaycheck(Guid payrollGuid)
        {
            using (var db = new EconomatContext()) {
                var payroll = db.Payrolls.Find(payrollGuid);
                if (payroll == null)
                {
                    throw new InvalidOperationException("PAYROLL_REFERENCE_NOT_FOUND");
                }

                payroll.IsPaid          = false;
                payroll.IsPaidTo        = Guid.Empty;
                payroll.DatePaid        = DateTime.Now;
                payroll.NumeroReference = string.Empty;

                payroll.LastEditDate     = DateTime.Now;
                payroll.LastEditUserGuid = Guid.Empty;

                db.Payrolls.Attach(payroll);
                db.Entry(payroll).State = EntityState.Modified;

                return(db.SaveChanges() > 0);
            }
        }