public void Given_MorningDateTime_GenerateDeal_Returns_AmRate()
        {
            // Arrange
            var sut         = new DealService();
            var morningTime = new DateTime(2020, 10, 10, 10, 10, 10);
            var amRate      = DealService.AmRate;

            // Act
            var generatedDealRate = sut.GenerateDeal(morningTime);

            // Assert
            generatedDealRate.Should().Be(amRate);
        }
Ejemplo n.º 2
0
        public async Task LoadDeals()
        {
            ViewModelArgs = new DealReportArgs();
            DataRequest <Data.Deal> request = BuildDataRequest();
            IList <DealModel>       result  = await DealService.GetDealsAsync(request);

            ReportItems = new List <DealModel>();
            foreach (var obj in result)
            {
                ReportItems.Add(obj);
            }
            // ReportItems = result.ToList();
        }
Ejemplo n.º 3
0
        public void GetDeals_UserIsAdmin_ThrowMethodAccessException()
        {
            // Arrange
            User user = new Admin(1, "test", 1);

            SecurityContext.SetUser(user);
            var          mockUnitOfWork = new Mock <IUnitOfWork>();
            IDealService dealService    = new DealService(mockUnitOfWork.Object);

            // Act
            // Assert
            Assert.Throws <MethodAccessException>(() => dealService.GetDeal(0));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Index()
        {
            try
            {
                LiveIdAuthResult    liveIdAuthResult = HttpContext.Items["liveauthstate"] as LiveIdAuthResult;
                AuthorizeUserResult userResult       = await AuthorizeUser(liveIdAuthResult);

                if (!userResult.Authorized)
                {
                    return(userResult.Result);
                }

                if (liveIdAuthResult != null)
                {
                    ViewBag.ProfileName     = liveIdAuthResult.ProfileName;
                    ViewBag.SignOutHtmlLink = liveIdAuthResult.SignOutHtmlLink;
                }

                string state = (HttpContext.Items["state"] as string) ?? "wa";
                Task <List <Deal> > dealTask   = DealService.GetDeals(state);
                UserModel           userModel  = new UserModel(User.Identity as ClaimsIdentity);
                string        secureToken      = HttpContext.Items["backendtoken"] as string;
                Task <string> earnedAmountTask = CommerceService.GetTotalEarnedAmount(userModel, secureToken);
                string        earnedAmount     = await earnedAmountTask;
                List <Deal>   deals            = await dealTask;
                List <Deal>   topDeals         = DealService.GetTopDeals(state);

                if (deals != null)
                {
                    AccountsPageModel model = new AccountsPageModel
                    {
                        LocalDeals = deals,
                        TopDeals   = topDeals,
                        EarnTotal  = earnedAmount,
                        UserId     = userModel.UserId,
                        Page       = "places to earn"
                    };

                    return(View("~/offers/earn/views/account/places.cshtml", model));
                }
            }
            catch (Exception e)
            {
            }

            return(HandleServerError());
        }
Ejemplo n.º 5
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var juridicalPerson1   = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 1
            };

            accountOrganization = new AccountOrganization("Тестовая собственная организация", "Тестовая собственная организация", juridicalPerson1)
            {
                Id = 1
            };

            var juridicalPerson2 = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 2
            };

            clientOrganization = new ClientOrganization("Тестовая организация клиента", "Тестовая организация клиента", juridicalPerson2)
            {
                Id = 2
            };

            clientContractRepository = Mock.Get(IoCContainer.Resolve <IClientContractRepository>());
            dealRepository           = Mock.Get(IoCContainer.Resolve <IDealRepository>());

            dealIndicatorService = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());
            expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>());
            storageService = Mock.Get(IoCContainer.Resolve <IStorageService>());
            clientContractIndicatorService = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            taskRepository = Mock.Get(IoCContainer.Resolve <ITaskRepository>());

            dealServiceMock = new Mock <DealService>(dealRepository.Object, clientContractRepository.Object, taskRepository.Object, dealIndicatorService.Object,
                                                     expenditureWaybillIndicatorService.Object, storageService.Object, clientContractIndicatorService.Object);

            dealService = dealServiceMock.Object;

            user = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            clientContractIndicatorService.Setup(x => x.CalculateCashPaymentLimitExcessByPaymentsFromClient(It.IsAny <ClientContract>())).Returns(0);
        }
        public void Should_GetAllAsync_ThrowsFileNotFoundException_WhenDealFileIsNotAvailable()
        {
            //Given
            var fileInfo = Substitute.For <IFileInfo>();

            fileInfo.Exists.Returns(false);

            var fileProvider = Substitute.For <IFileProvider>();

            fileProvider.GetFileInfo(Arg.Any <string>()).Returns(fileInfo);

            var sut = new DealService(fileProvider);

            //When
            Func <Task> action = async() => await sut.GetAllAsync();

            //Then
            action.ShouldThrow <FileNotFoundException>();
        }
        public async Task Should_GetAllAsync_ReturnsACorrectNumberOfDeals_WhenDealFileIsAvailable()
        {
            //Given
            var fileInfo = Substitute.For <IFileInfo>();

            fileInfo.Exists.Returns(true);
            fileInfo.CreateReadStream().Returns(_fileFixture.Stream);

            var fileProvider = Substitute.For <IFileProvider>();

            fileProvider.GetFileInfo(Arg.Any <string>()).Returns(fileInfo);

            var sut = new DealService(fileProvider);

            //When
            var actual = await sut.GetAllAsync();

            //Then
            actual.Should().NotBeNull();
            actual.Should().HaveCount(7);
        }
Ejemplo n.º 8
0
 public DealPayment(int dealPaymentId, int?paymentDealPaymentId, bool isParentDealExecuted, Direction direction, int paymentId, int?sourcePaymentId,
                    int?cptyServiceId, double amount, DateTime?date, string transactionNum, PaymentStatus paymentStatus, PaymentOperation paymentOperation,
                    DealService dealService, string currencyCode, DateTime createDate, bool isMyPayment, string accountNumberFrom, string accountNumberTo)
 {
     DealPaymentId        = dealPaymentId;
     PaymentDealPaymentId = paymentDealPaymentId;
     IsParentDealExecuted = isParentDealExecuted;
     Direction            = direction;
     PaymentId            = paymentId;
     SourcePaymentId      = sourcePaymentId;
     CptyServiceId        = cptyServiceId;
     Amount            = amount;
     Date              = date;
     TransactionNum    = transactionNum;
     PaymentStatus     = paymentStatus;
     PaymentOperation  = paymentOperation;
     DealService       = dealService;
     CurrencyCode      = currencyCode;
     CreateDate        = createDate;
     IsMyPayment       = isMyPayment;
     AccountNumberFrom = accountNumberFrom;
     AccountNumberTo   = accountNumberTo;
 }
Ejemplo n.º 9
0
        public ActionResult GetProjectInfoAndContacts(string projectGuid)
        {
            return(ActionUtils.Json(() =>
            {
                //权限检查
                var authorizedIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(authorizedIds.Contains(project.ProjectId), "当前用户没有读取产品[{0}]的权限", project.Name);

                var projectInfo = new ProjectInfo();
                if (project.CnabsDealId.HasValue)
                {
                    DealService ds = new DealService();
                    projectInfo = MonitorConvertion.ConvertProjectInfo(ds.GetDealData(project.CnabsDealId.Value), projectGuid);
                }
                else
                {
                    var rootFolder = WebConfigUtils.RootFolder;
                    project.Model = m_dbAdapter.Project.GetModel(project.ModelId);

                    var modelFolder = Path.Combine(rootFolder, project.Model.ModelFolder);
                    var ymlFilePath = modelFolder + @"\Script.yml";
                    if (System.IO.File.Exists(ymlFilePath))
                    {
                        using (StreamReader sr = new StreamReader(ymlFilePath))
                        {
                            var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream);
                            if (nancyDealData != null)
                            {
                                DateTime?date = null;
                                projectInfo = new ProjectInfo()
                                {
                                    guid = project.ProjectGuid,
                                    fullName = project.Name,
                                    closingDate = nancyDealData.ScheduleData.ClosingDate,
                                    legalMaturityDate = nancyDealData.ScheduleData.LegalMaturity,
                                    firstPaymentDate = nancyDealData.ScheduleData.PaymentSchedule.Periods.Count > 0 ?
                                                       nancyDealData.ScheduleData.PaymentSchedule.Periods[0].PaymentDate : date,
                                    paymentFrequency = Toolkit.PaymentFrequency(nancyDealData.ScheduleData.PaymentPerYear),
                                    //TODO: 监管机构 产品类型
                                    //regulator
                                    //productType
                                };
                            }
                        }
                    }
                }

                var result = new
                {
                    ProjectInfo = new
                    {
                        Guid = projectInfo.guid,
                        FullName = projectInfo.fullName,
                        ClosingDate = Toolkit.DateToString(projectInfo.closingDate),
                        LegalMaturityDate = Toolkit.DateToString(projectInfo.legalMaturityDate),
                        FirstPaymentDate = Toolkit.DateToString(projectInfo.firstPaymentDate),
                        PaymentFrequency = projectInfo.paymentFrequency,
                        Regulator = Toolkit.ToString(projectInfo.regulator),
                        ProductType = Toolkit.ToString(projectInfo.productType),
                    },
                    Contacts = m_dbAdapter.Contact.GetContactsByProjectId(project.ProjectId),
                };

                return ActionUtils.Success(result);
            }));
        }
Ejemplo n.º 10
0
 public override void Prepare()
 {
     // first callback. Initialize parameter-agnostic stuff here
     dealService = new DealService();
 }
Ejemplo n.º 11
0
        public App()
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjkzMzMzQDMxMzgyZTMyMmUzMFkrbThkQ0FqejNXS2YyUkRoQUFzZVhTbnhUK09BOFNPQjliS2RDUTJDSnM9");
            InitializeComponent();

            //start
            var builder = PublicClientApplicationBuilder.Create(OAuthSettings.ApplicationId).WithRedirectUri(OAuthSettings.RedirectUri);

            if (!string.IsNullOrEmpty(iOSKeychainSecurityGroup))
            {
                builder = builder.WithIosKeychainSecurityGroup(iOSKeychainSecurityGroup);
            }

            PCA = builder.Build();
            //end
            var o_dataservices = new DealService();

            o_dataservices.UpdateAll_list_Down_visible_installment();
            //تحديث ايام التاخير
            List <Data.V_costomar_deal_installment> List_Deal_Data;
            var view_Deal_Data = o_dataservices.GetAll_costomar_deal_installment_payed();

            if (view_Deal_Data.Result != null)
            {
                List_Deal_Data = view_Deal_Data.Result;

                var date = DateTime.Now;
                foreach (var element in List_Deal_Data)
                {
                    var O_installment = new Data.installment
                    {
                        installment_id         = element.installment_id,
                        deal_id                = element.deal_id,
                        InstallmentPaymentDate = element.InstallmentPaymentDate,
                        InstallmentDueDate     = element.InstallmentDueDate,
                        installment_condition  = element.installment_condition,
                        Collectedvalue         = element.Collectedvalue,
                        Worthy_amount          = element.Worthy_amount,
                        Remaining_amount       = element.Remaining_amount,
                        list_Down_visible      = element.list_Down_visible,
                        installmedntColor      = element.installmedntColor,
                        delay_Days             = element.delay_Days,
                    };
                    if (date > element.InstallmentDueDate)
                    {
                        var res = (date - O_installment.InstallmentDueDate).Days;
                        // عدد ايام التاخير اقصاها 3 شهور يعنى 90 يوم واللون الاحمر والاخضر بالرجي بي بيكونو 255  يعنى كل يوم تخير بيساوى 3 درجات فى اللون غالبا ...يعنى اضرب عدد اليام التاخير فى 3 يطلع الدرجة الى انا محتاج اظبطها
                        int   total_delay_Days = 0;
                        int   gren             = 0;
                        int   red  = 0;
                        int   blue = 0;
                        Color o_installmedntColor;

                        if (res <= 90)
                        {
                            if (res <= 30)
                            {
                                total_delay_Days = Convert.ToInt32(res * 2.5);
                                red  = 180 + total_delay_Days;
                                gren = 255;
                                blue = 180;
                                o_installmedntColor = Color.FromRgb(red, gren, blue);
                            }
                            else if (res <= 60 && res > 30)
                            {
                                total_delay_Days = Convert.ToInt32(res * 1.3);
                                red  = 255;
                                gren = 255 - total_delay_Days;
                                blue = 180;
                                o_installmedntColor = Color.FromRgb(red, gren, blue);
                            }
                            else
                            {
                                total_delay_Days = Convert.ToInt32(res * 1.4);
                                red  = 255;
                                gren = 180 - total_delay_Days;
                                blue = 180 - total_delay_Days;
                                o_installmedntColor = Color.FromRgb(red, gren, blue);
                            }
                        }
                        else
                        {
                            // اكثر من 90 يوم يبقى هحط الاحمر والاخضر على طول
                            red  = 255;
                            gren = 60;
                            blue = 60;
                            o_installmedntColor = Color.FromRgb(red, gren, blue);
                        }

                        O_installment.delay_Days = res.ToString();
                        string Color_Hex = o_installmedntColor.ToHex();
                        O_installment.installmedntColor = Color_Hex.Remove(1, 2);
                        // Color v = Color.FromHex(O_installment.installmedntColor);
                        int test = o_dataservices.Update_installment(O_installment).Result;
                        int x    = 5;
                    }
                }
            }

            Settings.Deal_installment_id = -1; Settings.Deal_deal_id = -1;
            MainPage = new NavigationPage(new Views.installment());
            //MainPage = new NavigationPage(new Views.MasterPage());
        }
Ejemplo n.º 12
0
 public DealController(DealService dealService)
 {
     this._dealService = dealService;
 }
Ejemplo n.º 13
0
        public PdfManager GenerateRevenueReport(DateTime?fromDate = null, DateTime?toDate = null)
        {
            DealService _dealService    = new DealService();
            FileInfo    file            = new FileInfo(pdfDestination);
            var         fontDestination = System.IO.Path.Combine(targetFolder, "times.ttf");

            //document settings
            pdfDoc = new PdfDocument(new PdfWriter(pdfDestination));
            pdfDoc.SetDefaultPageSize(PageSize.A4);
            document = new Document(pdfDoc, PageSize.A4, false).SetFontSize(12);
            //set header
            PdfFont font = PdfFontFactory.CreateFont(fontDestination, PdfEncodings.IDENTITY_H, true);
            PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.TIMES_BOLD);

            Paragraph docHeader = new Paragraph("Revenue Report").SetTextAlignment(TextAlignment.CENTER)
                                  .SetFontSize(headerFontSize).SetFont(bold);
            //set logo
            Image logo = new Image(ImageDataFactory
                                   .Create(logoFile))
                         .SetTextAlignment(TextAlignment.LEFT).SetHeight(60).SetWidth(60);

            document.Add(logo);
            document.Add(docHeader);

            if (fromDate != null && toDate != null)
            {
                var fromTo = new Paragraph("From " + fromDate.Value.ToString("D") + " to " + toDate.Value.ToString("D")).SetTextAlignment(TextAlignment.RIGHT).SetMarginRight(30);
                document.Add(fromTo);
            }

            var   currentItem = 1;
            Table table       = new Table(UnitValue.CreatePercentArray(6), false).SetFont(font);

            table.SetWidth(UnitValue.CreatePercentValue(100));
            table.SetFixedLayout();

            List <string> headers = new List <string> {
                "No.", "Deal's Name", "Closing Date", "Amount", "Customer's Name", "Owner"
            };

            foreach (var header in headers)
            {
                var newHeaderCell = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).SetTextRenderingMode(PdfCanvasConstants.TextRenderingMode.FILL_STROKE).SetStrokeWidth(0.3f).SetStrokeColor(DeviceGray.BLACK).Add(new Paragraph(header));
                table.AddHeaderCell(newHeaderCell);
            }

            var dealList = _dealService.GetDealList(pageSize: 99999, currentPage: 1, sort: new List <string> {
                "asc.name"
            });

            dealList.deals = dealList.deals.Where(c => c.createdAt.CompareTo(new DateTime(1, 1, 1)) != 0 || c.endOn.CompareTo(new DateTime(1, 1, 1)) != 0 || c.expectedDate.CompareTo(new DateTime(1, 1, 1)) != 0).ToList();
            if (fromDate != null && toDate != null)
            {
                dealList.deals = dealList.deals.Where(c => (c.endOn >= fromDate && c.endOn <= toDate) && (c.stage == "Won")).ToList();
            }

            foreach (var deal in dealList.deals)
            {
                var x = deal.expectedDate.CompareTo(new DateTime(1, 1, 1)) != 0;
                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(currentItem.ToString())));
                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(deal.name ?? "")));

                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(deal.endOn.CompareTo(new DateTime(1, 1, 1)) != 0 ? deal.endOn.ToString("dd'/'MM'/'yyyy") : "")));

                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(deal.amount.ToString() ?? "")));
                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(deal.accountName ?? "")));
                table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph(deal.owner ?? "")));
                currentItem++;
            }
            long totalAmount = dealList.deals.Aggregate((long)0, (total, next) => total += next.amount, res => res);

            table.AddCell(new Cell(1, 3).SetTextAlignment(TextAlignment.CENTER).SetFontSize(fontSize).Add(new Paragraph("Sum")));
            table.AddCell(new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetBorderRight(Border.NO_BORDER).SetFontSize(fontSize).Add(new Paragraph(totalAmount.ToString())));
            table.AddCell(new Cell(1, 2).SetTextAlignment(TextAlignment.CENTER).SetBorderLeft(Border.NO_BORDER).SetFontSize(fontSize).Add(new Paragraph("")));
            document.Add(table);

            document.Add(new Paragraph(new Text("\n")));

            var dateSignature = new Paragraph("Hanoi, " + DateTime.Now.ToString("D")).SetTextAlignment(TextAlignment.RIGHT).SetMarginRight(30);

            document.Add(dateSignature);
            document.Add(new Paragraph(new Text("\n\n")));
            document.Add(new Paragraph(new Text("Signature: ________________________")).SetTextAlignment(TextAlignment.RIGHT).SetMarginRight(0));


            int numberOfPages = pdfDoc.GetNumberOfPages();

            for (int i = 1; i <= numberOfPages; i++)
            {
                document.ShowTextAligned(new Paragraph(String
                                                       .Format(i.ToString())),
                                         559, PageSize.A4.GetBottom() + 20, i, TextAlignment.RIGHT,//806
                                         VerticalAlignment.BOTTOM, 0);
            }
            document.Close();
            return(this);
        }
Ejemplo n.º 14
0
 public DealController(DealService service)
 {
     _service = service;
 }
Ejemplo n.º 15
0
        public ActionResult GetPaymentPercentChart(string projectGuid)
        {
            return(ActionUtils.Json(() =>
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);

                CommUtils.Assert(project.CnabsDealId.HasValue, "CNABS deal id is null.");

                DealService dealService = new DealService();
                var dealData = dealService.GetDealData(project.CnabsDealId.Value);
                CommUtils.Assert(dealData.ClosingDate.HasValue, "查找计息日失败");
                var closingDate = dealData.ClosingDate;

                //Load note info
                var notes = m_dbAdapter.Dataset.GetNotes(project.ProjectId);
                var cnabsNotes = new ProjectLogicModel(CurrentUserName, project).Notes;
                var noteDict = Toolkit.GetNoteDictionary(project, notes, cnabsNotes);
                var noteInfos = notes.ConvertAll(x => noteDict[x.NoteId]);

                //Load dataset info
                var datasetViewModels = new List <DatasetViewModel>();
                var dealSchedule = NancyUtils.GetDealSchedule(project.ProjectId);
                var datasets = m_dbAdapter.Dataset.GetDatasetByProjectId(project.ProjectId);
                foreach (var dataset in datasets)
                {
                    var noteDatas = m_dbAdapter.Dataset.GetNoteDatas(dataset.DatasetId);
                    var datasetViewModel = Toolkit.GetDatasetViewModel(dataset, dealSchedule.PaymentDates, noteDict, noteDatas);
                    datasetViewModels.Add(datasetViewModel);
                }

                datasetViewModels.Reverse();

                var dataSeries = new DataSeries();
                dataSeries.name = "汇总";
                dataSeries.data = new List <Vector>();
                dataSeries.data.Add(new Vector(closingDate.Value, 100f));

                var sumNotional = noteInfos.Sum(x => x.Notional);
                var endingBalance = sumNotional;

                if (sumNotional.HasValue && sumNotional.Value != 0)
                {
                    foreach (var datasetViewModel in datasetViewModels)
                    {
                        var detail = datasetViewModel.SumPaymentDetail;
                        endingBalance -= detail.PrincipalPaid;
                        dataSeries.data.Add(new Vector(datasetViewModel.PaymentDay.Value, (endingBalance.Value / sumNotional.Value) * 100));
                    }
                }

                var dataSeriesList = new List <DataSeries>();
                dataSeriesList.Add(dataSeries);

                Dictionary <string, List <Vector> > series = new Dictionary <string, List <Vector> >();
                Dictionary <string, decimal> endingBalances = new Dictionary <string, decimal>();
                foreach (var noteInfo in noteInfos)
                {
                    var key = noteInfo.Name;
                    series[key] = new List <Vector>();
                    endingBalances[key] = noteInfo.Notional.Value;
                    series[key].Add(new Vector(closingDate.Value, 100d));
                }

                foreach (var datasetViewModel in datasetViewModels)
                {
                    foreach (var noteData in datasetViewModel.NoteDatas)
                    {
                        var key = noteData.NoteInfo.Name;
                        endingBalances[key] -= noteData.PaymentDetail.PrincipalPaid.Value;
                        series[key].Add(new Vector(datasetViewModel.PaymentDay.Value, (100 * endingBalances[key] / noteData.NoteInfo.Notional.Value)));
                    }
                }

                foreach (var key in series.Keys)
                {
                    var ds = new DataSeries();
                    ds.name = key;
                    ds.data = series[key];
                    dataSeriesList.Add(ds);
                }

                return ActionUtils.Success(dataSeriesList);
            }));
        }
Ejemplo n.º 16
0
        //private async void update_deal_in_date_now_Clicked(object sender, EventArgs e)
        //{

        //    //remainder = pricee - given;
        //    var O_DataServices = new GroupService();
        //    int O_remainder = Convert.ToInt32(remainder_lable.Text);
        //    int O_group_id = Convert.ToInt32(group_id_lable.Text);
        //    var o_V_Group_month_Lisst = O_DataServices.getGroup_by_Id(O_group_id).Result;
        //    int O_selcet_month = Convert.ToInt32(selcet_month_lable.Text);
        //    var f = ((o_V_Group_month_Lisst.MonthlyProfitRate.Value * O_selcet_month) + 100) / 1000;
        //    //هنا الاصول اشوف عدد الاقساط المدفوعه والمتبقيه واعمل كام حاجه كده
        //    int o_paid_installments = Convert.ToInt32(paid_installments_lable.Text) + 1;
        //    var total = Math.Round((O_remainder * f) / o_paid_installments);
        //    var t = O_remainder * f;
        //    var x = total * 10;
        //    int int_total = Convert.ToInt32(Math.Round((O_remainder * f) * o_paid_installments) * 10);
        //    int O_Total_Paid = Convert.ToInt32(Total_Paid_lable.Text);



        //    int total_remaing_quast = int_total - O_Total_Paid;

        //    await DisplayAlert("تنبيه", total_remaing_quast.ToString(), "حسنا");
        //    //الاصول هنا بقى اطلع اليرت فيها القيمه ولو تمام هو عاوز يعمل جدوله اجيب الحجات الى هعملها فى زرار الدفع لما يتعمل واحطها هنا
        //}
        private async void update_deal_in_date_now_Clicked(object sender, EventArgs e)
        {
            //remainder = pricee - given;
            var O_DataServices        = new GroupService();
            int O_remainder           = Convert.ToInt32(remainder_lable.Text);
            int O_group_id            = Convert.ToInt32(group_id_lable.Text);
            var o_V_Group_month_Lisst = O_DataServices.getGroup_by_Id(O_group_id).Result;
            int O_selcet_month        = Convert.ToInt32(selcet_month_lable.Text);
            int o_paid_installments   = Convert.ToInt32(paid_installments_lable.Text) + 1;
            var f                   = ((o_V_Group_month_Lisst.MonthlyProfitRate.Value * o_paid_installments) + 100) / 1000;
            int qast                = Convert.ToInt32(Math.Round((O_remainder * f) / o_paid_installments) * 10);
            int new_Total_qast      = qast * o_paid_installments;
            int O_Total_Paid        = Convert.ToInt32(Total_Paid_lable.Text);
            int total_remaing_quast = new_Total_qast - O_Total_Paid;

            var saved     = O_remainder - (new_Total_qast + O_Total_Paid);
            var saved_Msg = "تم خصم مبلغ " + saved.ToString() + "@";

            saved_Msg = saved_Msg.Replace("@", System.Environment.NewLine);
            var Msg = saved_Msg + "المبلغ الكلي المطلوب دفعه   " + total_remaing_quast.ToString() + "@" + " هل تريد دفع الملبغ ؟";

            Msg = Msg.Replace("@", System.Environment.NewLine);

            var s = await DisplayAlert("تنبيه", Msg, "حسنا", " الغاء");

            if (s == true)
            {
                // تعديل بينات القسط
                var O_deal_id      = Convert.ToInt32(deal_id_lable.Text);
                var O_DealServices = new DealService();
                var o_res          = O_DealServices.Get_Unpayed_installment_by_Deal_id(O_deal_id);
                if (o_res != null)
                {
                    var O_Unpayed_installment = o_res.Result;
                    O_Unpayed_installment.Collectedvalue         = total_remaing_quast;
                    O_Unpayed_installment.installmedntColor      = "#6A6AFF";
                    O_Unpayed_installment.InstallmentPaymentDate = DateTime.Now;
                    O_Unpayed_installment.installment_condition  = true;

                    var update_res = await O_DealServices.Update_installment(O_Unpayed_installment);

                    var O_deal = await O_DealServices.GetdealDital(O_deal_id);

                    if (O_deal != null)
                    {
                        O_deal.Total_Saved    = saved.ToString();
                        O_deal.Deal_condition = true;
                        var update_deal = await O_DealServices.Update_Deal(O_deal);



                        if (update_deal != 0)
                        {
                            int Total_Paid_and_given = new_Total_qast + Convert.ToInt32(product_given_Lable.Text);
                            if (Total_Paid_and_given > Convert.ToInt32(product_Price_Lable.Text))
                            {
                                int o_amount = Total_Paid_and_given - Convert.ToInt32(product_Price_Lable.Text);
                                //ابحث عن الاي دي لو مش لقيت  هعمل انشاء واحد جديد لو لقيت اعمل تحديث
                                var o_dataservices_smallEarnings = new smallEarningsService();
                                var existing_smallEarnings       = o_dataservices_smallEarnings.Get_smallEarnings(O_deal_id).Result;
                                if (existing_smallEarnings != null)
                                {
                                    //تحديث
                                    existing_smallEarnings.amount = o_amount;
                                    existing_smallEarnings.date   = DateTime.Now;

                                    var smallEarnings_Update_res = o_dataservices_smallEarnings.Update_smallEarnings(existing_smallEarnings);
                                }
                                else
                                {
                                    //انشاء جديد
                                    var note_msg          = " ";
                                    var New_smallEarnings = new Data.smallEarnings
                                    {
                                        amount  = o_amount,
                                        date    = DateTime.Now,
                                        note    = note_msg,
                                        deal_id = O_deal_id,
                                    };

                                    var smallEarnings_Create_res = o_dataservices_smallEarnings.Create_smallEarnings(New_smallEarnings);
                                }
                            }

                            MessagingCenter.Send("Ubdate", "UbdateListView", "Success");

                            DependencyService.Get <IMessage>().LongAlert("أنتهت الصفقة وتم أرشفتها");
                            Navigation.PushAsync(new Views.installment());
                        }
                    }
                }
            }



            //الاصول هنا بقى اطلع اليرت فيها القيمه ولو تمام هو عاوز يعمل جدوله اجيب الحجات الى هعملها فى زرار الدفع لما يتعمل واحطها هنا
            //فى الجدوبة الى انا فهمه ان الى هيتم كالتالى .... اولا دى اسمها جدولة يعنى مافيش حاجه اسمها انى اخد منه قيمه المبلغ
            //لا المبلغ المطلوب لاما يدفع لاما شكرا ...
            //ثانيا لو هو خلاص هيدفع فا لو في قسط مطلوب منه
            //فى عندى كذه حاجه
            // ممكن اضيف فى بينات الصفقة تمت الجدولة او لا ... او ممكن اعمل ان القيمه المدفوعه فى القسط هي كذة وخلاص واعدل فى باقى بينات الصفقه الى هو المبلغ المدفوع والمتبقى
        }