diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs new file mode 100644 index 00000000..b258aff6 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/SaleReturnInput.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs +{ + public class SaleReturnInput + { + /// + /// 入库仓库ID + /// + public string? warehouse { get; set; } + + /// + /// 供应商代码 + /// + public string? supplier_code { get; set; } + + /// + /// 打印状态 + /// + public string print_status { get; set; } = string.Empty; + + /// + /// 库位 + /// + public string? location { get; set; } + + /// + /// 来源单据ID + /// + public string? source_id { get; set; } + + /// + /// 来源单据代码 + /// + public string? source_code { get; set; } + + /// + /// 源单单据类型 + /// + public int? source_type { get; set; } + + /// + /// 来源单据行号 + /// + public int? source_line { get; set; } + + /// + /// 来源单据明细ID + /// + public string? source_detail_id { get; set; } + + /// + /// 采购单号 + /// + public string purchase_code { get; set; } + + public List details { get; set; } + } + public class SaleReturnDetail + { + /// + /// 物品代码 + /// + public string material_code { get; set; } = string.Empty; + + /// + /// 入库需求数量 + /// + public decimal? pr_qty { get; set; } + + /// + /// 实际入库数量 + /// + public decimal qty { get; set; } + + /// + /// 原因 + /// + public string? reason { get; set; } + + /// + /// 入库仓库ID + /// + public string? warehouse { get; set; } + + /// + /// 不含税单价 + /// + public decimal? price { get; set; } + + /// + /// 含税单价 + /// + public decimal? tax_price { get; set; } + + /// + /// 不含税金额 + /// + public decimal? amount { get; set; } + + /// + /// 含税金额 + /// + public decimal? all_amount { get; set; } + + /// + /// 已打印数量 + /// + public decimal print_qty { get; set; } + + /// + /// 扫描数量 + /// + public decimal scan_qty { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 箱号 + /// + public string? container_no { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs index b0e0f8c8..d0bfb5f8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -208,5 +208,75 @@ namespace Tnb.WarehouseMgr await db.Insertable(WmsSaleH).ExecuteCommandAsync(); await db.Insertable(WmsSaleDs).ExecuteCommandAsync(); } + /// + /// 销售退货单 + /// + public async Task SaleReturn(SaleReturnInput input) + { + var db = _repository.AsSugarClient(); + WmsInstockH WmsInstockH = new WmsInstockH(); + string Code = await _billRuleService.GetBillNumber("WmsInStock"); + WmsInstockH.bill_code = Code; + WmsInstockH.bill_date = DateTime.Now; + WmsInstockH.bill_type = "25103434001429";//销售退货单 + WmsInstockH.biz_type = "26191496816421";//一般入库 + WmsInstockH.status = "25065138925589";//新增 + WmsInstockH.generate_type = "1";//0人工 1自动 + WmsInstockH.create_time = DateTime.Now; + WmsInstockH.source_id = input.source_id; + WmsInstockH.source_code = input.source_code; + WmsInstockH.source_line = input.source_line; + WmsInstockH.source_detail_id = input.source_detail_id; + WmsInstockH.is_check = 1; + WmsInstockH.purchase_code = input.purchase_code; + WmsInstockH.sync_status = "26191359047461";//无需同步 + WmsInstockH.print_status = "26191366982437";//未打印 + WmsInstockH.create_id = ""; + WmsInstockH.create_time = DateTime.Now; + var location = await db.Queryable().Where(p => p.location_code == input.location).FirstAsync(); + if (location != null) + WmsInstockH.location_id = location.id; + var warehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (warehouse != null) + WmsInstockH.warehouse_id = warehouse.id; + WmsInstockH.supplier_code = input.supplier_code; + var supplier = await db.Queryable().Where(p => p.supplier_code == input.supplier_code).FirstAsync(); + if (supplier != null) + { + WmsInstockH.supplier_id = supplier.id; + WmsInstockH.supplier_name = supplier.supplier_name; + } + List WmsInstockDs = new List(); + foreach (var detail in input.details) + { + WmsInstockD WmsInstockD = new WmsInstockD(); + WmsInstockD.bill_id = WmsInstockH.id; + WmsInstockD.line_status = "25065138925589";//新增 + WmsInstockD.pr_qty = detail.pr_qty; + WmsInstockD.qty = detail.qty; + WmsInstockD.reason = detail.reason; + WmsInstockD.price = detail.price; + WmsInstockD.tax_price = detail.tax_price; + WmsInstockD.amount = detail.amount; + WmsInstockD.all_amount = detail.all_amount; + WmsInstockD.print_qty = 0; + WmsInstockD.scan_qty = 0; + WmsInstockD.code_batch = detail.code_batch; + WmsInstockD.container_no = detail.container_no; + var detailwarehouse = await db.Queryable().Where(p => p.whcode == input.warehouse).FirstAsync(); + if (detailwarehouse != null) + WmsInstockD.warehouse_id = detailwarehouse.id; + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + WmsInstockD.material_id = material.id; + WmsInstockD.unit_id = material.unit_id; + + } + WmsInstockDs.Add(WmsInstockD); + } + await db.Insertable(WmsInstockH).ExecuteCommandAsync(); + await db.Insertable(WmsInstockDs).ExecuteCommandAsync(); + } } }