コード例 #1
0
        /// <summary>
        /// make company monthly payment means recurring payments
        /// </summary>
        /// <createdby>Sumit Saurav</createdby>
        /// <createddate>09/july/2014</createddate>
        public static void MakeCompanyRecurringMonthlyPayment()
        {
            try
            {
                #region Valiables
                DecisionPointRepository       objDecisionPointRepository = null;
                RecurringPaymentResponseParam planDetails = null;
                objDecisionPointRepository = new DecisionPointRepository();
                IList <int> lstStaff           = new List <int>();
                IList <int> lstBusinessPartner = new List <int>();
                IList <int> lstWePayIc         = new List <int>();
                IList <CompanyIdResponseParam>     lstCompany    = objDecisionPointRepository.getAllPayeeCompanyId();
                IList <PaymentAmountResponseParam> PaymentAmount = null;
                int amount = 0;
                #endregion
                if (lstCompany != null && lstCompany.Count > 0)
                {
                    foreach (var item in lstCompany)
                    {
                        try
                        {
                            #region Company Payment Calculation

                            // get payment amount of a compnay inclusing staff, business, IC rates
                            PaymentAmount = objDecisionPointRepository.getPaymentAmount(item.CompanyId).ToList();

                            planDetails = new RecurringPaymentResponseParam();
                            //get recurring payment customer details
                            planDetails = objDecisionPointRepository.getPlanDetails(Convert.ToInt32(item.Id));
                            if (planDetails != null)
                            {
                                int IsPaymentDone = objDecisionPointRepository.IsRecurringPaymentDone(planDetails.CustomerId, remarkMonthlyPlan);
                                if (IsPaymentDone == 0)
                                {
                                    //check wether is invoice is false or not??
                                    if (!Convert.ToBoolean(PaymentAmount[0].IsInvoice))
                                    {
                                        // code for staff calculation and deduction
                                        lstStaff = objDecisionPointRepository.GetAllStaff(item.CompanyId);

                                        // code for business partner calculation and deduction
                                        lstBusinessPartner = objDecisionPointRepository.GetAllBusinessPartners(item.CompanyId);

                                        // code for we pay IC calculation and deduction
                                        lstWePayIc = objDecisionPointRepository.GetAllWePayIc(item.CompanyId);


                                        if (PaymentAmount != null && PaymentAmount.Count > 0)
                                        {
                                            decimal staffamount    = Convert.ToDecimal(lstStaff.Count()) * Convert.ToDecimal(PaymentAmount[0].PerFieldStaffFee);
                                            decimal businessAmount = Convert.ToDecimal(lstBusinessPartner.Count()) * Convert.ToDecimal(PaymentAmount[0].PerOfficeStaffFee);
                                            decimal IcAmount       = Convert.ToDecimal(lstWePayIc.Count()) * Convert.ToDecimal(PaymentAmount[0].PerIcFee);
                                            amount = Convert.ToInt32(((staffamount + businessAmount + IcAmount) * 100));
                                        }
                                        planDetails.Amount = amount;
                                        planDetails.Remark = remarkMonthlyPlan;
                                        planDetails.UserId = item.Id;
                                        //update plan in stripe.

                                        StripePayment payment = new StripePayment(Convert.ToString(ConfigurationManager.AppSettings["StripeKey"]));
                                        XamarinStripeCore.AnnualMonthlyPaymentCharge(payment, planDetails);
                                    }
                                }
                            }
                            #endregion
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
            }
        }