public async Task <InitializationResult> InitializeAsync(string authTkn, Guid licenseServiceID, string socialReason,
                                                                 string RFC, PayrollCompanyConfiguration payrollCompanyConfiguration, EmployerRegistration employerRegistration)
        {
            var createParmas = new InitializationParams()
            {
                AuthTkn          = authTkn,
                LicenseServiceID = licenseServiceID,
                SocialReason     = socialReason,
                RFC = RFC,
                PayrollCompanyConfiguration = payrollCompanyConfiguration,
                EmployerRegistration        = employerRegistration
            };

            string serializedResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                                         new Uri($"{_cotorraUri}"), new object[] { createParmas });

            if (!String.IsNullOrEmpty(serializedResult))
            {
                return(JsonConvert.DeserializeObject <InitializationResult>(serializedResult));
            }
            return(default);
Exemple #2
0
        public async Task <JsonResult> Create(CompanyCreateModel ccm, EmployerRegistrationController.EmployerRegistration er)
        {
            //Create payment periodicity
            PaymentPeriodicity pp;

            if (ccm.PeriodType == "Weekly")
            {
                pp = PaymentPeriodicity.Weekly;
            }
            else if (ccm.PeriodType == "BiWeekly")
            {
                pp = PaymentPeriodicity.Biweekly;
            }
            else
            {
                pp = PaymentPeriodicity.Monthly;
            }

            //Create employer registration
            EmployerRegistration employerRegistration = null;

            if (ccm.HasIMSS)
            {
                var employerRegistrationAddress = new Address
                {
                    ID             = Guid.NewGuid(),
                    ZipCode        = er.ZipCode,
                    FederalEntity  = er.FederalEntity,
                    Municipality   = er.Municipality,
                    Reference      = "",
                    ExteriorNumber = "",
                    InteriorNumber = "",
                    Street         = "",
                    Suburb         = "",

                    //Common
                    Name         = String.Empty,
                    Description  = String.Empty,
                    StatusID     = 1,
                    user         = SessionModel.IdentityID,
                    Timestamp    = DateTime.Now,
                    DeleteDate   = null,
                    Active       = true,
                    company      = SessionModel.CompanyID,
                    InstanceID   = SessionModel.InstanceID,
                    CreationDate = DateTime.Now,
                };

                employerRegistration = new EmployerRegistration
                {
                    ID                = Guid.NewGuid(),
                    Code              = er.Code.ToUpper(),
                    RiskClass         = er.RiskClass,
                    RiskClassFraction = er.RiskClassFraction,
                    AddressID         = employerRegistrationAddress.ID,
                    Address           = employerRegistrationAddress,

                    //Common
                    Active       = true,
                    company      = SessionModel.CompanyID,
                    InstanceID   = SessionModel.InstanceID,
                    CreationDate = DateTime.Now,
                    Description  = String.Empty,
                    StatusID     = 1,
                    user         = SessionModel.IdentityID,
                    Timestamp    = DateTime.Now,
                    DeleteDate   = null,
                    Name         = String.Empty,
                };
            }

            //Create company and employer registration addresses
            var companyAddress = new Address
            {
                ID             = Guid.NewGuid(),
                ZipCode        = er.ZipCode,
                FederalEntity  = er.FederalEntity,
                Municipality   = er.Municipality,
                Reference      = "",
                ExteriorNumber = "",
                InteriorNumber = "",
                Street         = "",
                Suburb         = "",

                //Common
                Name         = String.Empty,
                Description  = String.Empty,
                StatusID     = 1,
                user         = SessionModel.IdentityID,
                Timestamp    = DateTime.Now,
                DeleteDate   = null,
                Active       = true,
                company      = SessionModel.CompanyID,
                InstanceID   = SessionModel.InstanceID,
                CreationDate = DateTime.Now,
            };

            //Create payroll configuration
            var payrollConfiguration = new PayrollCompanyConfiguration()
            {
                //Step 1
                RFC  = ccm.CompanyRFC.ToUpper(),
                CURP = String.IsNullOrEmpty(ccm.CompanyCURP) ? "" : ccm.CompanyCURP.ToUpper(),

                SocialReason = ccm.CompanySocialReason,
                SalaryZone   = Enum.Parse <SalaryZone>(ccm.SalaryZone),
                FiscalRegime = ccm.FiscalRegime,
                AddressID    = companyAddress.ID,
                Address      = companyAddress,
                CurrencyID   = ccm.CurrencyID,

                //Step 2
                //EmployerRegistration

                //Step 3
                PaymentPeriodicity  = pp, //This is used as PeriodType (...)
                CurrentExerciseYear = ccm.CurrentFiscalYear,
                PeriodInitialDate   = ccm.InitialDate,
                CurrentPeriod       = ccm.CurrentPeriod,
                //PeriodTotalDays = ccm.PeriodTotalDays, (internally calculated)
                PaymentDays        = ccm.PaymentDays,
                WeeklySeventhDay   = ccm.WeeklySeventhDay,
                AdjustmentPay      = ccm.FortnightPaymentDays,
                NonDeducibleFactor = ccm.NonDeductibleFactor,

                //Step 4
                CompanyInformation    = ccm.CompanyInformation,
                ComercialName         = ccm.ComercialName,
                CompanyScope          = ccm.CompanyScope,
                CompanyBusinessSector = ccm.CompanyBusinessSector,
                CompanyCreationDate   = ccm.CompanyCreationDate,
                CompanyWebSite        = ccm.CompanyWebSite,
                Facebook  = ccm.Facebook,
                Instagram = ccm.Instagram
            };

            var res = await client.InitializeAsync(
                SessionModel.AuthorizationHeader,
                Guid.Parse(CommonUX.SecurityUX.DecryptString(ccm.LicenseServiceID)),
                ccm.CompanySocialReason,
                ccm.CompanyRFC.ToUpper(),
                payrollConfiguration,
                employerRegistration
                );

            return(Json(new
            {
                CompanyID = CommonUX.SecurityUX.EncryptString(res.CompanyID.ToString(), SessionModel.EncryptKey),
                InstanceID = CommonUX.SecurityUX.EncryptString(res.InstanceID.ToString(), SessionModel.EncryptKey),
                LicenseID = CommonUX.SecurityUX.EncryptString(res.LicenseID.ToString(), SessionModel.EncryptKey),
                LicenseServiceID = CommonUX.SecurityUX.EncryptString(res.LicenseServiceID.ToString(), SessionModel.EncryptKey)
            }));
        }
Exemple #3
0
        public async Task <JsonResult> Save(EmployerRegistration data)
        {
            var lstEmployerRegistration = new List <Cotorra.Schema.EmployerRegistration>();
            var lstAddress = new List <Address>();

            lstAddress.Add(new Address()
            {
                Active       = true,
                company      = SessionModel.CompanyID,
                InstanceID   = SessionModel.InstanceID,
                CreationDate = DateTime.Now,
                Description  = String.Empty,
                ID           = data.AddressID ?? Guid.NewGuid(),
                StatusID     = 1,
                user         = SessionModel.IdentityID,
                Timestamp    = DateTime.Now,

                ExteriorNumber = data.ExteriorNumber,
                ZipCode        = data.ZipCode,
                FederalEntity  = data.FederalEntity,
                InteriorNumber = data.InteriorNumber,
                Municipality   = data.Municipality,
                Reference      = data.Reference,
                Street         = data.Street,
                Suburb         = data.Suburb
            });

            lstEmployerRegistration.Add(new Cotorra.Schema.EmployerRegistration()
            {
                Active       = true,
                company      = SessionModel.CompanyID,
                InstanceID   = SessionModel.InstanceID,
                CreationDate = DateTime.Now,
                Description  = String.Empty,
                ID           = data.ID ?? Guid.NewGuid(),
                StatusID     = 1,
                user         = SessionModel.IdentityID,
                Timestamp    = DateTime.Now,

                Code              = data.Code.ToUpper(),
                DeleteDate        = null,
                Name              = String.Empty,
                RiskClass         = data.RiskClass,
                RiskClassFraction = data.RiskClassFraction,
                AddressID         = data.AddressID ?? lstAddress.FirstOrDefault().ID,
            });

            if (!data.AddressID.HasValue)
            {
                await clientAddress.CreateAsync(lstAddress, SessionModel.IdentityID);
            }
            else
            {
                await clientAddress.UpdateAsync(lstAddress, SessionModel.IdentityID);
            }

            if (!data.ID.HasValue)
            {
                await client.CreateAsync(lstEmployerRegistration, SessionModel.IdentityID);
            }
            else
            {
                await client.UpdateAsync(lstEmployerRegistration, SessionModel.IdentityID);
            }

            return(Json(lstEmployerRegistration.FirstOrDefault().ID));
        }
Exemple #4
0
        public async Task <InitializationResult> InitializeAsync(string authTkn, Guid licenseServiceID, string socialReason, string RFC,
                                                                 PayrollCompanyConfiguration payrollCompanyConfiguration, EmployerRegistration employerRegistration)

        {
            var mgr = new InitializationManager();

            return(await mgr.InitializeAsync(new InitializationParams
            {
                AuthTkn = authTkn,
                LicenseServiceID = licenseServiceID,
                SocialReason = socialReason,
                RFC = RFC,
                PayrollCompanyConfiguration = payrollCompanyConfiguration,
                EmployerRegistration = employerRegistration
            }));
        }
 public async Task <InitializationResult> InitializeAsync(string authTkn, Guid licenseServiceID, string socialReason, string RFC,
                                                          PayrollCompanyConfiguration payrollCompanyConfiguration, EmployerRegistration employerRegistration)
 {
     return(await _client.InitializeAsync(authTkn, licenseServiceID, socialReason, RFC, payrollCompanyConfiguration, employerRegistration));
 }