Browse Source

费用审核
费用List TotalStr 币种相关 改成动态

leiy 1 year ago
parent
commit
07b9680a2a

+ 80 - 48
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -34,6 +34,7 @@ using System.Globalization;
 using static QRCoder.PayloadGenerator;
 using Bookmark = Aspose.Words.Bookmark;
 using Aspose.Words.Fields;
+using NPOI.POIFS.FileSystem;
 
 namespace OASystem.API.Controllers
 {
@@ -940,22 +941,26 @@ namespace OASystem.API.Controllers
                 .Where(exp.ToExpression())
                 .ToList();
 
+            
             List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
-            decimal CNY = 0;
-            decimal PayCNY = 0;
-            decimal BalanceCNY = 0;
-            decimal YSFYCNY = 0;
 
-            decimal USD = 0;
-            decimal PayUSD = 0;
-            decimal BalanceUSD = 0;
-            decimal YSFYUSD = 0;
+            List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
+           
+            /*
+             * 币种信息
+             */
+
+            var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
 
-            decimal EUR = 0;
-            decimal PayEUR = 0;
-            decimal BalanceEUR = 0;
-            decimal YSFYEUR = 0;
+            /*
+             * 用户信息
+             */
 
+            var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
+
+            /*
+             * 处理详情数据 
+             */
             foreach (var entity in entityList)
             {
                 Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
@@ -1009,13 +1014,13 @@ namespace OASystem.API.Controllers
                 /*
                  * 应付款金额	
                  */
-                Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
+                Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).First();
                 string PaymentCurrency_WaitPay = "Unknown";
                 if (sdPaymentCurrency_WaitPay != null)
                 {
                     PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
                 }
-                _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
+                _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
 
                 /*
                  * 此次付款金额
@@ -1024,11 +1029,11 @@ namespace OASystem.API.Controllers
                 if (entity.PayPercentage == 0)
                 {
                     if (entity.PayThenMoney != 0)
-                        CurrPayStr = entity.PayThenMoney * entity.DayRate;
+                        CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
                 }
                 else
                 {
-                    CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate);
+                    CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
                 }
                 _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
 
@@ -1039,15 +1044,15 @@ namespace OASystem.API.Controllers
                 if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
                     BalanceStr = 0;
                 else
-                    BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate);
+                    BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
 
                 _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
 
                 /*
                  * 申请人
                  */
-                string operatorName = "";
-                Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
+                string operatorName = " - ";
+                Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).First();
                 if (_opUser != null)
                 {
                     operatorName = _opUser.CnName;
@@ -1059,12 +1064,12 @@ namespace OASystem.API.Controllers
                 */
                 string auditOperatorName = "Unknown";
                 if (entity.AuditGMOperate == 0)
-                    auditOperatorName = "";
+                    auditOperatorName = " - ";
                 else if (entity.AuditGMOperate == 4)
                     auditOperatorName = "自动审核";
                 else
                 {
-                    Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
+                    Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).First();
                     if (_adUser != null)
                     {
                         auditOperatorName = _adUser.CnName;
@@ -1073,8 +1078,7 @@ namespace OASystem.API.Controllers
                 _detail.AuditOperatorName = auditOperatorName;
 
                 /*
-                 * 
-                 * *超预算比例
+                 * 超预算比例
                  */
                 string overBudgetStr = "";
 
@@ -1090,41 +1094,69 @@ namespace OASystem.API.Controllers
                 /*
                  * 费用总计
                  */
-                if (entity.PaymentCurrency == 48)
-                {
-                    CNY += entity.PayMoney;
-                    PayCNY += CurrPayStr;
-                    BalanceCNY += BalanceStr;
-                    YSFYCNY += CurrPayStr;
-                }
-                if (entity.PaymentCurrency == 49)
-                {
-                    USD += entity.PayMoney;
-                    PayUSD += CurrPayStr;
-                    BalanceUSD += BalanceStr;
-                    YSFYUSD += CurrPayStr;
-                }
-                if (entity.PaymentCurrency == 51)
+
+                ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
                 {
-                    EUR += entity.PayMoney;
-                    PayEUR += CurrPayStr;
-                    BalanceEUR += BalanceStr;
-                    YSFYEUR += CurrPayStr;
-                }
+                    CurrencyId = entity.PaymentCurrency,
+                    CurrencyName = PaymentCurrency_WaitPay,
+                    AmountPayable = entity.PayMoney,
+                    ThisPayment = CurrPayStr,
+                    BalancePayment = BalanceStr,
+                    AuditedFunds = CurrPayStr
+                });
 
                 _detail.IsAuditGM = entity.IsAuditGM;
 
                 detailList.Add(_detail);
-
             }
 
             #endregion
 
             _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
-            _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
-            _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
-            _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
-            _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
+
+
+            /*
+             * 下方描述处理
+             */
+
+            List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重 
+
+            CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
+            if (ccpCurrencyPrice != null)
+            {
+                int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
+                nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
+
+            }
+            else
+            {
+                nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
+            }
+            string amountPayableStr = string.Format(@"应付款总金额: ");
+            string thisPaymentStr = string.Format(@"此次付款总金额: ");
+            string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
+            string auditedFundsStr = string.Format(@"已审费用总额: ");
+
+            foreach (var item in nonDuplicat)
+            {
+                var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
+                if (strs.Count > 0)
+                {
+                    decimal amountPayable = strs.Sum(it => it.AmountPayable);
+                    decimal thisPayment = strs.Sum(it => it.ThisPayment);
+                    decimal balancePayment = strs.Sum(it => it.BalancePayment);
+                    decimal auditedFunds = strs.Sum(it => it.AuditedFunds);
+                    amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
+                    thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
+                    balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
+                    auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
+                }
+            }
+
+            _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
+            _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
+            _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
+            _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
 
 
             var _view1 = new

+ 24 - 0
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -1118,6 +1118,30 @@ namespace OASystem.API.OAMethodLib
             return subDecimal;
         }
 
+        /// <summary>
+        /// decimal 保留两位小数 不四舍五入
+        /// </summary>
+        /// <param name="number"></param>
+        /// <returns></returns>
+        public static decimal ConvertToDecimal1(this decimal myDecimal)
+        {
+            var subDecimal = Math.Floor(myDecimal * 100) / 100;//保留两位小数,直接截取
+            return subDecimal;
+        }
+
+        /// <summary>
+        /// 列表的成员移动到列表的前面
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list"></param>
+        /// <param name="index"></param>
+        public static void MoveItemAtIndexToFront<T>(this List<T> list, int index)
+        {
+            T item = list[index];
+            list.RemoveAt(index);
+            list.Insert(0, item);
+        }
+
         /// <summary>
         /// 获取请假类型
         /// </summary>

+ 33 - 35
OASystem/OASystem.Domain/ViewModels/Groups/Grp_CreditCardPaymentView.cs

@@ -92,41 +92,6 @@ namespace OASystem.Domain.ViewModels.Groups
 
     public class Grp_CreditCardPaymentView
     {
-        /// <summary>
-        /// 团组编号
-        /// </summary>
-        public int DiId { get; set; }
-
-        /// <summary>
-        /// 团组名称
-        /// </summary>
-        public string TeamName { get; set; }
-
-        /// <summary>
-        /// 客户名称
-        /// </summary>
-        public string ClientName { get; set; }
-
-        /// <summary>
-        /// 访问国家
-        /// </summary>
-        public string VisitCountry { get; set; }
-
-        /// <summary>
-        /// 访问起止日期
-        /// </summary>
-        public string VisitDate { get; set; }
-
-        /// <summary>
-        /// 天数
-        /// </summary>
-        public int VisitDays { get; set; }
-
-        /// <summary>
-        /// 人数
-        /// </summary>
-        public int VisitPNumber { get; set; }
-
         /// <summary>
         /// 审核列表
         /// </summary>
@@ -203,4 +168,37 @@ namespace OASystem.Domain.ViewModels.Groups
 
         
     }
+
+    public class CreditCardPaymentCurrencyPriceItem
+    {
+        /// <summary>
+        /// 币种Id
+        /// </summary>
+        public int CurrencyId { get; set; }
+
+        /// <summary>
+        /// 币种Name
+        /// </summary>
+        public string CurrencyName { get; set; }
+
+        /// <summary>
+        /// 应付金额
+        /// </summary>
+        public decimal AmountPayable { get; set; }
+
+        /// <summary>
+        /// 此次付款
+        /// </summary>
+        public decimal ThisPayment { get; set; }
+
+        /// <summary>
+        /// 剩余尾款
+        /// </summary>
+        public decimal BalancePayment { get; set; }
+
+        /// <summary>
+        /// 已审款项
+        /// </summary>
+        public decimal AuditedFunds { get; set; }
+    }
 }

+ 2 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -66,6 +66,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
                         }
                     }
+                    else _DelegationInfo.VisitCountry = " - ";
 
                     result.Data = _DelegationInfo;
                 }
@@ -83,6 +84,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
                         }
                     }
+                    else _DelegationInfo.VisitCountry = " - ";
 
                     result.Data = _DelegationInfo;
                 }