예제 #1
0
        public static bool CanChangeStatusTo(PartyRole partyRole, CustomerStatusType statusTo)
        {
            CustomerStatu status = GetActive(partyRole);

            if (status == null)
                return true;

            if (status.CustomerStatusTypeId == statusTo.Id)
                return false;

            if (status.CustomerStatusTypeId == CustomerStatusType.NewType.Id)
                return statusTo.Id == CustomerStatusType.ActiveType.Id;
            else if (status.CustomerStatusTypeId == CustomerStatusType.ActiveType.Id)
                return statusTo.Id != CustomerStatusType.NewType.Id;
            else if (status.CustomerStatusTypeId == CustomerStatusType.InactiveType.Id)
                return statusTo.Id == CustomerStatusType.ActiveType.Id;
            else if (status.CustomerStatusTypeId == CustomerStatusType.DelinquentType.Id)
                return statusTo.Id == CustomerStatusType.ActiveType.Id;
            else if (status.CustomerStatusTypeId == CustomerStatusType.SubprimeType.Id)
                return statusTo.Id == CustomerStatusType.ActiveType.Id;
            else
                return false;

            //if (status.CustomerStatusType.Id == CustomerStatusType.ActiveType.Id)
            //{
            //    return statusTo.Id != CustomerStatusType.ActiveType.Id;
            //}
            //else
            //{
            //    return false;
            //}
        }
예제 #2
0
 public static CustomerStatu ChangeStatus(PartyRole partyRole, CustomerStatusType statusTo, DateTime today)
 {
     CustomerStatu status = GetActive(partyRole);
     if (CanChangeStatusTo(partyRole, statusTo))
     {
         return CreateOrUpdateCurrent(partyRole, statusTo, today);
     }
     return status;
 }
예제 #3
0
        public static PartyRole Create(RoleType roletype, int party, DateTime today)
        {
            PartyRole partyRole = new PartyRole();
            partyRole.PartyId = party;
            partyRole.RoleTypeId = roletype.Id;
            partyRole.EffectiveDate = today;
            partyRole.EndDate = null;

            return partyRole;
        }
예제 #4
0
 public static PartyRole CreateChequeRole(Cheque cheque, RoleType roleType, Party party, DateTime today)
 {
     PartyRole partyRole = new PartyRole();
     partyRole.Party = party;
     partyRole.RoleTypeId = roleType.Id;
     partyRole.EffectiveDate = today;
     partyRole.EndDate = null;
     cheque.PartyRole = partyRole;
     Context.Cheques.AddObject(cheque);
     return partyRole;
 }
예제 #5
0
        public static CustomerStatu CreateOrUpdateCurrent(PartyRole partyRole, CustomerStatusType statusTo, DateTime today)
        {
            CustomerStatu customerAppStatus = GetActive(partyRole);
            if (customerAppStatus != null && customerAppStatus.CustomerStatusType.Id != statusTo.Id)
                customerAppStatus.IsActive = false;

            if (customerAppStatus == null || customerAppStatus.CustomerStatusType.Id != statusTo.Id)
            {
                CustomerStatu status = new CustomerStatu();
                status.CustomerStatusType = statusTo;
                status.PartyRoleId = partyRole.Id;
                status.TransitionDateTime = today;
                status.IsActive = true;
                return status;
            }
            return customerAppStatus;
        }
        public static IEnumerable<Receipt> RetrieveReceiptsOfCashPaymentMadeByCustomer(PartyRole customer)
        {
            var payments = from p in Context.Payments
                           where p.ProcessedToPartyRoleId == customer.Id
                           && p.PaymentTypeId == PaymentType.Receipt.Id
                           && (p.PaymentMethodTypeId == PaymentMethodType.CashType.Id ||
                            p.PaymentMethodTypeId == PaymentMethodType.ATMType.Id)
                           select p;

            var receipts = from p in payments
                           join rpa in Context.ReceiptPaymentAssocs on p.Id equals rpa.PaymentId
                           join r in Context.Receipts on rpa.ReceiptId equals r.Id
                           join rs in Context.ReceiptStatus on r.Id equals rs.ReceiptId
                           where rs.IsActive && r.ReceiptBalance > 0
                           && (rs.ReceiptStatusTypeId == ReceiptStatusType.OpenReceiptStatusType.Id ||
                            rs.ReceiptStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id)
                           select r;

            return receipts;
        }
        public static IEnumerable<Cheque> RetrieveChequesOfCustomerWithBalance(PartyRole customer)
        {
            var clearedCheques = from c in Context.Cheques
                                 join cs in Context.ChequeStatus on c.Id equals cs.CheckId
                                 where cs.CheckStatusTypeId == ChequeStatusType.ClearedType.Id
                                 && cs.IsActive
                                 select c;

            var cheques = from c in clearedCheques
                          join p in Context.Payments on c.PaymentId equals p.Id
                          join rpa in Context.ReceiptPaymentAssocs on p.Id equals rpa.PaymentId
                          join r in Context.Receipts on rpa.ReceiptId equals r.Id
                          join rs in Context.ReceiptStatus on r.Id equals rs.ReceiptId
                          where p.ProcessedToPartyRoleId == customer.Id
                          && p.PaymentTypeId == PaymentType.Receipt.Id
                          && r.ReceiptBalance > 0
                          && ((rs.ReceiptStatusTypeId == ReceiptStatusType.OpenReceiptStatusType.Id ||
                          rs.ReceiptStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id)
                          && rs.IsActive)
                          select c;

            return cheques;
        }
        public static List<ChequeViewModel> RetrieveChequeModelOfCustomerWithBalance(PartyRole customer)
        {
            var clearedCheques = from c in Context.Cheques
                                 join cs in Context.ChequeStatus on c.Id equals cs.CheckId
                                 where cs.CheckStatusTypeId == ChequeStatusType.ClearedType.Id
                                 && cs.IsActive
                                 select c;

            var results = from c in clearedCheques
                          join p in Context.Payments on c.PaymentId equals p.Id
                          join rpa in Context.ReceiptPaymentAssocs on p.Id equals rpa.PaymentId
                          join r in Context.Receipts on rpa.ReceiptId equals r.Id
                          join rs in Context.ReceiptStatus on r.Id equals rs.ReceiptId
                          where p.ProcessedToPartyRoleId == customer.Id
                          && p.PaymentTypeId == PaymentType.Receipt.Id
                          && r.ReceiptBalance > 0
                          && ((rs.ReceiptStatusTypeId == ReceiptStatusType.OpenReceiptStatusType.Id ||
                          rs.ReceiptStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id)
                          && rs.IsActive)
                          select new { Cheque = c, Receipt = r };

            var collection = new List<ChequeViewModel>();
            foreach (var result in results)
            {
                var model = new ChequeViewModel(result.Cheque, result.Receipt);
                collection.Add(model);
            }

            return collection;
        }
예제 #9
0
        protected void checkEmployerNames()
        {
            var today = DateTime.Now;
            var personName = txtPersonName.Text;
            //bool res = true;
            var sameName = ObjectContext.EmployersViewLists.SingleOrDefault(entity => entity.Name == personName);

            if (sameName != null)
            {
                int id = sameName.EmployerID;
                X.Msg.Confirm("Message", "An employer record with the same name already exists in the list. Do you want to create another employer record with the same name?", new JFunction("Employer.AddSameEmployer(result, id);", "result")).Show();
            }
            else
            {
                Party party = new Party();
                Person person = new Person();
                Organization org = new Organization();
                PersonName employerFName = new PersonName();
                PersonName employerLName = new PersonName();
                PersonName employerMName = new PersonName();
                PersonName employerNiName = new PersonName();
                PersonName employerNaName = new PersonName();
                PersonName employerTName = new PersonName();
                PersonName employerMMName = new PersonName();

                if (this.txtEmployerPartyType.Text == "Person")
                {
                    party.PartyType = PartyType.PersonType;

                    person.Party = party;

                    employerFName.Person = person;
                    employerFName.PersonNameType = PersonNameType.FirstNameType;
                    employerFName.Name = txtPersonFirstName.Text;
                    employerFName.EffectiveDate = today;

                    employerLName.Person = person;
                    employerLName.PersonNameType = PersonNameType.LastNameType;
                    employerLName.Name = txtPersonLastName.Text;
                    employerLName.EffectiveDate = today;

                    employerMMName.Person = person;
                    employerMMName.PersonNameType = PersonNameType.MothersMaidenNameType;
                    employerMMName.Name = txtPersonMothersMaidenName.Text;
                    employerMMName.EffectiveDate = today;

                    employerMName.Person = person;
                    employerMName.PersonNameType = PersonNameType.MiddleNameType;
                    employerMName.Name = txtPersonMiddleName.Text;
                    employerMName.EffectiveDate = today;

                    employerNaName.Person = person;
                    employerNaName.PersonNameType = PersonNameType.NameSuffixType;
                    employerNaName.Name = txtPersonNameSuffix.Text;
                    employerNaName.EffectiveDate = today;

                    employerNiName.Person = person;
                    employerNiName.PersonNameType = PersonNameType.NickNameType;
                    employerNiName.Name = txtPersonNickName.Text;
                    employerNiName.EffectiveDate = today;

                }
                else
                {
                    party.PartyType = PartyType.OrganizationType;

                    org.OrganizationName = txtOrganizationName.Text;
                    org.Party = party;
                }

                PartyRole partyRole = new PartyRole();
                partyRole.Party = party;
                partyRole.PartyRoleType.RoleType = RoleType.EmployerType;

                var res = Person.CheckEmployerName(partyRole);

                if(res != null)
                    X.Msg.Confirm("Message", "A party record with the same name already exists. Do you want to use this record to create the new employer record?", new JFunction("Employer.AddSameName(result, res);", "result")).Show();
            }
        }
예제 #10
0
        public static PartyRole CheckPersonName(Party party)
        {
            List<PartyRelationship> partyRel = new List<PartyRelationship>();

            var people = Context.People.ToList();
            bool equal = true;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();

            partyRel = Context.PartyRelationships.Where(entity =>
                entity.EndDate == null).ToList();

            if (partyRel != null)
            {
                foreach (var relation in partyRel)
                {
                    Person person = relation.PartyRole.Party.Person;

                    if (person != null)
                        equal = ValidatePersonNameIfEqual(person, party.Person);

                    if (equal)
                    {
                        equalParty = relation.PartyRole.Party;
                        equalPartyRole = relation.PartyRole;
                        break;
                    }
                }
            }
            if (equalParty.Id != 0)
                return equalPartyRole;
            return null;
        }
예제 #11
0
        private static decimal GetCoBorrowerLoanBalance(PartyRole customer,Payment loanPayment)
        {
            decimal totalPayments = 0;
            decimal totalDisbursements = 0;
            var loanAccounts = from farc in Context.FinancialAccountRoles
                               join pr in Context.PartyRoles on farc.PartyRoleId equals pr.Id
                               join ls in Context.LoanAccountStatus on farc.FinancialAccountId equals ls.FinancialAccountId
                               join vcr in Context.LoanDisbursementVcrs on farc.FinancialAccount.AgreementId equals vcr.AgreementId
                               where pr.PartyId == customer.PartyId
                               && pr.EndDate == null
                               && (pr.RoleTypeId == RoleType.CoOwnerFinancialType.Id
                               || pr.RoleTypeId == RoleType.GuarantorFinancialType.Id)
                               && ls.IsActive == true && ls.StatusTypeId != LoanAccountStatusType.RestructuredType.Id
                                   && farc.FinancialAccount.LoanAccount.LoanReleaseDate < loanPayment.EntryDate
                               select new { loanAccount = farc.FinancialAccount.LoanAccount, voucher = vcr};
            var payments = from la in loanAccounts
                           join pa in Context.PaymentApplications on la.loanAccount.FinancialAccountId equals pa.FinancialAccountId
                           join p in Context.Payments on pa.PaymentId equals p.Id
                           where p.Id > loanPayment.Id
                           select pa;
            var disbursements = from la in loanAccounts
                                join pa in Context.PaymentApplications on la.voucher.Id equals pa.LoanDisbursementVoucherId
                                join p in Context.Payments on pa.PaymentId equals p.Id
                                where p.Id > loanPayment.Id
                                select pa;

            if (disbursements.Count() != 0)
                totalDisbursements = disbursements.Sum(e => e.AmountApplied);

            if (payments.Count() != 0)
                totalPayments = payments.Sum(e => e.AmountApplied);

            decimal balance = 0;
            if (loanAccounts.Count() > 0)
                balance = loanAccounts.Sum(entity => entity.loanAccount.LoanBalance);
            balance += totalPayments;
            balance -= totalDisbursements;
            return balance;
        }
예제 #12
0
            public CoownerGuarantorModel(PartyRole partyRole)
            {
                this.FinancialAccountRole = partyRole.PartyRoleType.RoleType.Name;

                this.Name = Person.GetPersonFullName(partyRole.Party);

                var cellNumber = TelecommunicationsNumber.GetCurrentTelecommNumberAddress(partyRole.Party, TelecommunicationsNumberType.PersonalMobileNumberType, true);

                if (cellNumber != null)
                    this.CellphoneNumber = cellNumber.AreaCode + "-" + cellNumber.PhoneNumber;

                var telephoneNumber = TelecommunicationsNumber.GetCurrentTelecommNumberAddress(partyRole.Party, TelecommunicationsNumberType.HomePhoneNumberType, true);
                if (telephoneNumber != null)
                    this.TelephoneNumber = telephoneNumber.AreaCode + "-" + telephoneNumber.PhoneNumber;

                Address postalAddress = partyRole.Party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == AddressType.PostalAddressType.Id
                                    && entity.PostalAddress.PostalAddressTypeId == PostalAddressType.HomeAddressType.Id && entity.PostalAddress.IsPrimary);

                if (postalAddress != null && postalAddress.PostalAddress != null)
                {
                    PostalAddress postalAddressSpecific = postalAddress.PostalAddress;
                    this.PrimaryHomeAddress = StringConcatUtility.Build(", ", postalAddressSpecific.StreetAddress,
                                  postalAddressSpecific.Barangay,
                                  postalAddressSpecific.Municipality,
                                  postalAddressSpecific.City,
                                  postalAddressSpecific.Province,
                                  postalAddressSpecific.State,
                                  postalAddressSpecific.Country.Name,
                                  postalAddressSpecific.PostalCode);
                }
            }
예제 #13
0
        public static PartyRole CheckEmployerName(PartyRole partyRole)
        {
            List<PartyRelationship> partyRel = new List<PartyRelationship>();
            Party party = partyRole.Party;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();
            bool equal = true;

            if (partyRole.Party.PartyType == PartyType.PersonType)
            {
                partyRel = Context.PartyRelationships.Where(entity => (entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.ContactType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.CustomerType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.EmployeeType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.SpouseType.Id)
                           && entity.PartyRole.Party.PartyTypeId == PartyType.PersonType.Id
                           && entity.EndDate == null
                           && entity.PartyRole.EndDate == null).ToList();

                if (partyRel != null)
                {
                    foreach (var relation in partyRel)
                    {
                        Person person = relation.PartyRole.Party.Person;
                        if(person != null)
                            equal = ValidatePersonNameIfEqual(person, party.Person);

                        if (equal)
                        {
                            equalParty = person.Party;
                            equalPartyRole = relation.PartyRole;
                            break;
                        }
                    }
                }
            }
            else
            {
                partyRel = Context.PartyRelationships.Where(entity => (entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.ContactType.Id
                            || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.CustomerType.Id
                            || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.BankType.Id
                            || entity.PartyRole1.PartyRoleType.RoleTypeId == RoleType.LendingInstitutionType.Id
                            || entity.PartyRole1.PartyRoleType.RoleTypeId == RoleType.BankType.Id)
                            && entity.EndDate == null
                            && entity.PartyRole1.EndDate == null).ToList();

                if (partyRel != null)
                {
                    foreach (var relation in partyRel)
                    {
                        Organization organization = relation.PartyRole1.Party.Organization;
                        if (organization == null)
                        {
                            organization = relation.PartyRole1.Party.Organization;
                        }
                        equal &= organization.OrganizationName == party.Organization.OrganizationName;

                        if (equal)
                        {
                            equalParty = organization.Party;
                            equalPartyRole = relation.PartyRole1;
                            break;
                        }
                    }
                }
            }

            if (equalPartyRole.Id != 0)
                return equalPartyRole;
            return null;
        }
예제 #14
0
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            using (var context = new FinancialEntities())
            {
                var today = DateTime.Now;
                Bank bank = new Bank();
                Organization org = null;
                Party party = null;
                if (string.IsNullOrWhiteSpace(hiddenPartyId.Text) != false)
                {
                   party = new Party();
                   org = new Organization();
                   org.Party = party;
                   org.OrganizationName = txtName.Text;
                }
                else
                {
                   int partyId = Convert.ToInt32(hiddenPartyId.Text);
                   party = context.Parties.FirstOrDefault(entity => entity.Id == partyId);
                   org = context.Organizations.FirstOrDefault(entity => entity.PartyId == partyId);
                   org.OrganizationName = txtName.Text;
                  hiddenPartyId.Value = "";
                }
                BankStatu bankStatus = new BankStatu();

                var bankRoleType = context.RoleTypes.SingleOrDefault(entity => entity.Name == RoleTypeEnums.Bank);
                var orgPartyType = context.PartyTypes.SingleOrDefault(entity => entity.Name == PartyTypeEnums.Organization);
                var bankStatusType = context.BankStatusTypes.SingleOrDefault(entity => entity.Name == BankStatusTypeEnum.Active);

                InitialDatabaseValueChecker.ThrowIfNull<RoleType>(bankRoleType);
                InitialDatabaseValueChecker.ThrowIfNull<PartyType>(orgPartyType);
                InitialDatabaseValueChecker.ThrowIfNull<BankStatusType>(bankStatusType);

                party.PartyType = orgPartyType;

                PartyRole partyRole = new PartyRole();
                partyRole.Party = party;
                partyRole.PartyRoleType = bankRoleType.PartyRoleType;
                partyRole.EffectiveDate = today;

                bankStatus.BankStatusType = bankStatusType;
                bankStatus.PartyRoleId = partyRole.Id;
                bankStatus.EffectiveDate = today;

                bank.Branch = this.txtBranch.Text;

                if (string.IsNullOrWhiteSpace(this.txtAcronym.Text)) bank.Acronym = bank.PartyRole.Party.Organization.OrganizationName;
                else bank.Acronym = this.txtAcronym.Text;

                var addressType = context.AddressTypes.SingleOrDefault(entity => entity.Name == AddressTypeEnums.PostalAddress);
                Address postalAdd = AddressBusinessUtility.AddAddress(party, addressType, today);

                var postalAddressType = context.PostalAddressTypes.SingleOrDefault(entity => entity.Name == PostalAddressTypeEnums.BusinessAddress);
                InitialDatabaseValueChecker.ThrowIfNull<PostalAddressType>(postalAddressType);
                PostalAddress specificPostalAddress2 = AddressBusinessUtility.AddPostal(postalAdd, postalAddressType, true);
                int countryId = int.Parse(cmbCountry.Value.ToString());
                var country = context.Countries.FirstOrDefault(entity => entity.Id == countryId);
                InitialDatabaseValueChecker.ThrowIfNull<Country>(country);

                if(string.IsNullOrWhiteSpace(hiddenStreetName.Text)==false)specificPostalAddress2.StreetAddress = hiddenStreetName.Text;
                specificPostalAddress2.Barangay = hiddenBarangay.Text;
                specificPostalAddress2.PostalCode = hiddenPostalCode.Text;
                specificPostalAddress2.Country = country;
                if (string.IsNullOrWhiteSpace(hiddenCity.Text) == false) specificPostalAddress2.City = hiddenCity.Text;
                if (string.IsNullOrWhiteSpace(hiddenMunicipality.Text) == false) specificPostalAddress2.Municipality = hiddenMunicipality.Text;
                if (string.IsNullOrWhiteSpace(hiddenProvince.Text) == false) specificPostalAddress2.Province = hiddenProvince.Text;
                var telAddressType = context.AddressTypes.SingleOrDefault(entity => entity.Name == AddressTypeEnums.TelecommunicationNumber);
                if (string.IsNullOrWhiteSpace(txtAreaCode.Text) ==false)
                {
                    Address telephoneAddress = AddressBusinessUtility.AddAddress(party, telAddressType, today);
                    var telType = context.TelecommunicationsNumberTypes.SingleOrDefault(entity => entity.Name == TelecommunicationsNumberTypeEnums.BusinessPhoneNumber);
                    TelecommunicationsNumber specificTelephoneAddress = AddressBusinessUtility.AddTelNum(telephoneAddress, telType, true);
                    specificTelephoneAddress.AreaCode = txtAreaCode.Text;
                    specificTelephoneAddress.PhoneNumber = txtPhoneNum.Text;
                }
                if (string.IsNullOrWhiteSpace(txtFaxAreaCode.Text)== false)
                {
                    Address faxAddress = AddressBusinessUtility.AddAddress(party, telAddressType, today);
                    var faxType = context.TelecommunicationsNumberTypes.SingleOrDefault(entity => entity.Name == TelecommunicationsNumberTypeEnums.BusinessFaxNumber);
                    TelecommunicationsNumber specificTelephoneAddress1 = AddressBusinessUtility.AddTelNum(faxAddress, faxType, false);
                    specificTelephoneAddress1.AreaCode = txtFaxAreaCode.Text;
                    specificTelephoneAddress1.PhoneNumber = txtFaxNum.Text;
                }
                if (string.IsNullOrWhiteSpace(txtEmailAdd.Text) == false)
                {
                    var emailAddType = context.AddressTypes.SingleOrDefault(entity => entity.Name == AddressTypeEnums.ElectronicAddress);
                    var emailType = context.ElectronicAddressTypes.SingleOrDefault(entity => entity.Name == ElectronicAddressTypeEnums.BusinessEmailAddress);
                    Address email = AddressBusinessUtility.AddAddress(party, emailAddType, today);
                    ElectronicAddress specificEmail = AddressBusinessUtility.AddEmail(email, emailType, true);
                    specificEmail.ElectronicAddressString = txtEmailAdd.Text;
                }

                context.Banks.AddObject(bank);
                context.SaveChanges();
            }
            X.Msg.Alert("Message", "Bank record successfully created").Show();
        }
        public int checkPersonName(string name)
        {
            int result = 0;
            var names = name;

            var today = DateTime.Now;
            Party party = new Party();
            Person person = new Person();
            PersonName customerFName = new PersonName();
            PersonName customerLName = new PersonName();
            PersonName customerMName = new PersonName();
            PersonName customerNiName = new PersonName();
            PersonName customerNaName = new PersonName();
            PersonName customerTName = new PersonName();
            PersonName customerMMName = new PersonName();

            party.PartyType = PartyType.PersonType;

            person.Party = party;

            customerTName.Person = person;
            customerTName.PersonNameType = PersonNameType.TitleType;
            customerTName.Name = cmbTitle.SelectedItem.Text;
            customerTName.EffectiveDate = today;

            customerFName.Person = person;
            customerFName.PersonNameType = PersonNameType.FirstNameType;
            customerFName.Name = txtFirstName.Text;
            customerFName.EffectiveDate = today;

            customerLName.Person = person;
            customerLName.PersonNameType = PersonNameType.LastNameType;
            customerLName.Name = txtLastName.Text;
            customerLName.EffectiveDate = today;

            customerMMName.Person = person;
            customerMMName.PersonNameType = PersonNameType.MothersMaidenNameType;
            customerMMName.Name = txtMothersMaidenName.Text;
            customerMMName.EffectiveDate = today;

            customerMName.Person = person;
            customerMName.PersonNameType = PersonNameType.MiddleNameType;
            customerMName.Name = txtMiddleName.Text;
            customerMName.EffectiveDate = today;

            customerNaName.Person = person;
            customerNaName.PersonNameType = PersonNameType.NameSuffixType;
            customerNaName.Name = txtNameSuffix.Text;
            customerNaName.EffectiveDate = today;

            customerNiName.Person = person;
            customerNiName.PersonNameType = PersonNameType.NickNameType;
            customerNiName.Name = txtNickName.Text;
            customerNiName.EffectiveDate = today;

            PartyRole partyRole = new PartyRole();
            partyRole.Party = party;
            partyRole.RoleTypeId = RoleType.ContactType.Id;

            //check if input name is equal to existing person name
            var sameName = Person.CheckPersonName(party);
            //InitialDatabaseValueChecker.ThrowIfNull<CustomersViewList>(sameName);

            if (sameName != null)
            {
                //X.Msg.Confirm("Message", "A customer record with the same name already exists. Do you want to create another customer record with the same name?", new JFunction("Customer.AddSameCustomer(result);", "result")).Show();
                hiddenID.Value = sameName.Id;
                result = 1;
            }

            return result;
        }
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            using (UnitOfWorkScope scope = new UnitOfWorkScope(true))
            {
                var today = DateTime.Now;

                /*_________________________________________________________QUERIES_________________________________________________________________________________________________________*/

                //Gender Types
                GenderType genderType = radMale.Checked ? GenderType.MaleType : GenderType.FemaleType;

                PartyRole lendingInstitutionPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == RoleType.LendingInstitutionType.Id);

                //retrieve telephone country code
                int countryId = int.Parse(cmbCountry.Value.ToString());
                var country = ObjectContext.Countries.SingleOrDefault(entity => entity.Id == countryId);

                //retreive personName by personNameType
                string personTitle = cmbTitle.Text;
                string personFirstName = txtFirstName.Text;
                string personMiddleName = txtMiddleName.Text;
                string personLastName = txtLastName.Text;
                string personNickName = txtNickName.Text;
                string personNameSuffix = txtNameSuffix.Text;
                string personMothersMaidenName = txtMothersMaidenName.Text;

                /*_________________________________________________________INSERTS______________________________________________________________________________________________________________________________________________________________*/

                //insert partyTypeId to Party
                Party party = new Party();
                party.PartyType = PartyType.PersonType;

                //insert genderTypeId, birthdate to Person
                Person person = new Person();
                person.GenderType = genderType;
                person.Birthdate = dtBirthdate.SelectedDate;

                Person.CreatePersonName(person, today, personTitle, personFirstName,
                    personMiddleName, personLastName, personNameSuffix, personNickName);

                Person.CreateOrUpdatePersonNames(person, PersonNameType.MothersMaidenNameType, personMothersMaidenName, today);

                //insert partyId, roleTypeId, effectiveDate to Party Role
                PartyRole partyRole = new PartyRole();
                partyRole.Party = party;
                partyRole.PartyRoleType = RoleType.ContactType.PartyRoleType;
                partyRole.EffectiveDate = today;

                //insert firstPartyRoleId, secondPartyRoleId, partyRelationshipTypeId to Party Relationship
                PartyRelationship partyRelationshipType = new PartyRelationship();
                partyRelationshipType.PartyRole = partyRole;
                partyRelationshipType.PartyRole1 = lendingInstitutionPartyRole;
                partyRelationshipType.PartyRelType = PartyRelType.ContactRelationshipType;
                partyRelationshipType.EffectiveDate = today;

                if (!string.IsNullOrWhiteSpace(txtCellphoneNumber.Text))
                {
                    TelecommunicationsNumber specificCellphoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.PersonalMobileNumberType, today);
                    specificCellphoneNumber.AreaCode = txtCellphoneAreaCode.Text;
                    specificCellphoneNumber.PhoneNumber = txtCellphoneNumber.Text;
                    specificCellphoneNumber.IsPrimary = true;
                }

                if (!string.IsNullOrWhiteSpace(txtTelephoneNumber.Text))
                {
                    TelecommunicationsNumber specificTelephoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.HomePhoneNumberType, today);
                    specificTelephoneNumber.AreaCode = txtTelephoneAreaCode.Text;
                    specificTelephoneNumber.PhoneNumber = txtTelephoneNumber.Text;
                    specificTelephoneNumber.IsPrimary = true;
                }

                if (!string.IsNullOrWhiteSpace(txtEmailAddress.Text))
                {
                    ElectronicAddress specificEmailAddress = ElectronicAddress.CreateElectronicAddress(party, ElectronicAddressType.PersonalEmailAddressType, today);
                    specificEmailAddress.ElectronicAddressString = txtEmailAddress.Text;
                    specificEmailAddress.IsPrimary = true;
                }

                AddressType addressType = AddressType.PostalAddressType;
                PostalAddressType postalAddressType = PostalAddressType.HomeAddressType;

                //Create an Address with AddressType as Postal Address
                PostalAddress newPostalAddress = new PostalAddress();
                newPostalAddress.Country = country;
                newPostalAddress.Barangay = hiddenBarangay.Text;
                newPostalAddress.PostalCode = hiddenPostalCode.Text;
                newPostalAddress.Province = hiddenProvince.Text;
                newPostalAddress.City = hiddenCity.Text;
                newPostalAddress.Municipality = hiddenMunicipality.Text;
                newPostalAddress.StreetAddress = hiddenStreet.Text;
                newPostalAddress.IsPrimary = true;

                PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, postalAddressType, today, true);

                ObjectContext.Parties.AddObject(party);

            }
        }
        private Party CreateOrRetrieveParty(FinancialEntities ctx, DateTime today)
        {
            Party party;
            int organizationTypeId = int.Parse(cmbOrganizationType.SelectedItem.Value.ToString());
            if (string.IsNullOrWhiteSpace(HiddenPartyId.Text))
            {
                var partyType = ctx.PartyTypes.First(x => x.Name.Equals("Organization"));

                party = new Party();
                party.PartyTypeId = partyType.Id;

                var roleType = ctx.RoleTypes.SingleOrDefault(entity => entity.Name.Equals("Lending Institution"));
                PartyRole newPartyRole = new PartyRole();
                newPartyRole.Party = party;
                newPartyRole.PartyRoleType = roleType.PartyRoleType;
                newPartyRole.EffectiveDate = today;

                Organization organization = new Organization();
                organization.Party = party;//
                organization.OrganizationTypeId = organizationTypeId;
                organization.OrganizationName = txtName.Text;
                organization.DateEstablished = Convert.ToDateTime(dfDateEstablished.Text);
                ctx.Parties.AddObject(party);
            }
            else
            {
                int partyId = int.Parse(HiddenPartyId.Text);
                party = ctx.Parties.SingleOrDefault(entity => entity.Id == partyId);
                Organization organization = party.Organization;
                organization.OrganizationTypeId = organizationTypeId;
                organization.OrganizationName = txtName.Text;
                organization.DateEstablished = Convert.ToDateTime(dfDateEstablished.Text);
            }
            return party;
        }
예제 #18
0
 public SignatoriesModel(PartyRole partyRole)
 {
     this.Id = partyRole.Id;
     this.Name = partyRole.Party.NameV2.ToUpper();
 }
예제 #19
0
        public static PartyRole CheckPersonNameParty(Party party, Party employeeParty)
        {
            List<PartyRelationship> partyRel = new List<PartyRelationship>();

            var people = Context.People.ToList();
            bool equal = true;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();

            partyRel = Context.PartyRelationships.Where(entity =>
                           (entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.ContactType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.EmployeeType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.SpouseType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.CoBorrowerAgreementType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.CoBorrowerApplicationType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.GuarantorAgreementType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.GuarantorApplicationType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.GuarantorFinancialType.Id)
                           && entity.PartyRole.Party.PartyTypeId == PartyType.PersonType.Id
                           && entity.EndDate == null
                           && entity.PartyRole.EndDate == null
                           && entity.PartyRole.PartyId != employeeParty.Id
                           && entity.PartyRole.Party.PartyRoles.Where(c => c.RoleTypeId == RoleType.CustomerType.Id
                                        && entity.EndDate == null).Count() == 0).ToList();

            if (partyRel != null)
            {
                foreach (var relation in partyRel)
                {
                    Person person = relation.PartyRole.Party.Person;
                    if(person != null)
                        equal = ValidatePersonNameIfEqual(person, party.Person);

                    if (equal)
                    {
                        equalPartyRole = relation.PartyRole;

                        break;
                    }
                }
            }

            if (equalPartyRole.Id != 0)
                return equalPartyRole;
            return null;
        }
예제 #20
0
        public void UpdateOrNot(PartyRole partyRole)
        {
            DateTime today = DateTime.Now;
            var lenderPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == RoleType.LendingInstitutionType.Id);//Lending Institution
            var EmployeeView = ObjectContext.EmployeeViewLists.SingleOrDefault(entity => entity.EmployeeId == partyRole.Id);
            var party = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.Id == partyRole.Id && entity.EndDate == null).Party;
            var person = party.Person;
            var employee = ObjectContext.Employees.SingleOrDefault(entity => entity.PartyRoleId == partyRole.Id);
            var partyRelationShip = ObjectContext.PartyRelationships.SingleOrDefault(entity => entity.FirstPartyRoleId == partyRole.Id && entity.SecondPartyRoleId == lenderPartyRole.Id                                                  && entity.EndDate == null);
            var employment = ObjectContext.Employments.SingleOrDefault(entity => entity.PartyRelationshipId == partyRelationShip.Id);
            string concatinatedTIN = ConcatinateTIN(txtTIN.Text, txtTIN1.Text, txtTIN2.Text, txtTIN3.Text);

            Person.CreateOrUpdatePersonNames(person, PersonNameType.TitleType, hdnTitle.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.FirstNameType, hdnFirstName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.MiddleNameType, hdnMiddleName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.LastNameType, hdnLastName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.NameSuffixType, hdnSuffix.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.NickNameType, hdnNickName.Text, today);

            /*------------------------------------------------------------------------------------------------------------------*/
            GenderType genderType;
            if(radioFemale.Checked) genderType = GenderType.FemaleType;
            else genderType = GenderType.MaleType;

            if(person.GenderType != genderType) person.GenderType = genderType;//gender
            if(person.Birthdate != dtBirthDate.SelectedDate) person.Birthdate = dtBirthDate.SelectedDate;//birthdate

            string stringPersinPictureFile  = hdnPersonPicture.Value.ToString();
            if (person.ImageFilename != stringPersinPictureFile) person.ImageFilename = hdnPersonPicture.Value.ToString();//imagepicture

            if (employee.EmployeeIdNumber != txtEmployeeIdNumber.Text)
            {
                if (string.IsNullOrWhiteSpace(txtEmployeeIdNumber.Text))
                {
                    employee.EmployeeIdNumber = null;
                }
                else
                {
                    employee.EmployeeIdNumber = txtEmployeeIdNumber.Text;//employeeidnumber
                }
            }
            if (employee.Position != cmbPosition.SelectedItem.Text) employee.Position = cmbPosition.SelectedItem.Text;//position
            if(employment.EmploymentStatus != cmbEmploymentStatus.SelectedItem.Text) employment.EmploymentStatus = cmbEmploymentStatus.SelectedItem.Text;//employmentstatus
            if(employment.Salary != txtSalary.Text) employment.Salary = txtSalary.Text;//salary

            Taxpayer.CreateOrUpdateTaxPayer(partyRole, concatinatedTIN);//tin

            if(employee.SssNumber != txtSSSNumber.Text) employee.SssNumber = txtSSSNumber.Text;//sssnumber
            if(employee.PhicNumber != txtPHICNumber.Text) employee.PhicNumber = txtPHICNumber.Text;//phicnumber
            /*------------------------------------------------------------------------------------------------------------------*/

            /**  CONTACT INFO DETAILS  **/

            /*------------------------------------------------------------------------------------------------------------------*/
            //Primary Home Address
            PostalAddress newPostalAddress = new PostalAddress();
            newPostalAddress.StreetAddress = hdnStreetAddress.Text;
            newPostalAddress.Barangay = hdnBarangay.Text;
            newPostalAddress.City = hdnCity.Text;
            newPostalAddress.Municipality = hdnMunicipality.Text;
            newPostalAddress.Province = hdnProvince.Text;
            newPostalAddress.State = hdnState.Text;
            newPostalAddress.PostalCode = hdnPostalCode.Text;
            newPostalAddress.CountryId = int.Parse(hdnCountryId.Text);
            newPostalAddress.IsPrimary = true;
            PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, PostalAddressType.HomeAddressType, today, true);

            //Home Phone
            TelecommunicationsNumber newTelePhoneNumber = new TelecommunicationsNumber();
            newTelePhoneNumber.AreaCode = txtTeleAreaCode.Text;
            newTelePhoneNumber.PhoneNumber = txtTelePhoneNumber.Text;
            newTelePhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.HomePhoneNumberType;
            newTelePhoneNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newTelePhoneNumber, TelecommunicationsNumberType.HomePhoneNumberType, today, true);

            //Personal Mobile
            TelecommunicationsNumber newCellPhoneNumber = new TelecommunicationsNumber();
            newCellPhoneNumber.AreaCode = txtCellAreaCode.Text;
            newCellPhoneNumber.PhoneNumber = txtCellPhoneNumber.Text;
            newCellPhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.PersonalMobileNumberType;
            newCellPhoneNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newCellPhoneNumber, TelecommunicationsNumberType.PersonalMobileNumberType, today, true);

            //Electronic Address
            ElectronicAddress newEmailAddress = new ElectronicAddress();
            newEmailAddress.ElectronicAddressString = txtPrimaryEmailAddress.Text;
            newEmailAddress.ElectronicAddressType = ElectronicAddressType.PersonalEmailAddressType;
            newEmailAddress.IsPrimary = true;
            ElectronicAddress.CreateOrUpdateElectronicAddress(party, newEmailAddress, ElectronicAddressType.PersonalEmailAddressType, entity => entity.ElectronicAddress.IsPrimary == true, today);
        }
예제 #21
0
        public static LoanPayment CreateLoanPayment(Payment payment, PartyRole customerPartyRole)
        {
            decimal OwnerLoanBalance = 0;
            decimal OwnerInterest = 0;
            decimal CoOwnerBalance = 0;
            decimal CoOwnerInterest = 0;

            var ownerLoans = from farc in Context.FinancialAccountRoles
                               join pr in Context.PartyRoles on farc.PartyRoleId equals pr.Id
                               join ls in Context.LoanAccountStatus on farc.FinancialAccountId equals ls.FinancialAccountId
                               where pr.PartyId == customerPartyRole.PartyId
                               && pr.EndDate == null
                               && (pr.RoleTypeId == RoleType.OwnerFinancialType.Id)
                               && ls.IsActive == true && (ls.StatusTypeId != LoanAccountStatusType.RestructuredType.Id
                               && ls.StatusTypeId != LoanAccountStatusType.PaidOffType.Id)
                               select ls.LoanAccount;
            if (ownerLoans.Count() != 0)
                OwnerLoanBalance = ownerLoans.Sum(entity => entity.LoanBalance);

            var coOwnerLoans = from farc in Context.FinancialAccountRoles
                               join pr in Context.PartyRoles on farc.PartyRoleId equals pr.Id
                               join ls in Context.LoanAccountStatus on farc.FinancialAccountId equals ls.FinancialAccountId
                               where pr.PartyId == customerPartyRole.PartyId
                               && pr.EndDate == null
                               && (pr.RoleTypeId == RoleType.CoOwnerFinancialType.Id
                               || pr.RoleTypeId == RoleType.GuarantorFinancialType.Id)
                               && ls.IsActive == true && (ls.StatusTypeId != LoanAccountStatusType.RestructuredType.Id
                               && ls.StatusTypeId != LoanAccountStatusType.PaidOffType.Id)
                               select ls.LoanAccount;

            if (coOwnerLoans.Count() != 0)
                CoOwnerBalance = coOwnerLoans.Sum(entity => entity.LoanBalance);

            var ownerReceivables = from l in ownerLoans
                              join r in Context.Receivables on l.FinancialAccountId equals r.FinancialAccountId
                              join rs in Context.ReceivableStatus on r.Id equals rs.ReceivableId
                              where rs.IsActive == true && r.Balance > 0 && (rs.StatusTypeId == ReceivableStatusType.OpenType.Id
                              || rs.StatusTypeId == ReceivableStatusType.PartiallyPaidType.Id)
                              select r;

            if (ownerReceivables.Count() != 0)
                OwnerInterest = ownerReceivables.Sum(entity => entity.Balance);

            var coOwnerReceivables = from l in coOwnerLoans
                                   join r in Context.Receivables on l.FinancialAccountId equals r.FinancialAccountId
                                   join rs in Context.ReceivableStatus on r.Id equals rs.ReceivableId
                                   where rs.IsActive == true && r.Balance > 0 && (rs.StatusTypeId == ReceivableStatusType.OpenType.Id
                                   || rs.StatusTypeId == ReceivableStatusType.PartiallyPaidType.Id)
                                   select r;

            if (coOwnerReceivables.Count() != 0)
                CoOwnerInterest = coOwnerReceivables.Sum(entity => entity.Balance);

            LoanPayment loanpayment = new LoanPayment();
            loanpayment.Payment = payment;
            loanpayment.OwnerOutstandingLoan = OwnerLoanBalance;
            loanpayment.OwnerOutstandingInterest = OwnerInterest;
            loanpayment.CoOwnerOutstandingLoan = CoOwnerBalance;
            loanpayment.CoOwnerOutstandingInterest = CoOwnerInterest;
            return loanpayment;
        }
예제 #22
0
        public static PartyRole CheckEmployeePersonName(PartyRole partyRole)
        {
            List<PartyRelationship> partyRel = new List<PartyRelationship>();

            var lenderPartyRole = Context.PartyRoles.SingleOrDefault(entity => entity.EndDate == null && entity.RoleTypeId == RoleType.LendingInstitutionType.Id);
            var people = Context.People.ToList();
            bool equal = true;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();
            var party = partyRole.Party;

            partyRel = Context.PartyRelationships.Where(entity => entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.EmployeeType.Id
                                                        && entity.PartyRole.Party.PartyTypeId == PartyType.PersonType.Id
                                                        && entity.SecondPartyRoleId == lenderPartyRole.Id
                                                        && entity.EndDate == null
                                                        && entity.PartyRole.EndDate == null).ToList();

            if (partyRel != null)
            {
                foreach (var relation in partyRel)
                {
                    Person person = relation.PartyRole.Party.Person;
                    if (person != null)
                        equal = ValidatePersonNameIfEqual(person, party.Person);

                    if (equal)
                    {
                        equalParty = relation.PartyRole.Party;
                        equalPartyRole = relation.PartyRole;
                        break;
                    }
                }
            }

            if (equalPartyRole.Id != 0)
                return equalPartyRole;
            return null;
        }
예제 #23
0
        public static PartyRole CreateLoanApplicationRole(LoanApplication loanApplication, RoleType roletype, Party party, DateTime today)
        {
            PartyRole partyRole = new PartyRole();
            partyRole.Party = party;
            partyRole.RoleTypeId = roletype.Id;
            partyRole.EffectiveDate = today;
            partyRole.EndDate = null;

            LoanApplicationRole loanApplicationRole = new LoanApplicationRole();
            loanApplicationRole.LoanApplication = loanApplication;
            loanApplicationRole.PartyRole = partyRole;

            Context.LoanApplicationRoles.AddObject(loanApplicationRole);

            return partyRole;
        }
예제 #24
0
        public static PartyRole CheckAllowedEmployeeName(PartyRole partyRole)
        {
            List<PartyRelationship> partyRel = new List<PartyRelationship>();
            Party party = partyRole.Party;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();
            bool equal = true;

            if (partyRole.Party.PartyType == PartyType.PersonType)
            {
                partyRel = Context.PartyRelationships.Where(entity => (entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.ContactType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.CustomerType.Id
                           || entity.PartyRole.PartyRoleType.RoleTypeId == RoleType.EmployerType.Id)
                           && entity.PartyRole.Party.PartyTypeId == PartyType.PersonType.Id
                           && entity.EndDate == null
                           && entity.PartyRole.EndDate == null).ToList();

                if (partyRel != null)
                {
                    foreach (var relation in partyRel)
                    {
                        Person person = relation.PartyRole.Party.Person;
                        if (person != null)
                            equal = ValidatePersonNameIfEqual(person, party.Person);

                        if (equal)
                        {
                            equalParty = person.Party;
                            equalPartyRole = relation.PartyRole;
                            break;
                        }
                    }
                }
            }

            if (equalPartyRole.Id != 0)
                return equalPartyRole;
            return null;
        }
예제 #25
0
        public int checkEmployerName()
        {
            var result = 0;
            var today = DateTime.Now;
            var personName = this.PersonName;

            Party party = new Party();
            Person person = new Person();
            Organization org = new Organization();
            PersonName employerFName = new PersonName();
            PersonName employerLName = new PersonName();
            PersonName employerMName = new PersonName();
            PersonName employerNiName = new PersonName();
            PersonName employerNaName = new PersonName();
            PersonName employerTName = new PersonName();
            PersonName employerMMName = new PersonName();

            party.PartyType = PartyType.PersonType;

            person.Party = party;

            if (this.txtEmployerPartyType.Text == "Person")
            {
                party.PartyType = PartyType.PersonType;

                person.Party = party;

                employerFName.Person = person;
                employerFName.PersonNameType = PersonNameType.FirstNameType;
                employerFName.Name = txtPersonFirstName.Text;
                employerFName.EffectiveDate = today;

                employerLName.Person = person;
                employerLName.PersonNameType = PersonNameType.LastNameType;
                employerLName.Name = txtPersonLastName.Text;
                employerLName.EffectiveDate = today;

                employerMMName.Person = person;
                employerMMName.PersonNameType = PersonNameType.MothersMaidenNameType;
                employerMMName.Name = txtPersonMothersMaidenName.Text;
                employerMMName.EffectiveDate = today;

                employerMName.Person = person;
                employerMName.PersonNameType = PersonNameType.MiddleNameType;
                employerMName.Name = txtPersonMiddleName.Text;
                employerMName.EffectiveDate = today;

                employerNaName.Person = person;
                employerNaName.PersonNameType = PersonNameType.NameSuffixType;
                employerNaName.Name = txtPersonNameSuffix.Text;
                employerNaName.EffectiveDate = today;

                employerNiName.Person = person;
                employerNiName.PersonNameType = PersonNameType.NickNameType;
                employerNiName.Name = txtPersonNickName.Text;
                employerNiName.EffectiveDate = today;

                employerTName.Person = person;
                employerTName.PersonNameType = PersonNameType.TitleType;
                employerTName.Name = txtPersonTitle.Text;
                employerTName.EffectiveDate = today;
            }
            else
            {
                party.PartyType = PartyType.OrganizationType;

                org.OrganizationName = txtOrganizationName.Text;
                org.Party = party;
            }

            PartyRole partyRole = new PartyRole();
            partyRole.Party = party;
            partyRole.RoleTypeId = RoleType.EmployerType.Id;

            //bool res = true;
            var sameName = Person.CheckEmployerPersonName(partyRole);

            if (sameName != null)
            {
                int id = sameName.Id;
                //X.Msg.Confirm("Message", "An employer record with the same name already exists in the list. Do you want to create another employer record with the same name?", new JFunction("Employer.AddSameEmployer(result, id);", "result")).Show();
                this.hiddenID.Value = id;
                result = 1;
            }
            else
            {

                var res = Person.CheckEmployerName(partyRole);

                if (res != null)
                {
                    //X.Msg.Confirm("Message", "A party record with the same name already exists. Do you want to use this record to create the new employer record?", new JFunction("Employer.AddSameName(result, res);", "result")).Show();
                    result = 2;
                    hiddenID.Value = res.Id;
                    hiddenExistingParty.Value = res.PartyId;
                    hiddenExistingPartyRole.Value = res.Id;

                }
            }

            return result;
        }
예제 #26
0
        public static PartyRole CheckEmployerPersonName(PartyRole partyRole)
        {
            List<PartyRole> partyRel = new List<PartyRole>();

            var people = Context.People.ToList();
            bool equal = true;
            Party equalParty = new Party();
            PartyRole equalPartyRole = new PartyRole();
            var party = partyRole.Party;

            if (partyRole.Party.PartyType == PartyType.PersonType)
            {
                partyRel = Context.PartyRoles.Where(entity => entity.PartyRoleType.RoleTypeId == RoleType.EmployerType.Id
                                                            && entity.Party.PartyTypeId == PartyType.PersonType.Id
                                                            && entity.EndDate == null).ToList();

                if (partyRel != null)
                {
                    foreach (var relation in partyRel)
                    {
                        Person person = relation.Party.Person;
                        if (person != null)
                            equal = ValidatePersonNameIfEqual(person, party.Person);

                        if (equal)
                        {
                            equalParty = relation.Party;
                            equalPartyRole = relation;
                            break;
                        }
                    }
                }
            }
            else
            {
                partyRel = Context.PartyRoles.Where(entity => entity.PartyRoleType.RoleTypeId == RoleType.EmployerType.Id
                                                            && entity.Party.PartyTypeId == PartyType.OrganizationType.Id
                                                            && entity.EndDate == null).ToList();

                if (partyRel != null)
                {
                    foreach (var relation in partyRel)
                    {
                        Organization organization = relation.Party.Organization;
                        if (organization == null)
                        {
                            organization = relation.Party.Organization;
                        }
                        equal &= organization.OrganizationName == party.Organization.OrganizationName;

                        if (equal)
                        {
                            equalParty = organization.Party;
                            equalPartyRole = relation;
                            break;
                        }
                    }
                }
            }

            if (equalPartyRole.Id != 0)
                return equalPartyRole;
            return null;
        }
            public NameAddressModel(PartyRole partyRole)
            {
                this.Name = Person.GetPersonFullName(partyRole.Party);

                Address postalAddress = partyRole.Party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == AddressType.PostalAddressType.Id
                                    && entity.PostalAddress.PostalAddressTypeId == PostalAddressType.HomeAddressType.Id && entity.PostalAddress.IsPrimary);

                if (postalAddress != null && postalAddress.PostalAddress != null)
                {
                    PostalAddress postalAddressSpecific = postalAddress.PostalAddress;
                    this.Address = StringConcatUtility.Build(", ", postalAddressSpecific.StreetAddress,
                                  postalAddressSpecific.Barangay,
                                  postalAddressSpecific.Municipality,
                                  postalAddressSpecific.City,
                                  postalAddressSpecific.Province,
                                  postalAddressSpecific.State,
                                  postalAddressSpecific.Country.Name,
                                  postalAddressSpecific.PostalCode);
                }

                this.Spacer = "";
            }
예제 #28
0
 public static CustomerStatu GetActive(PartyRole partyRole)
 {
     return Context.CustomerStatus.FirstOrDefault(entity => entity.IsActive && entity.PartyRoleId == partyRole.Id);
 }
        private void SaveBasicOrganizationContactInformation()
        {
            var today = DateTime.Now;

            //insert partyTypeId to Party
            PartyType partyType = ObjectContext.PartyTypes.SingleOrDefault(entity => entity.Name == PartyTypeEnums.Organization);
            Party party = new Party();
            party.PartyType = partyType;

            //insert organizationType, organizationName and dateEstablished to Organization
            OrganizationType internalOrganization = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Name == OrganizationTypeEnums.Internal);
            OrganizationType externalOrganization = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Name == OrganizationTypeEnums.External);
            Organization organization = new Organization();
            organization.OrganizationName = txtName.Text;
            if (!string.IsNullOrWhiteSpace(cmbOrganizationType.SelectedItem.Text))
            {
                int organizationTypeId = int.Parse(cmbOrganizationType.Value.ToString());
                var organizationType = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Id == organizationTypeId);
                organization.OrganizationType = organizationType;
            }
            else
            {
                organization.OrganizationTypeId = null;
            }
            if (dtDateEstablished.SelectedValue != null)
                organization.DateEstablished = dtDateEstablished.SelectedDate;
            else
                organization.DateEstablished = null;

            //retirieve contactRoleType from Role Type where name = "Contact"
            var contactRoleType = ObjectContext.RoleTypes.SingleOrDefault(entity => entity.Name == RoleTypeEnums.Contact);

            //insert partyId, contactRoleType and effectiveDate to Party Role
            PartyRole partyRole = new PartyRole();
            partyRole.Party = party;
            partyRole.PartyRoleType = contactRoleType.PartyRoleType;
            partyRole.EffectiveDate = today;

            //insert firstPartyRoleId, secondPartyRoleId and EffectiveDate to PartyRelationship
            var contactRelationshipType = ObjectContext.PartyRelTypes.SingleOrDefault(entity => entity.Name == PartyRelationTypesEnums.ContactRelationship);
            RoleType lendingInstitution = ObjectContext.RoleTypes.SingleOrDefault(entity => entity.Name == RoleTypeEnums.LendingInstitution);
            PartyRole lendingInstitutionPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == lendingInstitution.Id);
            PartyRelationship partyRelationship = new PartyRelationship();
            partyRelationship.PartyRole = partyRole;
            partyRelationship.PartyRole1 = lendingInstitutionPartyRole;
            partyRelationship.PartyRelType = contactRelationshipType;
            partyRelationship.EffectiveDate = today;

            //retrieve postalAddressCategoryType from AddressType where name = "Postal Address"
            var postalAddressCategoryType = ObjectContext.AddressTypes.SingleOrDefault(entity => entity.Name == AddressTypeEnums.PostalAddress);

            //retrieve businessAddressCategory from Address where addressType = postalAddressCategoryType and name = "Business Address"
            var primaryBusinessAddress = ObjectContext.PostalAddressTypes.SingleOrDefault(entity => entity.Name == PostalAddressTypeEnums.BusinessAddress);

            //insert address
            int countryId = int.Parse(cmbCountry.Value.ToString());
            var country = ObjectContext.Countries.SingleOrDefault(entity => entity.Id == countryId);

            AddressType addressType = AddressType.PostalAddressType;
            PostalAddressType postalAddressType = PostalAddressType.BusinessAddressType;

            //Create an Address with AddressType as Postal Address
            PostalAddress newPostalAddress = new PostalAddress();
            newPostalAddress.Country = country;
            newPostalAddress.Barangay = hiddenBarangay.Text;
            newPostalAddress.PostalCode = hiddenPostalCode.Text;
            newPostalAddress.Province = hiddenProvince.Text;
            newPostalAddress.City = hiddenCity.Text;
            newPostalAddress.Municipality = hiddenMunicipality.Text;
            newPostalAddress.StreetAddress = hiddenStreet.Text;
            newPostalAddress.IsPrimary = true;

            PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, postalAddressType, today, true);
            //retrieve telecommunicationNumberType

            if (!string.IsNullOrWhiteSpace(txtFaxNumber.Text))
            {
                TelecommunicationsNumber specificCellphoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.BusinessFaxNumberType, today);
                specificCellphoneNumber.AreaCode = txtFaxAreaCode.Text;
                specificCellphoneNumber.PhoneNumber = txtFaxNumber.Text;
                specificCellphoneNumber.IsPrimary = true;
            }

            if (!string.IsNullOrWhiteSpace(txtTelephoneNumber.Text))
            {
                TelecommunicationsNumber specificTelephoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.BusinessPhoneNumberType, today);
                specificTelephoneNumber.AreaCode = txtTelephoneAreaCode.Text;
                specificTelephoneNumber.PhoneNumber = txtTelephoneNumber.Text;
                specificTelephoneNumber.IsPrimary = true;
            }

            if (!string.IsNullOrWhiteSpace(txtEmailAddress.Text))
            {
                ElectronicAddress specificEmailAddress = ElectronicAddress.CreateElectronicAddress(party, ElectronicAddressType.BusinessEmailAddressType, today);
                specificEmailAddress.ElectronicAddressString = txtEmailAddress.Text;
                specificEmailAddress.IsPrimary = true;
            }

            ObjectContext.Parties.AddObject(party);
        }
예제 #30
-1
        public static void CreateOrUpdateTaxPayer(PartyRole partyRole, string tin)
        {
            var taxPayer = Context.Taxpayers.SingleOrDefault(entity => entity.PartyRoleId == partyRole.Id);
            if (taxPayer != null)
            {
                if (taxPayer.Tin == tin) return;
                //if (string.IsNullOrWhiteSpace(tin))
                //{
                //    Context.Taxpayers.DeleteObject(taxPayer);
                //    return;
                //}
                taxPayer.Tin = tin;
                return;
            }

            if (string.IsNullOrWhiteSpace(tin)) return;

            Taxpayer NewTaxPayer = new Taxpayer();
            NewTaxPayer.PartyRoleId = partyRole.Id;
            NewTaxPayer.Tin = tin;

            Context.Taxpayers.AddObject(NewTaxPayer);
        }