ソースを参照

三公费用修改

amigotrip 7 ヶ月 前
コミット
f88719c51e

+ 2 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4838,9 +4838,9 @@ namespace OASystem.API.Controllers
                         }else dic.Add("SubGZF", "0.00");
 
                         //删除多余行
-                        while (table3.Rows.Count > table4Row)
+                        while (table3.Rows.Count > table3Row)
                         {
-                            table3.Rows.RemoveAt(table4Row);
+                            table3.Rows.RemoveAt(table3Row);
                         }
 
                         //培训费

+ 188 - 130
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -202,20 +202,21 @@ namespace OASystem.API.Controllers
                  * 增加方式=实际报价时 费用必须审核才能进入团组报表
                  */
                 decimal frTotalAmount = 0.00M;//应收总金额
-                string _frSql = string.Format(@"Select fr.Id,fr.AddingWay,fr.Status,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
+                string _frSql = string.Format(@"  Select fr.Id,fr.AddingWay,fr.Status,u.CnName As Auditor,fr.AuditTime,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
 										        sd.Name As CurrencyCode,sd.Remark As CurrencyName,fr.Rate,fr.ItemSumPrice,fr.CreateTime
 										        From Fin_ForeignReceivables fr
 										        Left Join Sys_SetData sd On fr.Currency = sd.Id
+												Left Join Sys_Users u On fr.Auditor = u.Id
 										        Where fr.IsDel = 0 And fr.Diid = {0} Order By CreateTime", _dto.DiId);
-                List<Gsd_ForeignReceivablesView> _frViews1 = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
+                List<Gsd_ForeignReceivablesView> _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
 
 
-                List<Gsd_ForeignReceivablesView> _frViews = new List<Gsd_ForeignReceivablesView>();
-                if (_frViews1.Count > 0)
-                {
-                    _frViews.AddRange(_frViews1.Where(x => x.AddingWay != 2).ToList());
-                    _frViews.AddRange(_frViews1.Where(x => x.AddingWay == 2 && x.Status == 1).ToList());
-                }
+                //List<Gsd_ForeignReceivablesView> _frViews = new List<Gsd_ForeignReceivablesView>();
+                //if (_frViews1.Count > 0)
+                //{
+                //    _frViews.AddRange(_frViews1.Where(x => x.AddingWay != 2).ToList());
+                //    _frViews.AddRange(_frViews1.Where(x => x.AddingWay == 2 && x.Status == 1).ToList());
+                //}
 
                 _frViews.ForEach(x =>
                 {
@@ -601,7 +602,7 @@ namespace OASystem.API.Controllers
                                                      sd2.name As PaymentCurrency,ccp.PayPercentage,
                                                      (ctggrc.Price * (ccp.PayPercentage / 100)) As AmountPaid,
                                                      (ctggrc.Price - ctggrc.Price * (ccp.PayPercentage / 100)) As BalancePayment,
-                                                     ccp.DayRate,(ctggrc.Price * ccp.DayRate)  As CNYPrice,ccp.Payee,ccp.AuditGMDate,
+                                                     ccp.DayRate,(ctggrc.Price * (ccp.PayPercentage / 100) * ccp.DayRate) As CNYPrice,ccp.Payee,ccp.AuditGMDate,
                                                      ccp.OrbitalPrivateTransfer,sd1.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ctggr.CreateTime
                                                      From Grp_CarTouristGuideGroundReservations ctggr
                                                      Left Join ( Select cggrc.CTGGRId,sd1.Name As PriceName,cggrc.Price*cggrc.Count As Price,sd2.Name As PriceCurrency,
@@ -1244,14 +1245,14 @@ namespace OASystem.API.Controllers
                 #endregion
 
                 /* 
-                 * 团组报表计算方式
-                 * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
-                 * 应收金额 = 应收表.Sum()
-                 * 已收金额 = 已收表.Sum()
-                 * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
-                 * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
-                 * 
-                 */
+                * 团组报表计算方式
+                * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
+                * 应收金额 = 应收表.Sum()
+                * 已收金额 = 已收表.Sum()
+                * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
+                * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
+                * 
+                */
                 decimal _totalExpenditure = 0.00M; //总支出
                 decimal _amountReceivable = 0.00M; //应收金额
                 decimal _amountReceived = 0.00M;   //已收金额
@@ -3270,20 +3271,16 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
             if (_dto.Year < 1) return Ok(JsonView(false,"操作失败"));
 
 
-            string thisBeginDt = $"{_dto.Year}-01-01 00:00:00",
-                   thisEndDt = $"{_dto.Year}-12-31 23:59:59";
-
-            string lastBeginDt = $"{_dto.Year - 1}-01-01 00:00:00",
-                   lastEndDt = $"{_dto.Year - 1}-12-31 23:59:59";
-
-            #region 营业额
+            string beginDt = $"{_dto.Year-1}-01-01 00:00:00",
+                   endDt = $"{_dto.Year}-12-31 23:59:59";
 
-            string thisSql = string.Format(@"
+            string sql = string.Format(@"
 SELECT
   di.Id,
+  di.TeamName,
   di.VisitDate,
-  YEAR(di.VisitDate) AS Year,
-  MONTH(di.VisitDate) AS Month,
+  YEAR(di.VisitDate) AS YEAR,
+  MONTH(di.VisitDate) AS MONTH,
   (
     SELECT
       CAST(SUM(ItemSumPrice * Rate) AS DECIMAL(12, 2))
@@ -3293,138 +3290,199 @@ SELECT
       IsDel = 0
       AND AddingWay IN (0, 1, 2)
       AND di.Id = Diid
-  ) AS Amount
-FROM
-  Grp_DelegationInfo di
-WHERE
-  di.IsDel = 0
-  AND di.IsSure = 1
-  AND di.VisitDate BETWEEN '{0}' AND '{1}'
-", thisBeginDt,thisEndDt);
-            string lastSql = string.Format(@"
-SELECT
-  di.Id,
-  di.VisitDate,
-  YEAR(di.VisitDate) AS YEAR,
-  MONTH(di.VisitDate) AS MONTH,
+  ) AS SaleAmount,
   (
     SELECT
-      CAST(SUM(ItemSumPrice * Rate) AS DECIMAL(12, 2))
+      CAST(
+        SUM(
+          (
+            ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+          )
+        ) AS DECIMAL(12, 2)
+      )
     FROM
-      Fin_ForeignReceivables
+      Grp_AirTicketReservations atr
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 85
+      AND atr.Id = ccp.CId
     WHERE
-      IsDel = 0
-      AND AddingWay IN (0, 1, 2)
-      AND di.Id = Diid
-  ) AS Amount
-FROM
-  Grp_DelegationInfo di
-WHERE
-  di.IsDel = 0
-  AND di.IsSure = 1
-  AND di.VisitDate BETWEEN '{0}' AND '{1}'
-", lastBeginDt, lastEndDt);
-
-
-           var thisSalesData = _sqlSugar.SqlQueryable<SalesSqlView>(thisSql).ToList();
-           var lastSalesData = _sqlSugar.SqlQueryable<SalesSqlView>(lastSql).ToList();
-
-            List<SalesReturnView> salesData = new List<SalesReturnView>();
-            int salesMonth = 1;
-            while (salesMonth < 13)
-            {
-                var thisMonthData = thisSalesData.Where(x => x.Month == salesMonth).ToList();
-                var lastMonthData = lastSalesData.Where(x => x.Month == salesMonth).ToList();
-                decimal thisMonthSales = thisMonthData.Sum(x => x?.Amount ?? 0);
-                var thisIds = thisMonthData.Select(x => x.Id).ToList();
-                decimal lastMonthSales = lastMonthData.Sum(x => x?.Amount ?? 0);
-                var lastIds = lastMonthData.Select(x => x.Id).ToList();
-
-                salesData.Add(new SalesReturnView( _dto.Year,salesMonth, thisMonthSales, lastMonthSales, thisIds, lastIds) );
-
-
-                salesMonth++;
-            }
-
-            #endregion
-
-            #region 团组成本
-
-            string thisCostSql = string.Format(@"
-SELECT
-  di.Id,
-  di.VisitDate,
-  YEAR(di.VisitDate) AS YEAR,
-  MONTH(di.VisitDate) AS MONTH,
+      atr.IsDel = 0
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = atr.DiId
+  ) AirTicketAmount,
   (
     SELECT
-      CAST(SUM(PayMoney * DayRate) AS DECIMAL(12, 2))
+      CAST(
+        SUM(
+          (
+            ctggr.ServiceQuotedPrice * (ccp.PayPercentage / 100) * ccp.DayRate
+          )
+        ) AS DECIMAL(12, 2)
+      )
     FROM
-      Grp_CreditCardPayment
+      Grp_CarTouristGuideGroundReservations ctggr
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.IsDel = 0
+      AND ccp.CTable = 79
+      AND ctggr.Id = ccp.CId
     WHERE
-      IsDel = 0
-      AND di.Id = Diid
-      AND CTable IN(98, 81, 79, 85, 76, 80, 82)
-      AND IsPay = 1
-  ) AS Amount
-FROM
-  Grp_DelegationInfo di
-WHERE
-  di.IsDel = 0
-  AND di.IsSure = 1
-  AND di.VisitDate BETWEEN '{0}' AND '{1}'
-", thisBeginDt, thisEndDt);
-            string lastCostSql = string.Format(@"
-SELECT
-  di.Id,
-  di.VisitDate,
-  YEAR(di.VisitDate) AS YEAR,
-  MONTH(di.VisitDate) AS MONTH,
+      ctggr.IsDel = 0
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = ctggr.DiId
+  ) AS OPAmount,
   (
     SELECT
-      CAST(SUM(PayMoney * DayRate) AS DECIMAL(12, 2))
+      CAST(SUM((ccp.PayMoney * ccp.DayRate)) AS DECIMAL(12, 2))
     FROM
-      Grp_CreditCardPayment
+      Grp_DecreasePayments dp
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 98
+      AND dp.Id = ccp.CId
     WHERE
-      IsDel = 0
-      AND di.Id = Diid
-      AND CTable IN(98, 81, 79, 85, 76, 80, 82)
-      AND IsPay = 1
-  ) AS Amount
+      dp.IsDel = 0
+      AND ccp.Ctable = 98
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = dp.Diid
+  ) AS OtherCostAmount,
+  (
+    SELECT
+      CAST(
+        SUM(
+          (
+            ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+          )
+        ) AS DECIMAL(12, 2)
+      )
+    FROM
+      Grp_VisaInfo vi
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 80
+      AND vi.Id = ccp.CId
+    WHERE
+      vi.IsDel = 0
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = vi.DIId
+  ) AS VisaAmount,
+  (
+    SELECT
+      CAST(
+        SUM(
+          ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+        ) AS DECIMAL(12, 2)
+      )
+    FROM
+      Grp_InvitationOfficialActivities ioa
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 81
+      AND ioa.Id = ccp.CId
+    WHERE
+      ioa.IsDel = 0
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = ioa.Diid
+  ) AS OAAmount,
+  (
+    SELECT
+      CAST(
+        SUM(
+          ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+        ) AS DECIMAL(12, 2)
+      )
+    FROM
+      Grp_Customers ic
+      INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
+      AND ccp.CTable = 82
+      AND ic.Id = ccp.CId
+    WHERE
+      ic.IsDel = 0
+      AND ccp.IsAuditGM = 1And ccp.IsPay = 1
+      AND di.Id = ic.DiId
+  ) AS InsureAmount,
+  (
+    SELECT
+      CAST(
+        SUM(
+          ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+        ) AS DECIMAL(12, 2)
+      )
+    FROM
+      Grp_HotelReservations hr
+      INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
+    WHERE
+      hr.IsDel = 0
+      AND ccp.IsDel = 0
+      AND ccp.CTable = 76
+      AND ccp.IsAuditGM = 1
+      AND ccp.PayMoney <> 0
+      AND ccp.IsPay = 0
+      AND di.Id = hr.DiId
+  ) AS HotelAmount,
+  (
+    SELECT
+      CAST(
+        SUM(
+          ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+        ) AS DECIMAL(12, 2)
+      )
+    FROM
+      Grp_HotelReservations hr
+      INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
+    WHERE
+      hr.IsDel = 0
+      AND ccp.IsDel = 0
+      AND ccp.CTable = 76
+      AND ccp.IsAuditGM = 1
+      AND ccp.PayMoney <> 0
+      AND ccp.IsPay = 0
+      AND di.Id = hr.DiId
+  ) AS HotelAmount,
+  (
+    SELECT
+      CAST(
+        SUM((gec.PriceSum * gec.Coefficient * ccp.DayRate)) AS DECIMAL(12, 2)
+      )
+    FROM
+      OA2023DB.dbo.Fin_GroupExtraCost gec
+      INNER JOIN Grp_CreditCardPayment ccp ON gec.Id = ccp.CId
+    WHERE
+      ccp.IsDel = 0
+      AND ccp.CTable = 1015
+      AND ccp.IsAuditGM = 1
+      AND ccp.IsPay = 1
+      AND di.Id = gec.DiId
+  ) AS ExcessAmount
 FROM
   Grp_DelegationInfo di
 WHERE
   di.IsDel = 0
   AND di.IsSure = 1
   AND di.VisitDate BETWEEN '{0}' AND '{1}'
-", lastBeginDt, lastEndDt);
+ORDER BY
+  di.VisitDate
+",beginDt,endDt);
 
+            var data = await _sqlSugar.SqlQueryable<StatisticsYOYView>(sql).ToListAsync();
 
-            var thisCostData = _sqlSugar.SqlQueryable<SalesSqlView>(thisCostSql).ToList();
-            var lastCostData = _sqlSugar.SqlQueryable<SalesSqlView>(lastCostSql).ToList();
+            var thisYearData = data.Where(x => x.Year == _dto.Year).ToList();
+            var lastYearData = data.Where(x => x.Year == (_dto.Year - 1)).ToList();
 
-            List<SalesReturnView> costData = new List<SalesReturnView>();
-            int costMonth = 1;
-            while (costMonth < 13)
+            List<YOYReturnView> SalesYOYData = new List<YOYReturnView>();
+            int monthIndex = 1;
+            while (monthIndex < 13)
             {
-                var thisMonthData = thisSalesData.Where(x => x.Month == costMonth).ToList();
-                var lastMonthData = lastSalesData.Where(x => x.Month == costMonth).ToList();
-                decimal thisMonthSales = thisMonthData.Sum(x => x?.Amount ?? 0);
-                var thisIds = thisMonthData.Select(x => x.Id).ToList();
-                decimal lastMonthSales = lastMonthData.Sum(x => x?.Amount ?? 0);
-                var lastIds = lastMonthData.Select(x => x.Id).ToList();
 
-                costData.Add(new SalesReturnView(_dto.Year, costMonth, thisMonthSales, lastMonthSales, thisIds, lastIds));
 
 
-                costMonth++;
-            }
 
+                monthIndex++;
+            }
 
-            #endregion
 
 
-            return Ok(JsonView(true,"操作成功!", new { SalesData = salesData,CostData = costData }));
+            return Ok(JsonView(true,"操作成功!", new { data = data, SalesData = new { },CostData = new { } }));
         }
 
         #endregion

+ 72 - 10
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -605,7 +605,7 @@ namespace OASystem.Domain.ViewModels.Financial
 
     #region 统计模块
 
-    public class SalesSqlView
+    public class StatisticsYOYView
     {
         public int Id { get; set; }
         public DateTime VisitDate { get; set; }
@@ -613,33 +613,95 @@ namespace OASystem.Domain.ViewModels.Financial
         public int Year { get; set; }
         public int Month { get; set; }
 
-        public decimal Amount { get; set; }
+        /// <summary>
+        /// 销售额金额
+        /// </summary>
+        public decimal SaleAmount { get; set; }
+
+        /// <summary>
+        /// 机票金额
+        /// </summary>
+        public decimal AirTicketAmount { get; set; }
+
+        /// <summary>
+        /// op金额
+        /// </summary>
+        public decimal OPAmount { get; set; }
+
+        /// <summary>
+        /// 其他费用金额
+        /// </summary>
+        public decimal OtherCostAmount { get; set; }
+
+        /// <summary>
+        /// 签证金额
+        /// </summary>
+        public decimal VisaAmount { get; set; }
+
+        /// <summary>
+        /// 邀请公务金额
+        /// </summary>
+        public decimal OAAmount { get; set; }
+
+        /// <summary>
+        /// 保险金额
+        /// </summary>
+        public decimal InsureAmount { get; set; }
+
+        /// <summary>
+        /// 酒店金额
+        /// </summary>
+        public decimal HotelAmount { get; set; }
+
+        /// <summary>
+        /// 超支金额
+        /// </summary>
+        public decimal ExcessAmount { get; set; }
+
+        /// <summary>
+        /// 成本金额
+        /// </summary>
+        public decimal CostAmount
+        {
+            get
+            {
+                return AirTicketAmount + HotelAmount + InsureAmount + OAAmount + VisaAmount + OtherCostAmount + OPAmount + ExcessAmount;
+            }
+        }
+
+        public decimal GrossProfitAmount
+        {
+            get
+            {
+                return SaleAmount - CostAmount;
+            }
+        }
 
         public List<int> ThisIds { get; set; }
         public List<int> LastIds { get; set; }
     }
-    public class SalesReturnView
+    public class YOYReturnView
     {
         public int Year { get; set; }
         public int Month { get; set; }
 
-        public decimal ThisSales { get; set; }
-        public decimal LastSales { get; set; }
+        public decimal ThisAmount { get; set; }
+        public decimal LastAmount { get; set; }
 
         public string Yoy { get; set; }
 
         public List<int> ThisIds { get; set; }
         public List<int> LastIds { get; set; }
-        public SalesReturnView(int year, int month, decimal thisSales, decimal lastSales, List<int> thisIds, List<int> lastIds)
+        public YOYReturnView(int year, int month, decimal thisAmount, decimal lastAmount, List<int> thisIds, List<int> lastIds)
         {
             this.Year = year;
             this.Month = month;
-            this.ThisSales = thisSales;
-            this.LastSales = lastSales;
+            this.ThisAmount = thisAmount;
+            this.LastAmount = lastAmount;
             string _yoy = "0.00%";
-            if (lastSales != 0)
+            if (lastAmount != 0)
             {
-                _yoy = ((thisSales - lastSales) / lastSales).ToString("#0.00") + "%";
+                _yoy = ((thisAmount - lastAmount) / lastAmount).ToString("#0.00") + "%";
             }
 
             this.Yoy = _yoy;

+ 40 - 0
OASystem/OASystem.Domain/ViewModels/Statistics/GroupStatementView.cs

@@ -193,9 +193,49 @@ namespace OASystem.Domain.ViewModels.Statistics
 
         public int diid { get; set; }
 
+        /// <summary>
+        /// 添加方式   
+        /// 0 - 账单模块   1 - 成本预算模块 2 - 实际报价
+        /// </summary>
         public int AddingWay { get; set; }
 
+        /// <summary>
+        /// 审核状态 AddingWay==2该项有值
+        /// 0 - 未审核 1 - 审核通过 2 - 审核不通过
+        /// </summary>
         public int Status { get; set; }
+
+        public string StatusStr
+        {
+            get
+            {
+                string str = "-";
+                if (AddingWay == 2)
+                {
+                    if (Status == 0) str = "未审核";
+                    else if (Status == 1) str = "审核通过";
+                    else if (Status == 2) str = "审核不通过";
+                }
+                return str;
+            }
+        }
+
+        public string Auditor { get; set; }
+
+        public string AuditorStr { get {
+                string str = "-";
+                if (AddingWay == 2)
+                {
+                    if (Status != 0)
+                    {
+                        str = @$"{Auditor} ";
+                    }
+                }
+                return str;
+            } }
+
+        //public DateTime? AuditTime { get; set; }
+
         /// <summary>
         /// 费用名称
         /// </summary>