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.);
        }
        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.º 3
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

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

            var loans = new HashSet<Loan>(l.ListLoans(new ListLoansQuery()
            {
                ControlFlags = LoanControlFlags.Basic | LoanControlFlags.Authorities | LoanControlFlags.Debts,
                Status = new LoanStatus[]
                {
                    LoanStatus.Overdue,
                    LoanStatus.Current,
                    LoanStatus.Late
                }
            }));

            foreach (var loan in loans)
            {
                var customer = c.GetCustomer( CustomerControlFlags.Basic,
                                              true,
                                              loan.BorrowerId.Value,
                                              true );

            }

            return;

            (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).Where(x => x != 2331 /*&& x != 6*/).ToList().ForEach(x =>

             data.Add(DailyManagement.GetLoanAndDailyModel(x)));

            using (var db = new AltasoftDailyContext())
            {
                foreach (var p in data)
                {

                }
            }
        }
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 } });
        }