Ejemplo n.º 1
0
        static void Main()
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, 43, true);

            var list = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            {
                ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes
            });

            var list2 = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
            {
                ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                ApplicationId = 571,
                ApplicationIdSpecified = true
            });

            var t = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
                {
                    ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                    ApplicationId = loan.Id,
                    ApplicationIdSpecified = true
                });

            var tt = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            {
                ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes,
                Id = t[0].CollateralId,
                IdSpecified = true
            });

            //c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.);
        }
Ejemplo n.º 2
0
        private void SyncUsers()
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var apiUsers = l.ListUsers(new AltasoftAPI.LoansAPI.ListUsersQuery());

            using (var db = new AltasoftDailyContext())
            {
                var dbUsers = db.Users.ToList();

                foreach (var user in apiUsers)
                {
                    var dbUser = dbUsers.FirstOrDefault(x => x.AltasoftUserID == user.Id);

                    if (dbUser == null)
                    {
                        var newUser = new User();

                        newUser.Username = user.LoginName.Replace("@businesscredit.ge", "");
                        newUser.AltasoftUserID = user.Id;
                        newUser.DeptID = user.DeptId;
                        newUser.Name = user.DisplayName.Split(' ').FirstOrDefault();
                        newUser.Password = "******";
                        newUser.LastName = user.DisplayName.Split(' ').LastOrDefault();
                        newUser.LastPasswordChange = DateTime.Now;

                        db.Users.Add(newUser);
                    }
                }

                var saved = db.SaveChanges();
            }
        }
        private void ViewCollateralsForm_Load(object sender, EventArgs e)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            AltasoftAPI.LoansAPI.Application app;
            bool? n;
            bool n2;

            l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.Basic | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extensions, true, loanId, true, out n, out n2, out app);

            var collaterals = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
            {
                ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                ApplicationId = app.Id.Value,
                ApplicationIdSpecified = app.IdSpecified
            });

            List<CollateralModel> list = new List<CollateralModel>();

            foreach (var item in collaterals)
            {
                var coll = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
                {
                    Id = item.CollateralId,
                    IdSpecified = item.CollateralIdSpecified,
                    ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes
                });

                var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, coll[0].OwnerId.Value, true);

                var col = new CollateralModel()
                {
                    Name = customer.Name.ValueGeo,
                    AgreementNumber = coll[0].AgreementNo,
                    CCy = item.LinkAmount.Ccy,
                    CollateralID = coll[0].CollateralId,
                    Discount = coll[0].Discount,
                    LiquidationAmount = item.LinkAmount.Amount,
                    MarketPrice = coll[0].MarketValue,
                    CloseDate = item.CloseDate
                };

                list.Add(col);
            }

            dataGridView1.DataSource = list;
        }
Ejemplo n.º 4
0
        private void CustomersForm_Load(object sender, EventArgs e)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            Customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Classifiers | AltasoftAPI.CustomersAPI.CustomerControlFlags.IdentityDocuments | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses | AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions | AltasoftAPI.CustomersAPI.CustomerControlFlags.ContactPersons, true, 431, true);

            CustomerEntity = Customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity;
            tbxName.Text = CustomerEntity.Name.FirstName.ValueGeo;
            tbxLastName.Text = CustomerEntity.Name.LastName.ValueGeo;
            if (CustomerEntity.Name.FathersName != null)
                tbxFathersName.Text = CustomerEntity.Name.FathersName.ValueGeo;

            dtpBirthDate.Value = CustomerEntity.BirthPlaceDateAndCountry.Date.Value;
            cbxType.SelectedItem = CustomerEntity.Type.Value.ToString();
            if (CustomerEntity.Subtype2Specified)
                cbxSubType.SelectedItem = CustomerEntity.Subtype2.Value.ToString();

            cbxCitizenship.SelectedItem = CustomerEntity.Citizenship;

            gridDocuments.DataSource = CustomerEntity.IdentityDocuments;

            tbxHome.Text = Customer.ContactInfo.Phone;
            tbxMobile.Text = Customer.ContactInfo.MobilePhone;

            tbxAddress.Text = Customer.AddressLegal.Value.ValueGeo;
            tbxAddressFact.Text = Customer.AddressActual.Value.ValueGeo;

            this.Text += Customer.Id.Value.ToString();

            ///////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////
            //var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, 43, true);

            //var list = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            //{
            //    ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes
            //});

            //var list2 = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
            //{
            //    ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
            //    ApplicationId = 571,
            //    ApplicationIdSpecified = true
            //});

            //var t = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
            //{
            //    CollateralId = list.FirstOrDefault().CollateralId,
            //    CollateralIdSpecified = list.FirstOrDefault().CollateralIdSpecified,
            //    ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
            //    ApplicationIdSpecified = true
            //});

            //var tt = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            //{
            //    ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes,
            //    Id = t[0].CollateralId,
            //    IdSpecified = true,
            //});
        }
Ejemplo n.º 5
0
        private void CollateralForm_Load(object sender, EventArgs e)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var collateral = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            {
                ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes,
                Id = collateralID,
                IdSpecified = true
            });

            var linked = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
            {
                CollateralId = collateralID,
                CollateralIdSpecified = true,
                ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                ApplicationIdSpecified = true
            });

            tbxType.Text = collateral[0].CollateralType;

            var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses | AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, collateral[0].OwnerId.Value, true);

            tbxOwner.Text = collateral[0].OwnerId.Value.ToString() + " | " + customer.Name.ValueGeo;
            tbxIdNumber.Text = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN;
            tbxBranch.Text = customer.BranchId.Value.ToString();
            tbxAgreement.Text = collateral[0].AgreementNo;
            tbxAddressLegal.Text = customer.AddressLegal.Value.ValueGeo;
            tbxMobile.Text = customer.ContactInfo.MobilePhone;
            tbxPhone.Text = customer.ContactInfo.Phone;

            var relations = new List<RelationModel>();

            foreach (var item in linked)
            {
                bool? n;
                bool n2;
                AltasoftAPI.LoansAPI.Application app;
                l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.Basic | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extended | AltasoftAPI.LoansAPI.ApplicationControlFlags.ExtraFields | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extensions, true, item.ApplicationId.Value, true, out n, out n2, out app);

                var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, app.Id.Value, true);
                var customer2 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, loan.BorrowerId.Value, true);

                var r = new RelationModel()
                {
                    AgreementNo = loan.AgreementNo,
                    Amount = item.LinkAmount.Amount,
                    Borrower = customer2.Name.ValueGeo,
                    Currency = item.LinkAmount.Ccy,
                    EndDate = loan.Term.End,
                    StartDate = loan.Term.Start,
                    LoanAmount = loan.Amount.Amount,
                    LoanCurrency = loan.Amount.Ccy,
                    LoanInterest = loan.InterestBasis.ToString() + "%",
                    Product = l.GetLoanProduct(loan.ProductId.Value, true).Name,
                    RelationDate = item.LinkDate.Value,
                    Status = item.State == AltasoftAPI.LoansAPI.CollateralLinkState.Closed ? RelationStatus.დახურული : RelationStatus.მიმდინარე,
                };

                relations.Add(r);
            }

            gridRelations.DataSource = relations;
        }
Ejemplo n.º 6
0
        private static string CoverLoan(int loanid, decimal amount)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic | AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts, true, loanid, true);
            var money = amount;
            var priorities = "fee,overdue_interest_penalty,overdue_nu_interest_penalty,overdue_principal_penalty,overdue_interest,overdue_principal_interest,overdue_nu_interest,late_interest,late_nu_interest,interest,nu_interest,overdue_principal,late_principal,principal,writeoff_penalty,writeoff_interest,writeoff_nu_interest,writeoff_principal,undue_principal".Split(',');
            var substractedDebts = new List<Tuple<string, string, decimal>>();
            var loanAmounts = new List<AltasoftAPI.LoansAPI.NameAmountCollectionItem>();
            var user = l.ListUsers(new AltasoftAPI.LoansAPI.ListUsersQuery() { Id = 12, IdSpecified = true });
            string opid;
            var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.IdentityDocuments, true, loan.BorrowerId.Value, true);

            #region Fill Substracted Debts

            foreach (var debt in loan.Debts)
            {
                if (debt.Name.Contains('#'))
                    substractedDebts.Add(new Tuple<string, string, decimal>(debt.Name.Substring(0, debt.Name.IndexOf('#')), debt.Name, debt.Amount));
                else
                    substractedDebts.Add(new Tuple<string, string, decimal>(debt.Name, debt.Name, debt.Amount));
            }
            #endregion

            #region Fill Loan Amounts
            for (int i = 0; i < priorities.Length; i++)
            {
                if (money == 0) break;

                var ddd = substractedDebts.Where(x => x.Item1 == priorities[i]);

                if (priorities[i] == "fee")
                    ddd = substractedDebts.Where(x => x.Item1.Contains(priorities[i]));

                if (ddd.Count() == 0) continue;

                foreach (var r in ddd)
                {
                    if (r.Item3 <= money)
                    {
                        loanAmounts.Add(new AltasoftAPI.LoansAPI.NameAmountCollectionItem()
                        {
                            Name = r.Item2,
                            Amount = r.Item3
                        });

                        money -= r.Item3;
                    }
                    else
                    {
                        loanAmounts.Add(new AltasoftAPI.LoansAPI.NameAmountCollectionItem()
                        {
                            Name = r.Item2,
                            Amount = money
                        });

                        money -= money;
                    }
                }
            }
            #endregion

            var b = l.LoanPayment(new int[1] { 1 },
                new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
                loanAmounts.ToArray(), "jahsdahdkjas",
                loan.Id.Value,
                true,
                new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
                loan.AccountIdentifier,
                loan.AccountIdentifier.HasValue,
                AltasoftAPI.LoansAPI.PaymentType.Payment,
                true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
                false, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
                true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);

            var etag = l.GetLoanOperationDetails(ref opid);

            l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });

            return opid;
        }
Ejemplo n.º 7
0
        private static string CoverLoan2(int loanid, decimal amount)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic | AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts, true, loanid, true);
            //var money = amount;
            //var priorities = "fee,overdue_interest_penalty,overdue_nu_interest_penalty,overdue_principal_penalty,overdue_interest,overdue_principal_interest,overdue_nu_interest,late_interest,late_nu_interest,interest,nu_interest,overdue_principal,late_principal,principal,writeoff_penalty,writeoff_interest,writeoff_nu_interest,writeoff_principal,undue_principal".Split(',');
            //var substractedDebts = new List<Tuple<string, string, decimal>>();
            //var loanAmounts = new List<AltasoftAPI.LoansAPI.NameAmountCollectionItem>();
            var user = l.ListUsers(new AltasoftAPI.LoansAPI.ListUsersQuery() { Id = 12, IdSpecified = true });
            string opid;
            var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.IdentityDocuments, true, loan.BorrowerId.Value, true);
            string b = "";
            string etag = "";

            //#region Fill Substracted Debts

            //foreach (var debt in loan.Debts)
            //{
            //    if (debt.Name.Contains('#'))
            //        substractedDebts.Add(new Tuple<string, string, decimal>(debt.Name.Substring(0, debt.Name.IndexOf('#')), debt.Name, debt.Amount));
            //    else
            //        substractedDebts.Add(new Tuple<string, string, decimal>(debt.Name, debt.Name, debt.Amount));
            //}
            //#endregion

            //#region Fill Loan Amounts
            //for (int i = 0; i < priorities.Length; i++)
            //{
            //    if (money == 0) break;

            //    var ddd = substractedDebts.Where(x => x.Item1 == priorities[i]);

            //    if (priorities[i] == "fee")
            //        ddd = substractedDebts.Where(x => x.Item1.Contains(priorities[i]));

            //    if (ddd.Count() == 0) continue;

            //    foreach (var r in ddd)
            //    {
            //        if (r.Item3 <= money)
            //        {
            //            loanAmounts.Add(new AltasoftAPI.LoansAPI.NameAmountCollectionItem()
            //            {
            //                Name = r.Item2,
            //                Amount = r.Item3
            //            });

            //            money -= r.Item3;
            //        }
            //        else
            //        {
            //            loanAmounts.Add(new AltasoftAPI.LoansAPI.NameAmountCollectionItem()
            //            {
            //                Name = r.Item2,
            //                Amount = money
            //            });

            //            money -= money;
            //        }
            //    }
            //}
            //#endregion

            var first = loan.Debts.Except(loan.Debts.Where(x => x.Name.Contains("undue_principal"))).Sum(x => x.Amount);
            var second = loan.Debts.Sum(x => x.Amount);
            var third = loan.Debts.Sum(x => x.Amount) <= amount;

            if (loan.Debts.Except(loan.Debts.Where(x => x.Name.Contains("undue_principal"))).Sum(x => x.Amount) >= amount)
            {
                b = l.LoanPayment(new int[0],
                        new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
                        new AltasoftAPI.LoansAPI.NameAmountCollectionItem[1] { new AltasoftAPI.LoansAPI.NameAmountCollectionItem() { Name = "payment", Amount = amount } }, "დავალიანების დაფარვა",
                        loan.Id.Value,
                        true,
                        new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
                        loan.AccountIdentifier,
                        loan.AccountIdentifier.HasValue,
                        AltasoftAPI.LoansAPI.PaymentType.Payment,
                        false, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
                        true, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
                        true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
                etag = l.GetLoanOperationDetails(ref opid);
                l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
                return opid;
            }
            else if (loan.Debts.Sum(x => x.Amount) > amount)
            {
                b = l.LoanPayment(new int[0],
                       new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
                       new AltasoftAPI.LoansAPI.NameAmountCollectionItem[1] { new AltasoftAPI.LoansAPI.NameAmountCollectionItem() { Name = "payment", Amount = amount } }, "დავალიანების დაფარვა",
                       loan.Id.Value,
                       true,
                       new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
                       loan.AccountIdentifier,
                       loan.AccountIdentifier.HasValue,
                       AltasoftAPI.LoansAPI.PaymentType.Prepayment,
                       true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
                       true, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
                       true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
                etag = l.GetLoanOperationDetails(ref opid);
                l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
                return opid;
            }
            else if (loan.Debts.Sum(x => x.Amount) <= amount)
            {
                b = l.LoanPayment(new int[0],
                       new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
                       new AltasoftAPI.LoansAPI.NameAmountCollectionItem[1] { new AltasoftAPI.LoansAPI.NameAmountCollectionItem() { Name = "payment", Amount = loan.Debts.Sum(x => x.Amount) } }, "დავალიანების დაფარვა",
                       loan.Id.Value,
                       true,
                       new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
                       loan.AccountIdentifier,
                       loan.AccountIdentifier.HasValue,
                       AltasoftAPI.LoansAPI.PaymentType.PrepaymentAndClose,
                       true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
                       false, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
                       true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
                etag = l.GetLoanOperationDetails(ref opid);
                l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
                return opid;
            }

            //if (loan.Debts.Sum(x => x.Amount) <= amount)
            //{
            //    b = l.LoanPayment(new int[0],
            //            new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
            //            new AltasoftAPI.LoansAPI.NameAmountCollectionItem[1] { new AltasoftAPI.LoansAPI.NameAmountCollectionItem() { Name = "payment", Amount = amount } }, "დავალიანების დაფარვა",
            //            loan.Id.Value,
            //            true,
            //            new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
            //            loan.AccountIdentifier,
            //            loan.AccountIdentifier.HasValue,
            //            AltasoftAPI.LoansAPI.PaymentType.PrepaymentAndClose,
            //            true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
            //            false, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
            //            true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
            //    etag = l.GetLoanOperationDetails(ref opid);
            //    l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
            //    return opid;
            //}
            //else if (loan.Debts.Where(x => x.Name.Contains("undue_principal")).Count() > 0)
            //{
            //    if (loan.Debts.FirstOrDefault(x => x.Name.Contains("undue_principal")).Amount == 0)
            //    {
            //        throw new Exception("In loanAmounts undue_principal is 0");
            //    }
            //    if (loan.Debts.Where(x => x.Name.Contains("undue_principal")).Sum(x => x.Amount) > 0)
            //    {
            //        b = l.LoanPayment(new int[1] { 1 },
            //                new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
            //                loanAmounts.ToArray(), "დავალიანების დაფარვა",
            //                loan.Id.Value,
            //                true,
            //                new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
            //                loan.AccountIdentifier,
            //                loan.AccountIdentifier.HasValue,
            //                AltasoftAPI.LoansAPI.PaymentType.Prepayment,
            //                true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
            //                false, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
            //                true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
            //        etag = l.GetLoanOperationDetails(ref opid);
            //        l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
            //        return opid;
            //    }
            //}
            //else
            //{
            //    b = l.LoanPayment(new int[1] { 1 },
            //            new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = 1, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = 12, IdSpecified = true, Name = "ნინო საჩალელი" } },
            //            loanAmounts.ToArray(), "დავალიანების დაფარვა",
            //            loan.Id.Value,
            //            true,
            //            new AltasoftAPI.LoansAPI.PayerDetails { Client = customer.Name.ValueGeo },
            //            loan.AccountIdentifier,
            //            loan.AccountIdentifier.HasValue,
            //            AltasoftAPI.LoansAPI.PaymentType.Payment,
            //            true, AltasoftAPI.LoansAPI.PrepaymentRescheduleStrategy.ByPMT,
            //            false, AltasoftAPI.LoansAPI.PaymentSource.ClientResource,
            //            true, true, true, loan.Version.Value, loan.VersionSpecified, out opid);
            //    etag = l.GetLoanOperationDetails(ref opid);
            //    l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
            //    return opid;
            //}

            throw new Exception("Loan not covered. LoanID: " + loan.Id);
            //l.ExecuteOperationAction(AltasoftAPI.LoansAPI.LoanOperationAction.IncrementAuthorization, true, "ავტორიზაცია", ref etag, ref opid, new AltasoftAPI.LoansAPI.UserAndDeptId() { DeptId = user.FirstOrDefault().DeptId, DeptIdSpecified = true, UserIdentification = new AltasoftAPI.LoansAPI.UserIdentification() { Id = user.FirstOrDefault().Id, IdSpecified = true, Name = user.FirstOrDefault().DisplayName } });
        }
Ejemplo n.º 8
0
        public static List<LoanDebts> ListLoanDebts(int[] loanIds)
        {
            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            var result = new List<LoanDebts>();

            foreach (var i in loanIds)
            {
                var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic | AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts, true, i, true);

                if (loan.Debts == null)
                    continue;

                var enf = new LoanDebts() { LoanID = i };

                ///////////////////////////////////////////
                enf.Principal = loan.Debts.Where(x => x.Name.Contains("overdue_principal#")).Sum(x => x.Amount)                                         //OverduePrincipalInGel
                                  + loan.Debts.Where(x => x.Name == ("undue_principal")).Sum(x => x.Amount)                                                 //PrincipalInGel
                                  + loan.Debts.Where(x => x.Name == ("principal")).Sum(x => x.Amount)                                                       //CurrentPrincipalInGel
                                  + loan.Debts.Where(x => x.Name.ToLower().Contains("late") && x.Name.ToLower().Contains("principal")).Sum(x => x.Amount);  //LatePrincipalInGel

                enf.Interest = loan.Debts.Where(x => x.Name.Contains("overdue_interest#") || x.Name.Contains("overdue_principal_interest")).Sum(x => x.Amount) //OverdueInterestInGel
                                 + loan.Debts.Where(x => x.Name == ("interest")).Sum(x => x.Amount);                                                               //AccruedInterestInGel

                enf.Penalty = loan.Debts.Where(x => x.Name.Contains("overdue_interest_penalty")).Sum(x => x.Amount)          //InterestPenaltyInGel
                                + loan.Debts.Where(x => x.Name.Contains("overdue_principal_penalty")).Sum(x => x.Amount);        //PrincipalPenaltyInGel
                enf.Other = loan.Debts.Sum(x => x.Amount) - (enf.Principal + enf.Interest + enf.Penalty);
                ///////////////////////////////////////////

                result.Add(enf);
            }

            return result;
        }
Ejemplo n.º 9
0
        /////////////////////////////////////////////////
        public static List<EnforcementLoan> ListEnForcementLoans(User problemManager, params int[] localIds)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var loansIds = (from x in l.ListLoans
                            (new AltasoftAPI.LoansAPI.ListLoansQuery()
                                {
                                    ControlFlags = AltasoftAPI.LoansAPI.LoanControlFlags.Basic,
                                    Status = new AltasoftAPI.LoansAPI.LoanStatus[] { AltasoftAPI.LoansAPI.LoanStatus.Overdue, AltasoftAPI.LoansAPI.LoanStatus.Current }
                                }) select x.Id.Value).Except(localIds).ToArray();

            var list1 = new List<EnforcementLoan>();

            foreach (var i in loansIds)
            {
                var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic | AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts, true, i, true);

                if (loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.ProblemManager && x.UserId.Value == problemManager.AltasoftUserID) == null)
                    continue;

                var cus1 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses | AltasoftAPI.CustomersAPI.CustomerControlFlags.ContactPersons | AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, loan.BorrowerId.Value, true);

                /////////////////////////////////
                AltasoftAPI.LoansAPI.Application app;
                bool? n;
                bool n2;

                l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.Basic | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extensions, true, i, true, out n, out n2, out app);

                var collaterals = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
                {
                    ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                    ApplicationId = app.Id.Value,
                    ApplicationIdSpecified = app.IdSpecified
                });

                /////////////////////////////////

                var enf = new EnforcementLoan();

                enf.LoanID = loan.Id.Value;
                enf.AgreementAndSummaryJudgementTerms = new AgreementAndSummaryJudgementTerms() { End = DateTime.Now, Start = DateTime.Now, PaymentDay = 0 };
                try
                {
                    enf.BorrowerAddress = cus1.AddressActual != null ? cus1.AddressActual.Value.ValueGeo : "";
                }
                catch { }
                enf.BorrowerName = cus1.Name != null ? cus1.Name.ValueGeo : "";
                enf.BorrowerPhone = cus1.ContactInfo != null ? cus1.ContactInfo.MobilePhone : "";
                enf.CreditExpert = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.Operator).Name;
                enf.LoanAgreementNumber = loan.AgreementNo;
                enf.Status = EnforcementLoanStatus.Active;
                enf.GivePLD = DateTime.Now;
                enf.ProblemManagerName = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.ProblemManager).Name;
                enf.ProblemManagerID = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.ProblemManager).UserId.Value;
                enf.BorrowerPrivateNumber = (cus1.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN;

                enf.CaseStatus = EnforcementCaseStatus.NewCase;

                ///////////////////////////////////////////
                enf.LoanPrincipal = loan.Debts.Where(x => x.Name.Contains("overdue_principal#")).Sum(x => x.Amount)                                         //OverduePrincipalInGel
                                  + loan.Debts.Where(x => x.Name == ("undue_principal")).Sum(x => x.Amount)                                                 //PrincipalInGel
                                  + loan.Debts.Where(x => x.Name == ("principal")).Sum(x => x.Amount)                                                       //CurrentPrincipalInGel
                                  + loan.Debts.Where(x => x.Name.ToLower().Contains("late") && x.Name.ToLower().Contains("principal")).Sum(x => x.Amount);  //LatePrincipalInGel

                enf.LoanInterest = loan.Debts.Where(x => x.Name.Contains("overdue_interest#") || x.Name.Contains("overdue_principal_interest")).Sum(x => x.Amount) //OverdueInterestInGel
                                 + loan.Debts.Where(x => x.Name == ("interest")).Sum(x => x.Amount);                                                               //AccruedInterestInGel

                enf.LoanPenalty = loan.Debts.Where(x => x.Name.Contains("overdue_interest_penalty")).Sum(x => x.Amount)          //InterestPenaltyInGel
                                + loan.Debts.Where(x => x.Name.Contains("overdue_principal_penalty")).Sum(x => x.Amount);        //PrincipalPenaltyInGel
                enf.TotalLoanDebt = loan.Debts.Sum(x => x.Amount);
                ///////////////////////////////////////////

                enf.ApplicationSubmitDate = DateTime.Now;
                enf.LoanStartDate = loan.Term.Start;

                if (collaterals.Count() > 0)
                {
                    var coll = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
                    {
                        Id = collaterals.FirstOrDefault().CollateralId,
                        IdSpecified = collaterals.FirstOrDefault().CollateralIdSpecified,
                        ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes
                    });

                    var col1 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, coll[0].OwnerId.Value, true);
                }

                if (loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.ProblemManager) != null)
                    list1.Add(enf);
            }

            return list1;
        }
Ejemplo n.º 10
0
        public static DailyPaymentAndLoan GetLoanAndDailyModel(int loanId)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            var result = new DailyPaymentAndLoan();
            var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts | AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, loanId, true);

            var bbbb = from x in loan.Debts
                       select x.Name;

            #region Create Item
            var pm = loan.Authorities.LastOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.ProblemManager);

            var item = new DailyPayment()
            {
                LoanID = loanId,
                CurrentDebtInGel = loan.Debts.Where(x => !x.Name.Contains("undue_principal")).Sum(x => x.Amount),
                TotalDebtInGel = loan.Debts.Sum(x => x.Amount),
                InterestPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest_penalty")).Sum(x => x.Amount),
                PrincipalPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal_penalty")).Sum(x => x.Amount),
                OverdueInterestInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest#") || x.Name.Contains("overdue_principal_interest")).Sum(x => x.Amount),
                AccruedInterestInGel = loan.Debts.Where(x => x.Name == ("interest")).Sum(x => x.Amount),
                OverduePrincipalInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal#")).Sum(x => x.Amount),
                PrincipalInGel = loan.Debts.Where(x => x.Name == ("undue_principal")).Sum(x => x.Amount),
                CurrentPrincipalInGel = loan.Debts.Where(x => x.Name == ("principal")).Sum(x => x.Amount),
                LatePrincipalInGel = loan.Debts.Where(x => x.Name.ToLower().Contains("late") && x.Name.ToLower().Contains("principal")).Sum(x => x.Amount),
                ProblemManager = pm != null ? pm.Name : ""
            };

            result.OperatorID = loan.Authorities.LastOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.PrimaryResponsible).UserId.Value;
            item.ResponsibleUser = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.PrimaryResponsible).Name;

            loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, loanId, true);

            item.DeptID = loan.BranchId.Value;
            item.CalculationDate = loan.CalcDate.Value.Date;
            item.LoanAmountInGel = loan.Amount.Amount;
            item.LoanCCY = loan.Amount.Ccy;
            item.ClientNo = loan.BorrowerId.Value;
            item.AgreementNumber = loan.AgreementNo;
            item.StartDate = loan.Term.Start.ToShortDateString();
            item.EndDate = loan.Term.End.ToShortDateString();

            result.ClientID = loan.BorrowerId.Value;
            result.DeptID = loan.BranchId.Value;

            var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, loan.BorrowerId.Value, true);
            AltasoftAPI.CustomersAPI.Customer customer2;
            var account = a.GetAccount(AltasoftAPI.AccountsAPI.AccountControlFlags.Basic, true, new AltasoftAPI.AccountsAPI.InternalAccountIdentification() { Id = loan.AccountIdentifier, IdSpecified = true }, item.LoanCCY);

            customer2 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, loan.BorrowerId.Value, true);
            if (customer2.ContactInfo != null)
                item.Phone = customer2.ContactInfo.MobilePhone;

            item.ClientAccountDescrip = account.DisplayName.ValueGeo;
            item.ClientName = customer.Name.ValueGeo;//

            item.FirstName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.FirstName.ValueGeo;
            item.LastName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.LastName.ValueGeo;
            item.PersonalID = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN;

            item.ClientAccountBranchCode = customer.BranchId.Value.ToString();
            item.ClientAccountIban = account.IBAN;

            AltasoftAPI.CustomersAPI.Customer customer3;

            customer3 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, loan.BorrowerId.Value, true);
            if (customer3.AddressActual != null && customer3.AddressActual.Value != null)
            {
                item.ClientAddressFact = customer3.AddressActual.Value.ValueGeo;
            }

            item.NextScheduledPaymentInGel = l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today) != null ?
                l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today).Elements.Where(x => x.Name != "balance").Sum(x => x.Amount) : 0;

            AltasoftAPI.LoansAPI.Application app;
            bool? notm;
            bool notms;
            l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.ExtraFields, true, loan.Id.Value, true, out notm, out notms, out app);

            if (app.Businesses != null)
                item.BusinessAddress = app.Businesses.FirstOrDefault().Address;

            result.DailyPayment = item;
            #endregion

            return result;
        }
Ejemplo n.º 11
0
        /////////////////////////////////////////////////
        public static List<DailyPayment> GetDailyByUserTest(int altasoftUserId)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            List<DailyPayment> list = new List<DailyPayment>();
            List<DailyPaymentAndLoan> data = new List<DailyPaymentAndLoan>();

            var loanss = l.ListLoans(new AltasoftAPI.LoansAPI.ListLoansQuery() { ControlFlags = AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts | AltasoftAPI.LoansAPI.LoanControlFlags.Basic, Status = new AltasoftAPI.LoansAPI.LoanStatus[] { AltasoftAPI.LoansAPI.LoanStatus.Overdue, AltasoftAPI.LoansAPI.LoanStatus.Current, AltasoftAPI.LoansAPI.LoanStatus.Late } });

            foreach (var loan in loanss)
            {
                var result = new DailyPaymentAndLoan();

                #region Create Item
                var item = new DailyPayment()
                {
                    LoanID = loan.Id.Value,
                    CurrentDebtInGel = loan.Debts.Where(x => !x.Name.Contains("undue_principal")).Sum(x => x.Amount),
                    TotalDebtInGel = loan.Debts.Sum(x => x.Amount),
                    InterestPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest_penalty")).Sum(x => x.Amount),
                    PrincipalPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal_penalty")).Sum(x => x.Amount),
                    OverdueInterestInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest#") || x.Name.Contains("overdue_principal_interest")).Sum(x => x.Amount),
                    AccruedInterestInGel = loan.Debts.Where(x => x.Name == ("interest")).Sum(x => x.Amount),
                    OverduePrincipalInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal#")).Sum(x => x.Amount),
                    PrincipalInGel = loan.Debts.Where(x => x.Name == ("undue_principal")).Sum(x => x.Amount),
                    CurrentPrincipalInGel = loan.Debts.Where(x => x.Name == ("principal")).Sum(x => x.Amount)
                };

                result.OperatorID = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.Operator).UserId.Value;
                item.ResponsibleUser = loan.Authorities.FirstOrDefault(x => x.Role == AltasoftAPI.LoansAPI.AuthorityRole.PrimaryResponsible).Name;

                item.DeptID = loan.BranchId.Value;
                item.CalculationDate = loan.CalcDate.Value.Date;
                item.LoanAmountInGel = loan.Amount.Amount;
                item.LoanCCY = loan.Amount.Ccy;
                item.ClientNo = loan.BorrowerId.Value;
                item.AgreementNumber = loan.AgreementNo;
                item.StartDate = loan.Term.Start.ToShortDateString();
                item.EndDate = loan.Term.End.ToShortDateString();

                result.ClientID = loan.BorrowerId.Value;
                result.DeptID = loan.BranchId.Value;

                var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, loan.BorrowerId.Value, true);
                AltasoftAPI.CustomersAPI.Customer customer2;
                var account = a.GetAccount(AltasoftAPI.AccountsAPI.AccountControlFlags.Basic, true, new AltasoftAPI.AccountsAPI.InternalAccountIdentification() { Id = loan.AccountIdentifier, IdSpecified = true }, item.LoanCCY);

                customer2 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, loan.BorrowerId.Value, true);
                item.Phone = customer2.ContactInfo.MobilePhone;
                item.ClientAccountDescrip = account.DisplayName.ValueGeo;
                item.ClientName = customer.Name.ValueGeo;
                item.FirstName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.FirstName.ValueGeo;
                item.LastName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.LastName.ValueGeo;
                item.PersonalID = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN;
                item.ClientAccountBranchCode = customer.BranchId.Value.ToString();
                item.ClientAccountIban = account.IBAN;

                AltasoftAPI.CustomersAPI.Customer customer3;

                customer3 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, loan.BorrowerId.Value, true);
                if (customer3.AddressActual != null)
                {
                    item.ClientAddressFact = customer3.AddressActual.Value.ValueGeo;
                }

                item.NextScheduledPaymentInGel = l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today) != null ?
                    l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today).Elements.Where(x => x.Name != "balance").Sum(x => x.Amount) : 0;

                AltasoftAPI.LoansAPI.Application app;
                bool? notm;
                bool notms;
                l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.ExtraFields, true, loan.Id.Value, true, out notm, out notms, out app);

                item.BusinessAddress = app.Businesses.FirstOrDefault().Address;

                result.DailyPayment = item;
                data.Add(result);
                #endregion
            }

            using (var db = new AltasoftDailyContext())
            {
                var user = db.Users.FirstOrDefault(x => x.AltasoftUserID == altasoftUserId);

                try
                {
                    if (user.Filter.IsDeptFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.DeptID == x.DeptID)).ToList();

                    if (user.Filter.IsCustomerFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.ClientID == x.ClientID)).ToList();

                    if (user.Filter.IsOperatorFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.OperatorID == x.OperatorID)).ToList();
                }
                catch (NullReferenceException)
                {
                    return new List<DailyPayment>();
                }

                if (data != null)
                    data.ForEach(x => { if (x != null) list.Add(x.DailyPayment); });
            }
            return list.OrderBy(x => x.LoanID).ToList();
        }
Ejemplo n.º 12
0
        public static List<DailyPayment> GetDailyByUser(int altasoftUserId)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            List<DailyPayment> list = new List<DailyPayment>();
            List<DailyPaymentAndLoan> data = new List<DailyPaymentAndLoan>();

            var loansIds = (from x in l.ListLoans(new AltasoftAPI.LoansAPI.ListLoansQuery() { ControlFlags = AltasoftAPI.LoansAPI.LoanControlFlags.Basic, Status = new AltasoftAPI.LoansAPI.LoanStatus[] { AltasoftAPI.LoansAPI.LoanStatus.Overdue, AltasoftAPI.LoansAPI.LoanStatus.Current, AltasoftAPI.LoansAPI.LoanStatus.Late } })
                            select x.Id.Value).ToList().OrderBy(x => x);

            using (var db = new AltasoftDailyContext())
            {
                var user = db.Users.FirstOrDefault(x => x.AltasoftUserID == altasoftUserId);

                loansIds.Where(x => x != 2331 /*&& x != 6*/).ToList().ForEach(x => data.Add(GetLoanAndDailyModel(x)));

                try
                {
                    if (user.Filter.IsDeptFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.DeptID == x.DeptID)).ToList();

                    if (user.Filter.IsCustomerFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.ClientID == x.ClientID)).ToList();

                    if (user.Filter.IsOperatorFilterEnabled && data != null)
                        data = data.Where(x => x != null && user.Filter.FilterData.Any(y => y.OperatorID == x.OperatorID)).ToList();
                }
                catch (NullReferenceException)
                {
                    return new List<DailyPayment>();
                }

                if (data != null)
                    data.ForEach(x => { if (x != null) list.Add(x.DailyPayment); });
            }
            return list.OrderBy(x => x.LoanID).ToList();
        }
Ejemplo n.º 13
0
        public static List<DailyPayment> GetDailyByDeptId(int deptId)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            List<DailyPayment> list = new List<DailyPayment>();

            var loansIds = (from x in l.ListLoans(new AltasoftAPI.LoansAPI.ListLoansQuery() { ControlFlags = AltasoftAPI.LoansAPI.LoanControlFlags.Basic, Status = new AltasoftAPI.LoansAPI.LoanStatus[] { AltasoftAPI.LoansAPI.LoanStatus.Overdue, AltasoftAPI.LoansAPI.LoanStatus.Current, AltasoftAPI.LoansAPI.LoanStatus.Late } })
                            select x.Id.Value).ToList().OrderBy(x => x);

            foreach (var loanId in loansIds)
            {
                var loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Authorities | AltasoftAPI.LoansAPI.LoanControlFlags.Debts | AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, loanId, true);

                if (loan.BranchId == deptId)
                {
                    var item = new DailyPayment()
                    {
                        LoanID = loanId,
                        CurrentDebtInGel = loan.Debts.Where(x => !x.Name.Contains("undue_principal")).Sum(x => x.Amount),
                        TotalDebtInGel = loan.Debts.Sum(x => x.Amount),
                        InterestPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest_penalty")).Sum(x => x.Amount),
                        PrincipalPenaltyInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal_penalty")).Sum(x => x.Amount),
                        OverdueInterestInGel = loan.Debts.Where(x => x.Name.Contains("overdue_interest#") || x.Name.Contains("overdue_principal_interest")).Sum(x => x.Amount),
                        AccruedInterestInGel = loan.Debts.Where(x => x.Name == ("interest")).Sum(x => x.Amount),
                        OverduePrincipalInGel = loan.Debts.Where(x => x.Name.Contains("overdue_principal#")).Sum(x => x.Amount),
                        PrincipalInGel = loan.Debts.Where(x => x.Name == ("undue_principal")).Sum(x => x.Amount),
                        CurrentPrincipalInGel = loan.Debts.Where(x => x.Name == ("principal")).Sum(x => x.Amount)
                    };

                    loan = l.GetLoan(AltasoftAPI.LoansAPI.LoanControlFlags.Basic, true, loanId, true);

                    item.CalculationDate = loan.CalcDate.Value.Date;
                    item.LoanAmountInGel = loan.Amount.Amount;
                    item.LoanCCY = loan.Amount.Ccy;
                    item.ClientNo = loan.BorrowerId.Value;
                    item.AgreementNumber = loan.AgreementNo;
                    item.StartDate = loan.Term.Start.ToShortDateString();
                    item.EndDate = loan.Term.End.ToShortDateString();

                    var customer = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, loan.BorrowerId.Value, true);
                    AltasoftAPI.CustomersAPI.Customer customer2;
                    var account = a.GetAccount(AltasoftAPI.AccountsAPI.AccountControlFlags.Basic, true, new AltasoftAPI.AccountsAPI.InternalAccountIdentification() { Id = loan.AccountIdentifier, IdSpecified = true }, item.LoanCCY);

                    customer2 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Extensions, true, loan.BorrowerId.Value, true);
                    item.Phone = customer2.ContactInfo.MobilePhone;
                    item.ClientAccountDescrip = account.DisplayName.ValueGeo;
                    item.ClientName = customer.Name.ValueGeo;
                    item.FirstName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.FirstName.ValueGeo;
                    item.LastName = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).Name.LastName.ValueGeo;
                    item.PersonalID = (customer.Entity as AltasoftAPI.CustomersAPI.IndividualEntity).PIN;
                    item.ClientAccountBranchCode = customer.BranchId.Value.ToString();
                    item.ClientAccountIban = account.IBAN;

                    AltasoftAPI.CustomersAPI.Customer customer3;

                    customer3 = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, loan.BorrowerId.Value, true);
                    item.ClientAddressFact = customer3.AddressActual.Value.ValueGeo;

                    item.NextScheduledPaymentInGel = l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today) != null ?
                        l.GetLoanSchedule(AltasoftAPI.LoansAPI.DebtComponentDetalization.Detailed, true, AltasoftAPI.LoansAPI.GetLoanScheduleControlFlags.Full, true, item.LoanID, true).FirstOrDefault(x => x.Date == DateTime.Today).Elements.Where(x => x.Name != "balance").Sum(x => x.Amount) : 0;

                    AltasoftAPI.LoansAPI.Application app;
                    bool? notm;
                    bool notms;
                    l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.ExtraFields, true, loan.Id.Value, true, out notm, out notms, out app);

                    item.BusinessAddress = app.Businesses.FirstOrDefault().Address;

                    list.Add(item);
                }
            }

            //list.AddRange(GetDailyByDeptId() as IEnumerable<DailyPayment>);

            return list.OrderBy(x => x.ClientNo).ToList();
        }
Ejemplo n.º 14
0
        public static int GetCollateralIdByLoanId(int loanId)
        {
            #region Initialize Services
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region AccountsService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion
            #endregion

            AltasoftAPI.LoansAPI.Application app;
            bool? n;
            bool n2;

            l.GetApplication(AltasoftAPI.LoansAPI.ApplicationControlFlags.Basic | AltasoftAPI.LoansAPI.ApplicationControlFlags.Extensions, true, loanId, true, out n, out n2, out app);

            var collaterals = l.ListLinkedCollaterals(new AltasoftAPI.LoansAPI.ListLinkedCollateralsQuery()
                {
                    ControlFlags = AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Basic | AltasoftAPI.LoansAPI.LinkedCollateralControlFlags.Attributes,
                    ApplicationId = app.Id.Value,
                    ApplicationIdSpecified = app.IdSpecified
                });

            //var collateral = l.ListCollaterals(new AltasoftAPI.LoansAPI.ListCollateralsQuery()
            //    {
            //        ControlFlags = AltasoftAPI.LoansAPI.CollateralControlFlags.Basic | AltasoftAPI.LoansAPI.CollateralControlFlags.Attributes,
            //        AccountId = loan.AccountIdentifier,
            //        AccountIdSpecified = loan.AccountIdentifierSpecified,
            //        CollateralType = "03"
            //    });

            return collaterals.FirstOrDefault().CollateralId.Value;
        }
Ejemplo n.º 15
0
        public static long? SubmitOrder(int docNum, string ccy, DateTime date, string accountIBAN, decimal amount, string agreementNumber, string cashDeskSymbol, int userId, int deptId)
        {
            #region OrdersService
            AltasoftAPI.OrdersAPI.OrdersService o = new AltasoftAPI.OrdersAPI.OrdersService();
            o.RequestHeadersValue = new AltasoftAPI.OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.CustomersAPI.CustomersService c = new AltasoftAPI.CustomersAPI.CustomersService();
            c.RequestHeadersValue = new AltasoftAPI.CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region CustomersService
            AltasoftAPI.AccountsAPI.AccountsService a = new AltasoftAPI.AccountsAPI.AccountsService();
            a.RequestHeadersValue = new AltasoftAPI.AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            #region LoansService
            AltasoftAPI.LoansAPI.LoansService l = new AltasoftAPI.LoansAPI.LoansService();
            l.RequestHeadersValue = new AltasoftAPI.LoansAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = Guid.NewGuid().ToString() };
            #endregion

            var acc = a.GetAccount(AltasoftAPI.AccountsAPI.AccountControlFlags.Basic, true, new AltasoftAPI.AccountsAPI.InternalAccountIdentification() { IBAN = accountIBAN }, ccy);
            var cus = c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic | AltasoftAPI.CustomersAPI.CustomerControlFlags.Addresses, true, acc.CustomerId.Value, true);
            var cusEntity = cus.Entity as AltasoftAPI.CustomersAPI.IndividualEntity;

            #region Variables
            long id;
            bool specified;
            #endregion

            #region Order Init
            var Order = new AltasoftAPI.OrdersAPI.CashOrderData
            {
                Amount = new AltasoftAPI.OrdersAPI.AmountAndCurrency { Amount = amount, Ccy = ccy },
                Date = date,
                Status = AltasoftAPI.OrdersAPI.TransactionStatus.Green,
                StatusSpecified = true,
                TransactionCode = "qwe34242342", //09
                OpCode = "09",
                Purpose = "სესხის დაფარვა სესხის ხელშ. " + agreementNumber + "-ის საფუძველზე",
                //ExtraAccount = 0,
                //ExtraAccountSpecified = false,
                CustomerAccount = new AltasoftAPI.OrdersAPI.InternalAccountIdentification { IBAN = accountIBAN },
                OrderDate = date,
                OrderDateSpecified = true,
                Type = AltasoftAPI.OrdersAPI.CashOrderType.Deposit,
                Customer = new AltasoftAPI.OrdersAPI.CustomerData { Name = (AltasoftAPI.OrdersAPI.PersonName)cusEntity.Name },
                //DeptId = 5,
                //DeptIdSpecified = true,
                DocNum = docNum,
                DocNumSpecified = docNum == 0 ? false : true
            };

            cusEntity = (c.GetCustomer(AltasoftAPI.CustomersAPI.CustomerControlFlags.IdentityDocuments | AltasoftAPI.CustomersAPI.CustomerControlFlags.Basic, true, acc.CustomerId.Value, true).Entity as AltasoftAPI.CustomersAPI.IndividualEntity);

            Order.Customer.IdentityDocument = (AltasoftAPI.OrdersAPI.IdentityDocument)cusEntity.IdentityDocuments.FirstOrDefault();
            try
            {
                Order.Customer.Address = (AltasoftAPI.OrdersAPI.TextBilingual)cus.AddressActual.Value;
                Order.Customer.BirthPlaceDateAndCountry = (AltasoftAPI.OrdersAPI.BirthPlaceDateAndCountry)cusEntity.BirthPlaceDateAndCountry;

            }
            catch
            {
            }
            #endregion

            #region Put Order
            o.PutOrder(new AltasoftAPI.OrdersAPI.UserAndDeptId()
                        {
                            DeptId = deptId,
                            DeptIdSpecified = true,
                            UserIdentification = new AltasoftAPI.OrdersAPI.UserIdentification() { Id = userId, IdSpecified = true }
                        }, 0, false,
                               new Guid().ToString(),
                               true, true, false, true, Order, out id, out specified);
            #endregion

            return id;
        }