Merge branch 'feature/zs_v1.3_cash' into feature/zs_v1.3_0822

This commit is contained in:
吴方海
2025-09-08 10:42:30 +08:00
10 changed files with 229 additions and 23 deletions
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
using YLErp.Commons;
using YLErp.Helpers;
@@ -205,6 +205,20 @@ namespace YLErp.DBModels
/// </summary>
[DisplayName("账户类型")]
public string cash_type { get; set; }
/// <summary>
/// 转出科目
/// </summary>
[DisplayName("转出科目")]
[Column("transfer_out_account")]
public string TransferOutAccount { get; set; }
/// <summary>
/// 转入科目
/// </summary>
[DisplayName("转入科目")]
[Column("transfer_in_account")]
public string TransferInAccount { get; set; }
}
/// <summary>
/// 出入金信息
@@ -267,7 +281,7 @@ namespace YLErp.DBModels
{
get
{
if (Direction == "出金" || Direction == "入金" || Direction == "其他收入" || Direction == "其他支出" || Direction == "应收预付金" || Direction == "实收预付金" || Direction == "实付预付金" || Direction == "实收权利金" || Direction == "实付权利金")
if (Direction == "出金" || Direction == "入金" || Direction == "其他收入" || Direction == "其他支出" || Direction == "应收预付金" || Direction == "实收预付金" || Direction == "实付预付金" || Direction == "实收权利金" || Direction == "实付权利金" || Direction == "划转")
{
return Direction;
}
@@ -232,7 +232,6 @@ namespace YLErp.BLL.Eod
//SetDebugSqlLog();
Dictionary<int, DateTime?> dicIntradayTradePosition = DbContext.intraday_trade_position.Where(x => clientIds.Contains(x.ClientId)).AsEnumerable().GroupBy(p => p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) })
.ToDictionary(p => p.Key, p => p.OptDate);
Dictionary<int, DateTime?> dicCashInOut = DbContext.ClientCashInCashOut.Where(x => clientIds.Contains((int)x.ClientId)).AsEnumerable().GroupBy(p => (int)p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }).ToDictionary(p => p.Key, p => p.OptDate);
foreach (var item in _clientBalanceDic.Values)
{
@@ -1067,7 +1066,7 @@ namespace YLErp.BLL.Eod
from td in trade.DefaultIfEmpty()
where t.HappenDate >= lastSettletDateAddOne && t.HappenDate < newValuedate
&& t.ValidState != "InValid"
&& (t.State == ClientCashInCashOut. || t.State == ClientCashInCashOut. || (t.Direction == "出金" && ClientCashInCashOut.outCashCals.Contains(t.State)))
&& (t.State == ClientCashInCashOut. || t.State == ClientCashInCashOut. || ((t.Direction == "出金"||t.Direction=="划转") && ClientCashInCashOut.outCashCals.Contains(t.State)))
&& clientIds.Contains(t.ClientId.Value)
&& t.Money != null
&& td.TradeType != "收益互换"
@@ -1077,19 +1076,23 @@ namespace YLErp.BLL.Eod
TradeId = t.TradeId ?? 0,
action = t.Direction + "^" + (t.Direction == "应收" ? t.Action : ""),
money = t.Money.Value,
cash_type = t.cash_type
cash_type = t.cash_type,
TransferOutAccount=t.TransferOutAccount,
TransferInAccount = t.TransferInAccount
};
//获取包含的所有收益互换id列表
var allTradeIds = ClientCashQuery.Select(x => x.TradeId).ToList();
var ClientCashQuerySum = from t in ClientCashQuery
group t by new { t.ClientId, t.action, t.cash_type } into g
group t by new { t.ClientId, t.action, t.cash_type,t.TransferOutAccount,t.TransferInAccount } into g
select new
{
g.Key.ClientId,
g.Key.action,
g.Key.cash_type,
g.Key.TransferOutAccount,
g.Key.TransferInAccount,
moneySum = g.Sum(n => n.money),
swapMoneySun = 0.0
};
@@ -1152,6 +1155,45 @@ namespace YLErp.BLL.Eod
{
balance.OutFundOther = data.moneySum;
}
else if (data.action == "划转^")
{
if (data.TransferOutAccount == "初保账户")
{
balance.InFund -= data.moneySum;
if (data.TransferInAccount == "追保账户")
{
balance.VmInFund += data.moneySum;
}
else
{
balance.WinLoss += data.moneySum;
}
}
else if (data.TransferOutAccount == "追保账户")
{
balance.VmInFund -= data.moneySum;
if (data.TransferInAccount == "初保账户")
{
balance.InFund += data.moneySum;
}
else
{
balance.WinLoss += data.moneySum;
}
}
else
{
balance.WinLoss -= data.moneySum;
if (data.TransferInAccount == "初保账户")
{
balance.InFund += data.moneySum;
}
else
{
balance.VmInFund += data.moneySum;
}
}
}
}
@@ -602,6 +602,8 @@ namespace YLErp.Modules.ClientModule
r.CurrencyCode = req.CurrencyCode;
r.cash_type = req.cash_type;
r.ValidState = ConsGlobal.Valid;
r.TransferOutAccount = req.TransferOutAccount;
r.TransferInAccount = req.TransferInAccount;
}
if (isARAP)
@@ -696,7 +698,31 @@ namespace YLErp.Modules.ClientModule
}
#endregion
#region
if ("划转".Equals(r.Direction))
{
var clientbalance = ClientBalanceUtility.GetClientBanlances(new List<int> { r.ClientId.Value }, DateTime.MinValue, DateTime.Now.Date).FirstOrDefault();
if (clientbalance == null)
{
throw new ServiceException("查询客户资金信息失败");
}
var money = r.Money ?? 0;
money=isAddNew? money: money-(originalMoney??0);
if (r.TransferOutAccount == "初保账户" && money > clientbalance.NetFundAll)
{
throw new ServiceException("划转金额不能超过初保账户金额");
}
if (r.TransferOutAccount == "追保账户" && money > clientbalance.VmFundSum)
{
throw new ServiceException("划转金额不能超过追保账户金额");
}
if (r.TransferOutAccount == "已实现盈亏" && money > clientbalance.WinLoss)
{
throw new ServiceException("划转金额不能超过已实现盈亏");
}
r.cash_type = null;
}
#endregion
if (r.Direction != "出金" && r.Direction != "入金")
{
r.OpenBank = null;
@@ -18,8 +18,9 @@ namespace YLErp.BLL
/// 系统中可以操作的方向
/// </summary>
public static List<string> EntryDirection_Remove = new List<string> { "收入", "支出" };
public static List<string> EntryDirection_Menu = new List<string> { "出金", "入金", "其他收入", "其他支出" };
public static List<string> DirectionType = new List<string> { "出金", "入金", "权利金支出", "权利金收入", "平仓/行权支出", "平仓/行权收入", "票息支出", "票息收入", "其他支出", "其他收入", "互换收入", "互换支出","应付预付金","预付金返息" };
public static List<string> EntryDirection_Menu = new List<string> { "出金", "入金", "其他收入", "其他支出","划转" };
public static List<string> TransferAccount = new List<string> { "初保账户", "追保账户", "已实现盈亏" };
public static List<string> DirectionType = new List<string> { "出金", "入金", "划转", "权利金支出", "权利金收入", "平仓/行权支出", "平仓/行权收入", "票息支出", "票息收入", "其他支出", "其他收入", "互换收入", "互换支出","应付预付金","预付金返息" };
/// <summary>
/// 现金交易方向
/// </summary>
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using DocumentFormat.OpenXml.Drawing.Charts;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using Org.BouncyCastle.Asn1.Ocsp;
@@ -525,6 +526,44 @@ namespace YLErp.Modules.EodModule.SettlementModule
fundObject.OtherFund.Add(clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0);
}
}
else if (clientEntryexit.Direction.Equals("划转")) {
if (clientEntryexit.TransferOutAccount == "初保账户")
{
AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, -clientEntryexit.Money ?? 0);
if (clientEntryexit.TransferInAccount == "追保账户")
{
AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0);
}
else
{
WinLoss += clientEntryexit.Money ?? 0;
}
}
else if (clientEntryexit.TransferOutAccount == "追保账户")
{
AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, -clientEntryexit.Money ?? 0);
if (clientEntryexit.TransferInAccount == "初保账户")
{
AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0);
}
else
{
WinLoss += clientEntryexit.Money ?? 0;
}
}
else
{
WinLoss -= clientEntryexit.Money ?? 0;
if (clientEntryexit.TransferInAccount == "初保账户")
{
AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0);
}
else
{
AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0);
}
}
}
else
{
if (ClientCashInCashOut._期权费.Equals(clientEntryexit.Action))
+1 -1
View File
@@ -354,7 +354,7 @@ namespace YLErp.Web.Controllers
{
return JsonError("找不到出入金信息");
}
if (r.Direction != "出金" && r.Direction != "入金" && r.Direction != "其他收入" && r.Direction != "其他支出")
if (r.Direction != "出金" && r.Direction != "入金" && r.Direction != "其他收入" && r.Direction != "其他支出" && r.Direction != "划转")
{
return JsonError("该笔交易不可以删除");
}
+22 -1
View File
@@ -110,10 +110,31 @@
<option value="追保账户" @(Model.cash_type == "追保账户" ? "selected" : "")>追保账户</option>
</select>
</div>
<div class="form-group col-6" id="transfer_out_container">
<label class="formlabel">转出科目</label>
<select name="TransferOutAccount" id="TransferOutAccount" onchange="setTransferMoney()" @(Model.id > 0 ? "disabled" : "")>
@foreach (var item in EntryExitBLL.TransferAccount)
{
<option value="@(item)" @(item == Model.TransferOutAccount ? "selected" : "")>@(item)</option>
}
</select>
<label id="transfer_out_account_money">余额:</label>
</div>
<div class="form-group col-6" id="transfer_in_container">
<label class="formlabel">转入科目</label>
<select name="TransferInAccount" id="TransferInAccount" onchange="setTransferMoney()" @(Model.id > 0 ? "disabled" : "")>
@foreach (var item in EntryExitBLL.TransferAccount)
{
<option value="@(item)" @(item == Model.TransferInAccount ? "selected" : "")>@(item)</option>
}
</select>
<label id="transfer_in_account_money">余额:</label>
</div>
<div class="form-group col-6">
<label class="formlabel">金额</label>
<input id="MoneyStr" class="text-box" type="text" value="@(Model.MoneyStr)" name="MoneyStr" oninput="moneyInputMgr.onInput()" onfocus="moneyInputMgr.onFocus()" onblur="moneyInputMgr.onChange()" autocomplete="off">
<span></span>
<a href="javascript:void(0)" onclick="transferAll()" id="transferAll">全部转出</a>
</div>
@if (Model.TradeId == null || Model.TradeId == 0)
@@ -130,7 +151,7 @@
<input class='form_datetime text-box' size='16' id='HappenDate' type='text' value='@(Model.HappenDate?.ToString("yyyy-MM-dd HH:mm"))' name='HappenDate' />
</div>
<div class="form-group col-12">
<div class="form-group col-6">
<label class="formlabel">银行账号</label>
@if (pageObj.changeBeforeConfirm)
{
@@ -52,7 +52,7 @@
TradeAction: isCompanyCash ? "@ClientCashInCashOut.人工操作_预付金" : ""
};
if (!isCompanyCash) {
PostData.DirectionTypes = "出金,入金,权利金支出,权利金收入,平仓/行权支出,平仓/行权收入,票息支出,票息收入,其他支出,其他收入,互换收入,互换支出";
// PostData.DirectionTypes = "出金,入金,权利金支出,权利金收入,平仓/行权支出,平仓/行权收入,票息支出,票息收入,其他支出,其他收入,互换收入,互换支出";
} else {
PostData.InOut = "应收,应付";
}
@@ -394,7 +394,7 @@
function customButton(cellValue, options, rowObject) {
var imageHtml = "";
if ((rowObject.Direction == "出金" || rowObject.Direction == "入金" || rowObject.Direction == "其他收入" || rowObject.Direction == "其他支出") && pageData.canDelete && rowObject.TradeNumber == "" && rowObject.ApprovalProcess < 1) {
if ((rowObject.Direction == "出金" || rowObject.Direction == "入金" || rowObject.Direction == "其他收入" || rowObject.Direction == "其他支出"|| rowObject.Direction == "划转") && pageData.canDelete && rowObject.TradeNumber == "" && rowObject.ApprovalProcess < 1) {
imageHtml = imageHtml + "<input type=\"button\" value=\"删除\" class=\"wentiEdit\" onclick=\"deleteentryexit('" +
rowObject.EncryptId +
"');\" />";
@@ -495,7 +495,7 @@
if (isCompanyCash) {
addurl += "?isCompanyCash=1";
}
main.open("新增资金记录", addurl, { area: ['1000px', '75%'] });
main.open("新增资金记录", addurl, { area: ['1000px', '95%'] });
}
function Entryexit_remove() {
@@ -505,7 +505,7 @@
function startentryexitView(id) {
var srcurl = "/entryexit/entryexitView/?enid=" + id;
main.open("查看资金信息", srcurl, { area: ['1000px', '75%'] });
main.open("查看资金信息", srcurl, { area: ['1000px', '95%'] });
}
function reloadentryexit() {
@@ -67,6 +67,8 @@
<tr>@Html.MyDisplayFor(m => m.ClientName)</tr>
<tr>@Html.MyDisplayFor(m => m.DirectionType)</tr>
<tr>@Html.MyDisplayFor(m => m.cash_type)</tr>
<tr>@Html.MyDisplayFor(m => m.TransferOutAccount)</tr>
<tr>@Html.MyDisplayFor(m => m.TransferInAccount)</tr>
<tr>@Html.MyDisplayFor(m => m.Money, (((Model.Direction == "出金" ? (-1) : 1) * Model.Money) ?? 0).ToString("N"))</tr>
<tr>@Html.MyDisplayFor(m => m.CurrencyCode)</tr>
<tr>@Html.MyDisplayFor(m => m.HappenDate, Utilities.ShowValidDatetime(Model.HappenDate, "yyyy-MM-dd HH:mm:ss"))</tr>
@@ -1,4 +1,8 @@
const cardInputMgr = (new function () {
var winloss = 0; // 已实现盈亏
var netFund = 0; // 初保账户
var vmFund = 0; // 追保账户
var transferOutMoney = 0; // 转出金额
const cardInputMgr = (new function () {
var _inited = 0, _inputFlag = 0;
@@ -180,7 +184,18 @@ function checkSubmitData() {
else {
$("#Money").val($("#Money").val().replace(',', ''));
}
let direction = $("#Direction").val();
if (direction==="划转") {
var transfer_out_account = $("#TransferOutAccount").val();
var transfer_in_account = $("#TransferInAccount").val();
if (transfer_out_account === transfer_in_account) {
return main.message("转出科目与转入科目不能相同!");
}
var money = parseFloat($("#Money").val());
if (money <=0) {
return main.message("转出金额必须大于0");
}
}
return cardInputMgr.checkSubmit();
}
@@ -205,16 +220,30 @@ function setDirection(isInit) {
!isInit && cardInputMgr.changeInputType(true);
let direction = $("#Direction").val();
$(".changeInputBtn").toggleClass("hide", ["出金", "应付"].includes(direction));
if (direction === "金") {
$("#cash_type_container").hide(); // 隐藏资金类型
} else {
if (direction === "金") {
$("#cash_type_container").show(); // 显示资金类型
} else {
$("#cash_type_container").hide(); // 隐藏资金类型
}
if (direction === "划转") {
$("#transfer_out_container").show();
$("#transfer_in_container").show();
$("#transferAll").show();
} else {
$("#transfer_out_container").hide();
$("#transfer_in_container").hide();
$("#transferAll").hide();
}
cardInputMgr.toggle(["入金", "出金"].includes(direction));
cardInputMgr.updateOptions();
}
// 全部转出
function transferAll() {
$("#MoneyStr").val(transferOutMoney);
moneyInputMgr.onInput();
}
function setClientCash() {
var clientId = $("#ClientId").val();
if (!clientId) {
@@ -225,9 +254,41 @@ function setClientCash() {
$("#ClientCashCNY").val(res.CNY);
$("#ClientCashUSD").val(res.USD);
}
})
});
main.post("/trade_span/GetClientLatestBalance", { clientId: clientId }).done(function (data) {
winloss = data.WinLoss;
netFund = data.NetFund;
vmFund = data.VmFundSum;
setTransferMoney();
});
}
function setTransferMoney() {
var clientId = $("#ClientId").val();
if (!clientId) {
return;
}
var transfer_out_account = $("#TransferOutAccount").val();
var transfer_in_account = $("#TransferInAccount").val();
if (transfer_out_account === "初保账户") {
transferOutMoney = netFund;
$("#transfer_out_account_money").text("余额:" + netFund);
}
else if (transfer_out_account === "追保账户") {
transferOutMoney = vmFund;
$("#transfer_out_account_money").text("余额:" + vmFund);
} else {
transferOutMoney = winloss;
$("#transfer_out_account_money").text("余额:" + winloss);
}
if (transfer_in_account === "初保账户") {
$("#transfer_in_account_money").text("余额:" + netFund);
}
else if (transfer_in_account === "追保账户") {
$("#transfer_in_account_money").text("余额:" + vmFund);
} else {
$("#transfer_in_account_money").text("余额:" + winloss);
}
}
$(function () {
cardInputMgr.init();