|
@@ -27,6 +27,7 @@ using System.Globalization;
|
|
|
using System.IO.Compression;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using Org.BouncyCastle.Asn1.X509.Qualified;
|
|
|
+using MathNet.Numerics;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -46,9 +47,9 @@ namespace OASystem.API.Controllers
|
|
|
private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
|
|
|
private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
|
|
|
private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
|
|
|
- private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
|
|
|
+ private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
|
|
|
private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
|
|
|
- private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
|
|
|
+ private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
|
|
|
private readonly ForeignReceivablesRepository _foreignReceivablesRepository;
|
|
|
|
|
|
/// <summary>
|
|
@@ -840,6 +841,13 @@ namespace OASystem.API.Controllers
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ private class EnterExitCostCurrency
|
|
|
+ {
|
|
|
+ public string Name { get; set; }
|
|
|
+ public string Code { get; set; }
|
|
|
+ public decimal Rate { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 已收账单
|
|
|
/// File Downloasd
|
|
@@ -860,7 +868,7 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川) 2 生成收款单(北京) 3 汇款账单"));
|
|
|
}
|
|
|
-
|
|
|
+ var _currencyDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
|
|
|
var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
|
|
|
if (_DelegationInfo == null)
|
|
|
{
|
|
@@ -968,6 +976,28 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(false, "该团组未填写出入境费用;"));
|
|
|
}
|
|
|
|
|
|
+ var _EnterExitCostCurrencys = new List<EnterExitCostCurrency>();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(_EnterExitCosts.CurrencyRemark))
|
|
|
+ {
|
|
|
+ var currency1 = _EnterExitCosts.CurrencyRemark.Split("|");
|
|
|
+ foreach (var item in currency1)
|
|
|
+ {
|
|
|
+ var currency2 = item.Split(":");
|
|
|
+ var currency3 = currency2[0].Split("(");
|
|
|
+ var currencyName = currency3[0].ToString();
|
|
|
+ var currencyCode = currency3[1].Split(")")[0].ToString();
|
|
|
+
|
|
|
+ _EnterExitCostCurrencys.Add(new EnterExitCostCurrency
|
|
|
+ {
|
|
|
+ Name = currencyName,
|
|
|
+ Code = currencyCode,
|
|
|
+ Rate = Convert.ToDecimal(currency2[1] ?? "0")
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var _cityFee = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
|
|
|
|
|
|
foreach (var item in _DayAndCosts)
|
|
@@ -1057,7 +1087,6 @@ namespace OASystem.API.Controllers
|
|
|
* 458 公务舱
|
|
|
* 460 经济舱
|
|
|
*/
|
|
|
-
|
|
|
decimal airPrice = 0.00M;
|
|
|
string airName = string.Empty;
|
|
|
if (client.AirType == 457)
|
|
@@ -1077,7 +1106,6 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
//计算费用总和
|
|
|
-
|
|
|
decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
|
|
|
dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
|
|
|
+_EnterExitCosts.YiMiao + _EnterExitCosts.YiMiao + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
|
|
@@ -1127,7 +1155,20 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
|
|
|
SetCells(ChildTable, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/晚");
|
|
|
- SetCells(ChildTable, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
|
|
|
+
|
|
|
+ var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
|
|
|
+ var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
|
|
|
+ if (sys_currencyInfo != null)
|
|
|
+ {
|
|
|
+ var sys_currencyCode = sys_currencyInfo.Name;
|
|
|
+ var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
|
|
|
+ if (eec_currencyInfo != null)
|
|
|
+ {
|
|
|
+ currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SetCells(ChildTable, doc, rowIndex, 3, "汇率" + currencyRate);
|
|
|
SetCells(ChildTable, doc, rowIndex, 4, "CNY " + item.SubTotal + "\r\n");
|
|
|
rowIndex++;
|
|
|
zsinfo += item.Place + " " + days + "晚 " + item.Cost.ToString("#0.00") + currencyCode + "/晚" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY " + item.SubTotal * days + "\r\n";
|
|
@@ -1164,7 +1205,20 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
|
|
|
SetCells(ChildTable1, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
|
|
|
- SetCells(ChildTable1, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
|
|
|
+
|
|
|
+ var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
|
|
|
+ var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
|
|
|
+ if (sys_currencyInfo != null)
|
|
|
+ {
|
|
|
+ var sys_currencyCode = sys_currencyInfo.Name;
|
|
|
+ var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
|
|
|
+ if (eec_currencyInfo != null)
|
|
|
+ {
|
|
|
+ currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SetCells(ChildTable1, doc, rowIndex, 3, "汇率" + currencyRate);
|
|
|
SetCells(ChildTable1, doc, rowIndex, 4, "CNY " + item.SubTotal);
|
|
|
rowIndex++;
|
|
|
hsinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY " + item.SubTotal * days + "\r\n";
|
|
@@ -1201,7 +1255,19 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
|
|
|
SetCells(ChildTable2, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
|
|
|
- SetCells(ChildTable2, doc, rowIndex, 3, "汇率" + (item.SubTotal / item.Cost).ToString("#0.0000"));
|
|
|
+
|
|
|
+ var currencyRate = DecimalToString((item.SubTotal / item.Cost), 4);
|
|
|
+ var sys_currencyInfo = _currencyDatas.Find(x => item.Currency == x.Id);
|
|
|
+ if (sys_currencyInfo != null)
|
|
|
+ {
|
|
|
+ var sys_currencyCode = sys_currencyInfo.Name;
|
|
|
+ var eec_currencyInfo = _EnterExitCostCurrencys.Find(x => x.Code.Equals(sys_currencyCode));
|
|
|
+ if (eec_currencyInfo != null)
|
|
|
+ {
|
|
|
+ currencyRate = DecimalToString(eec_currencyInfo.Rate, 4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SetCells(ChildTable2, doc, rowIndex, 3, "汇率" + currencyRate);
|
|
|
SetCells(ChildTable2, doc, rowIndex, 4, "CNY " + item.SubTotal + "\r\n");
|
|
|
rowIndex++;
|
|
|
gzinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY " + item.SubTotal * days + "\r\n";
|
|
@@ -1275,7 +1341,6 @@ namespace OASystem.API.Controllers
|
|
|
TeableBookmarkArr.Clear();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
|
|
|
bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
|
|
|
bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用 付辰同志出访费用为¥73,604.8元
|
|
@@ -1329,6 +1394,45 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// decimal保留指定位数小数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="num">原始数量</param>
|
|
|
+ /// <param name="scale">保留小数位数</param>
|
|
|
+ /// <returns>截取指定小数位数后的数量字符串</returns>
|
|
|
+ private static string DecimalToString(decimal num, int scale)
|
|
|
+ {
|
|
|
+ string numToString = num.ToString();
|
|
|
+
|
|
|
+ int index = numToString.IndexOf(".");
|
|
|
+ int length = numToString.Length;
|
|
|
+
|
|
|
+ if (index != -1)
|
|
|
+ {
|
|
|
+ return string.Format("{0}.{1}",
|
|
|
+ numToString.Substring(0, index),
|
|
|
+ numToString.Substring(index + 1, Math.Min(length - index - 1, scale)));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return num.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 保留小数位数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="n">待处理的值</param>
|
|
|
+ /// <param name="d">保留位数</param>
|
|
|
+ /// <param name="isEnter">是否四舍五入</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static decimal Round(decimal n, int d, bool isEnter = false)
|
|
|
+ {
|
|
|
+ if (isEnter)
|
|
|
+ return decimal.Round(n, d, MidpointRounding.AwayFromZero);
|
|
|
+ return Math.Truncate(n * (decimal)Math.Pow(10, d)) / (decimal)Math.Pow(10, d);
|
|
|
+ }
|
|
|
+
|
|
|
private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
|
|
|
{
|
|
|
//获取table中的某个单元格,从0开始
|