利润核算单

dev
嵇文龙 3 weeks ago
parent ac18821665
commit b3f5646eb4

@ -1,5 +1,5 @@
using DS.Module.Core;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Dtos;
using SqlSugar;
namespace DS.WMS.Core.Fee.Dtos.Report
{
@ -8,6 +8,11 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// </summary>
public class ProfitAccounting
{
/// <summary>
/// ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 客户编号
/// </summary>
@ -268,7 +273,8 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// <summary>
/// 费用组
/// </summary>
public List<FeeGroup> FeeGroups { get; set; } = [];
[SugarColumn(IsIgnore = true)]
public List<AccountingItem> FeeGroups { get; set; } = [];
/// <summary>
/// 客户账期(结算日期)
@ -318,14 +324,15 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// <summary>
/// 费用统计
/// </summary>
public FeeAuditStatistics Statistics { get; set; }
[SugarColumn(IsIgnore = true)]
public FeeAuditStatistics? Statistics { get; set; }
}
/// <summary>
/// 费用
/// 费用
/// </summary>
public class FeeGroup
public class AccountingItem
{
/// <summary>
/// 费用名称
@ -333,34 +340,33 @@ namespace DS.WMS.Core.Fee.Dtos.Report
public string FeeName { get; set; }
/// <summary>
/// 待审核费用
/// 应收金额
/// </summary>
public List<AccountingItem> Items { get; set; }
}
public string RecvAmount { get; set; }
/// <summary>
/// 费用项
/// </summary>
public class AccountingItem
{
/// <summary>
/// 费用类型
/// 应收结算对象
/// </summary>
public FeeType FeeType { get; set; }
public string RecvCustomerName { get; set; }
/// <summary>
/// 金额
/// 应收备注
/// </summary>
public decimal Amount { get; set; }
public string? RecvRemark { get; set; }
/// <summary>
/// 结算对象
/// 应付金额
/// </summary>
public string CustomerName { get; set; }
public string PayAmount { get; set; }
/// <summary>
/// 备注
/// 应收结算对象
/// </summary>
public string? Remark { get; set; }
public string PayCustomerName { get; set; }
/// <summary>
/// 应收备注
/// </summary>
public string? PayRemark { get; set; }
}
}

@ -115,7 +115,6 @@ public interface IFeeRecordService
/// <summary>
/// 回写业务表费用状态
/// </summary>
/// <param name="tenantDb"></param>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>

@ -25,6 +25,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
form = await context.TenantDb.Queryable<SeaExport>().Where(s => s.Id == context.BusinessId)
.Select(s => new ProfitAccounting
{
Id = s.Id,
ETDValue = s.ETD,
Operator = s.OperatorName,
CustomerService = s.CustomerServiceName,
@ -66,56 +67,86 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
x.RemarkType,
x.Remark
}).ToListAsync();
form.InternalRemark = remarks.Find(x => x.RemarkType == "1")?.Remark;
form.CabinRemark = remarks.Find(x => x.RemarkType == "2")?.Remark;
form.BookingRemark = remarks.Find(x => x.RemarkType == "3")?.Remark;
form.InternalRemark = string.Join(Environment.NewLine, remarks.Where(x => x.RemarkType == "1").Select(x => x.Remark));
form.CabinRemark = string.Join(Environment.NewLine, remarks.Where(x => x.RemarkType == "2").Select(x => x.Remark));
form.BookingRemark = string.Join(Environment.NewLine, remarks.Where(x => x.RemarkType == "3").Select(x => x.Remark));
var list = await context.TenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType)
.WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id))
.Select<FeeRecordRes>().ToListAsync();
.OrderByDescending(x => x.Currency).Select<FeeRecordRes>().ToListAsync();
if (list.Count > 0)
{
form.Statistics = new FeeAuditStatistics(list);
for (int i = 0; i < list.Count; i++)
{
var fee = list[i];
var item = new AccountingItem
AccountingItem? item = form.FeeGroups.Find(x => x.FeeName == fee.FeeName);
string amount = $"{GetSymbol(fee.Currency)}{Math.Round(fee.Amount.GetValueOrDefault(), 0, MidpointRounding.AwayFromZero)}";
if (fee.FeeType == FeeType.Receivable)
{
Amount = Math.Round(fee.Amount.GetValueOrDefault(), 0, MidpointRounding.AwayFromZero),
CustomerName = fee.CustomerName,
FeeType = fee.FeeType,
Remark = fee.Remark
};
var group = form.FeeGroups.Find(x => x.FeeName == fee.FeeName && x.Items?.Count < 2);
if (group == null)
{
group = new FeeGroup
if (item == null || string.IsNullOrEmpty(item.RecvAmount))
{
FeeName = fee.FeeName,
Items = [item]
};
form.FeeGroups.Add(group);
}
else if (group.Items.Exists(x => x.FeeType == fee.FeeType))
{
group = new FeeGroup
item = new AccountingItem
{
FeeName = fee.FeeName,
RecvAmount = amount,
RecvCustomerName = fee.CustomerName,
RecvRemark = fee.Remark
};
form.FeeGroups.Add(item);
}
else
{
FeeName = fee.FeeName,
Items = [item]
};
form.FeeGroups.Add(group);
item.RecvAmount = amount;
item.RecvCustomerName = fee.CustomerName;
item.RecvRemark = fee.Remark;
}
}
else
{
group.Items.Add(item);
if (item == null || string.IsNullOrEmpty(item.PayAmount))
{
item = new AccountingItem
{
FeeName = fee.FeeName,
PayAmount = amount,
PayCustomerName = fee.CustomerName,
PayRemark = fee.Remark
};
form.FeeGroups.Add(item);
}
else
{
item.PayAmount = amount;
item.PayCustomerName = fee.CustomerName;
item.PayRemark = fee.Remark;
}
}
}
}
}
return form ?? new ProfitAccounting { Statistics = new FeeAuditStatistics(new List<FeeRecordRes>()) };
return form ?? new ProfitAccounting { Statistics = new FeeAuditStatistics([]) };
}
static char GetSymbol(string currency)
{
char symbol = default;
switch (currency)
{
case "RMB":
symbol = '¥';
break;
case "USD":
symbol = '$';
break;
default:
break;
}
return symbol;
}
}
}

@ -78,6 +78,19 @@ namespace DS.WMS.FeeApi.Controllers
return DataResult<FeeStatistics>.Success(stat);
}
/// <summary>
/// 订单费用统计
/// </summary>
/// <param name="bsId">业务ID</param>
/// /// <param name="bsType">业务类型</param>
/// <returns></returns>
[HttpGet, Route("OrderFeeStatistics")]
public async Task<DataResult<FeeStatistics>> OrderStatisticsAsync(long bsId, BusinessType bsType)
{
var stat = await _feeService.GetFeeStatisticsAsync(bsId, bsType);
return DataResult<FeeStatistics>.Success(stat);
}
/// <summary>
/// 保存费用
/// </summary>

Loading…
Cancel
Save