...
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Validations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -9,6 +10,7 @@ using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
using Shared.Enums;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Back.Controllers
|
||||
@@ -25,20 +27,22 @@ namespace Back.Controllers
|
||||
private readonly servTaxPayer _servTaxPayer;
|
||||
private readonly servReport _servReport;
|
||||
private readonly IAsyncRepository<rptQueue> _rptQueueRepository;
|
||||
public InvoiceController(servInvoice servInvoice, servUser servUser
|
||||
, AddOrUpdateInvoiceValidation validationInvoice
|
||||
, servTaxPayer servTaxPayer, IConfiguration configuration
|
||||
, IAsyncRepository<rptQueue> rptQueueRepository, servReport servReport)
|
||||
private readonly RemittanceService _remittanceService;
|
||||
private readonly WarehouseService _warehouseService;
|
||||
|
||||
public InvoiceController(IConfiguration configuration, servInvoice servInvoice, servUser servUser, AddOrUpdateInvoiceValidation validationInvoice, servTaxPayer servTaxPayer, servReport servReport, IAsyncRepository<rptQueue> rptQueueRepository, RemittanceService remittanceService, WarehouseService warehouseService)
|
||||
{
|
||||
_servReport= servReport;
|
||||
_configuration = configuration;
|
||||
_servInvoice = servInvoice;
|
||||
_servUser = servUser;
|
||||
_validationInvoice = validationInvoice;
|
||||
_configuration = configuration;
|
||||
_servTaxPayer = servTaxPayer;
|
||||
_servReport = servReport;
|
||||
_rptQueueRepository = rptQueueRepository;
|
||||
|
||||
_remittanceService = remittanceService;
|
||||
_warehouseService = warehouseService;
|
||||
}
|
||||
|
||||
[HttpPost("GetAll")]
|
||||
public async Task<ActionResult<PagingDto<InvoiceGridDTO>?>> GetAll([FromBody] ItemSerchGetInvoices itemSerch)
|
||||
{
|
||||
@@ -203,6 +207,7 @@ namespace Back.Controllers
|
||||
invoice.Des = item.Des;
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
|
||||
return Ok(await _servInvoice.UpdateInvoice(invoice));
|
||||
}
|
||||
[HttpDelete("Delete/{ID}")]
|
||||
@@ -610,6 +615,63 @@ namespace Back.Controllers
|
||||
string base64= await _servReport.CreateImage(result, user?.RolUsers.First().Company.Logo==null ?"":Convert.ToBase64String(user?.RolUsers.First().Company.Logo), user?.RolUsers.First().Company.Name);
|
||||
return Ok(base64);
|
||||
}
|
||||
|
||||
[HttpPost("IssuingRemittance/{InvoiceID}")]
|
||||
public async Task<ActionResult<string>> IssuingRemittance(int InvoiceID)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
var CompanyID = user?.RolUsers.First().CompanyID;
|
||||
|
||||
if (!await _servInvoice.ExistInvoiceByInvoiceID(CompanyID.Value, InvoiceID))
|
||||
return NotFound();
|
||||
|
||||
if (await _remittanceService.HasaRemittance(InvoiceID))
|
||||
{
|
||||
return BadRequest(new List<string>() { "این صورتحساب حواله دارد" });
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> errors = new List<string>();
|
||||
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID);
|
||||
//check
|
||||
foreach (var item in result.items
|
||||
.GroupBy(i => i.CODID).Select(g => new { CODID = g.Key,TotalAm = g.Sum(i => i.am) }))
|
||||
{
|
||||
var Inventory =await _warehouseService.Inventory(CompanyID.Value, item.CODID);
|
||||
if (Inventory - item.TotalAm <= 0 )
|
||||
{
|
||||
errors.Add($"مقدار کالا {item.CODID} کمتر از درخواست شماست");
|
||||
}
|
||||
}
|
||||
if (errors.Count==0)
|
||||
{
|
||||
//save
|
||||
await _remittanceService.AddRange(result.items.Select(s => new Data.Models.Warehouse.Remittance()
|
||||
{
|
||||
CODID = s.CODID,
|
||||
Count = s.am,
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
info = $"حواله خودکار از صورتحساب {InvoiceID}",
|
||||
Type = TypeRemittance.Sale,
|
||||
InvoiceID = InvoiceID,
|
||||
Deleted = false,
|
||||
}).ToList());
|
||||
return Ok();
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(errors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using Back.Common;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Validations;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -21,6 +22,7 @@ namespace Back.Controllers
|
||||
private readonly servUser _servUser;
|
||||
private readonly AUInvoiceItemValidation _validationInvoiceItem;
|
||||
private readonly servInvoice _servInvoice;
|
||||
private readonly RemittanceService _remittanceService;
|
||||
public InvoiceItemController(servInvoiceItem servInvoiceItem, AUInvoiceItemValidation validationInvoiceItem
|
||||
, servUser servUser, servInvoice servInvoice)
|
||||
{
|
||||
@@ -31,7 +33,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpPost("AddItem")]
|
||||
public async Task<ActionResult<bool>> AddItem([FromBody]InvoiceItemAction<InvoiceItemDTO> model)
|
||||
public async Task<ActionResult<bool>> AddItem([FromBody] InvoiceItemAction<InvoiceItemDTO> model)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -48,7 +50,7 @@ namespace Back.Controllers
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.Repair)
|
||||
if (invoice.invoiceType == InvoiceType.Repair)
|
||||
{
|
||||
return BadRequest(new List<string> { "امکان افزودن کالا جدید در صورتحساب اصلاحی وجود ندارد" });
|
||||
}
|
||||
@@ -61,14 +63,21 @@ namespace Back.Controllers
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(model.invoiceID, model.item.CODID))
|
||||
{
|
||||
//check mojodi
|
||||
//add
|
||||
}
|
||||
|
||||
|
||||
return Ok(await _servInvoiceItem.Add(new InvoiceItem
|
||||
{
|
||||
am=model.item.am,
|
||||
fee=model.item.fee,
|
||||
dis=model.item.dis,
|
||||
CODID=model.item.CODID,
|
||||
InvoiceID=model.invoiceID,
|
||||
|
||||
am = model.item.am,
|
||||
fee = model.item.fee,
|
||||
dis = model.item.dis,
|
||||
CODID = model.item.CODID,
|
||||
InvoiceID = model.invoiceID,
|
||||
|
||||
}));
|
||||
}
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
@@ -89,10 +98,10 @@ namespace Back.Controllers
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
{
|
||||
if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale
|
||||
@@ -100,14 +109,14 @@ namespace Back.Controllers
|
||||
{
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var invoiceitem=await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, model.invoiceID, model.item.ID.Value);
|
||||
|
||||
|
||||
var invoiceitem = await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, model.invoiceID, model.item.ID.Value);
|
||||
if (invoiceitem == null)
|
||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
@@ -139,13 +148,13 @@ namespace Back.Controllers
|
||||
}
|
||||
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.BackFrmSale && invoiceitem.am < model.item.am)
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale && invoiceitem.am < model.item.am)
|
||||
return BadRequest(new List<string> { "در صورتحساب برگشت از فروش تعداد آیتم فقط میتواند کاهشی باشد" });
|
||||
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
invoiceitem.am = model.item.am;
|
||||
invoiceitem.am = model.item.am;
|
||||
else
|
||||
{
|
||||
invoiceitem.am = model.item.am;
|
||||
@@ -155,8 +164,16 @@ namespace Back.Controllers
|
||||
}
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
return Ok(await _servInvoiceItem.Update(invoiceitem));
|
||||
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(invoiceitem.invoice.ID, invoiceitem.CODID))
|
||||
{
|
||||
await _remittanceService.DeleteByInvoiceIDandCODID(invoiceitem.invoice.ID, invoiceitem.CODID);
|
||||
//check mojodi
|
||||
//add
|
||||
}
|
||||
return Ok(await _servInvoiceItem.Update(invoiceitem));
|
||||
}
|
||||
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
|
||||
|
||||
@@ -176,13 +193,13 @@ namespace Back.Controllers
|
||||
return NotFound(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceitem.InvoiceID.Value, new InvoiceItemDTO(), eActionValidation.delete)) ;
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceitem.InvoiceID.Value, new InvoiceItemDTO(), eActionValidation.delete));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
||||
|
||||
if (invoiceitem.invoice.invoiceType == InvoiceType.Repair )
|
||||
if (invoiceitem.invoice.invoiceType == InvoiceType.Repair)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب اصلاجی نمیتوان کالا را حذف کذد" });
|
||||
}
|
||||
@@ -192,16 +209,21 @@ namespace Back.Controllers
|
||||
}
|
||||
invoiceitem.invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
|
||||
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoiceitem.invoice))
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(invoiceitem.invoice.ID, invoiceitem.CODID))
|
||||
await _remittanceService.DeleteByInvoiceIDandCODID(invoiceitem.invoice.ID, invoiceitem.CODID);
|
||||
|
||||
return Ok(await _servInvoiceItem.Delete(invoiceitem));
|
||||
}
|
||||
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Common;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Validations.Warehouse.Receipt;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -17,6 +19,19 @@ namespace Back.Controllers.Warehouse
|
||||
{
|
||||
private readonly ReceiptService _receiptService;
|
||||
private readonly servUser _servUser;
|
||||
private readonly ADDValidation _addvalidation;
|
||||
private readonly UpdateValidation _updatevalidation;
|
||||
private readonly DeleteValidation _deletevalidation;
|
||||
|
||||
public ReceiptController(ReceiptService receiptService, servUser servUser, ADDValidation addvalidation, UpdateValidation updatevalidation, DeleteValidation deletevalidation)
|
||||
{
|
||||
_receiptService = receiptService;
|
||||
_servUser = servUser;
|
||||
_addvalidation = addvalidation;
|
||||
_updatevalidation = updatevalidation;
|
||||
_deletevalidation = deletevalidation;
|
||||
}
|
||||
|
||||
[HttpGet("{ItemID}")]
|
||||
public async Task<IActionResult> Get(int ItemID)
|
||||
{
|
||||
@@ -38,8 +53,19 @@ namespace Back.Controllers.Warehouse
|
||||
[HttpPost("ADD")]
|
||||
public async Task<IActionResult> AddReceipt(ReceiptDto item)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _addvalidation.ValidateAsync(Tuple.Create(item,CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
||||
// validate ADD
|
||||
var newmodel = await _receiptService.ADD(item);
|
||||
var newmodel = await _receiptService.ADD(item, CompanyID);
|
||||
if (newmodel != null) return Ok(newmodel);
|
||||
else return BadRequest(new List<string> { "خطا در صدور" });
|
||||
}
|
||||
@@ -47,7 +73,16 @@ namespace Back.Controllers.Warehouse
|
||||
[HttpPut("Update")]
|
||||
public async Task<IActionResult> UpdateReceipt(ReceiptDto item)
|
||||
{
|
||||
// validate Update
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _updatevalidation.ValidateAsync(Tuple.Create(item, CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
var Updatemodel = await _receiptService.Update(item);
|
||||
if (Updatemodel != null) return Ok(Updatemodel);
|
||||
else return BadRequest(new List<string> { "خطا در ویرایش" });
|
||||
@@ -61,6 +96,11 @@ namespace Back.Controllers.Warehouse
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _deletevalidation.ValidateAsync(Tuple.Create(ItemID, CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
var Deletemodel = await _receiptService.Delete(ItemID, CompanyID);
|
||||
if (Deletemodel) return Ok();
|
||||
else return BadRequest(new List<string> { "خطا در حذف" });
|
||||
|
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
using Back.Validations.Warehouse.Remittance;
|
||||
|
||||
namespace Back.Controllers.Warehouse
|
||||
{
|
||||
@@ -13,6 +14,20 @@ namespace Back.Controllers.Warehouse
|
||||
{
|
||||
private readonly RemittanceService _treanceService;
|
||||
private readonly servUser _servUser;
|
||||
|
||||
private readonly ADDValidation _addvalidation;
|
||||
private readonly UpdateValidation _updatevalidation;
|
||||
private readonly DeleteValidation _deletevalidation;
|
||||
|
||||
public RemittanceController(RemittanceService treanceService, servUser servUser, ADDValidation addvalidation, UpdateValidation updatevalidation, DeleteValidation deletevalidation)
|
||||
{
|
||||
_treanceService = treanceService;
|
||||
_servUser = servUser;
|
||||
_addvalidation = addvalidation;
|
||||
_updatevalidation = updatevalidation;
|
||||
_deletevalidation = deletevalidation;
|
||||
}
|
||||
|
||||
[HttpGet("{ItemID}")]
|
||||
public async Task<IActionResult> Get(int ItemID)
|
||||
{
|
||||
@@ -34,7 +49,17 @@ namespace Back.Controllers.Warehouse
|
||||
[HttpPost("ADD")]
|
||||
public async Task<IActionResult> Add(RemittanceDto item)
|
||||
{
|
||||
// validate ADD
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _addvalidation.ValidateAsync(Tuple.Create(item, CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
||||
var newmodel = await _treanceService.ADD(item);
|
||||
if (newmodel != null) return Ok(newmodel);
|
||||
else return BadRequest(new List<string> { "خطا در صدور" });
|
||||
@@ -43,7 +68,16 @@ namespace Back.Controllers.Warehouse
|
||||
[HttpPut("Update")]
|
||||
public async Task<IActionResult> Update(RemittanceDto item)
|
||||
{
|
||||
// validate Update
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _updatevalidation.ValidateAsync(Tuple.Create(item, CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
var Updatemodel = await _treanceService.Update(item);
|
||||
if (Updatemodel != null) return Ok(Updatemodel);
|
||||
else return BadRequest(new List<string> { "خطا در ویرایش" });
|
||||
@@ -57,6 +91,11 @@ namespace Back.Controllers.Warehouse
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _deletevalidation.ValidateAsync(Tuple.Create(ItemID, CompanyID));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
var Deletemodel = await _treanceService.Delete(ItemID, CompanyID);
|
||||
if (Deletemodel) return Ok();
|
||||
else return BadRequest(new List<string> { "خطا در حذف" });
|
||||
|
@@ -9,12 +9,13 @@ namespace Back.Data.Models.Warehouse
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool ForSale { get; set; }
|
||||
public TypeReceipt Type { get; set; }
|
||||
public string info { get; set; }
|
||||
|
||||
public bool Deleted { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
[ForeignKey("CODID")]
|
||||
public CODItem cODItem { get; set; }
|
||||
}
|
||||
|
@@ -9,10 +9,12 @@ namespace Back.Data.Models.Warehouse
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public TypeRemittance Type { get; set; }
|
||||
public string info { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
[ForeignKey("CODID")]
|
||||
public CODItem cODItem { get; set; }
|
||||
|
@@ -88,6 +88,14 @@ builder.Services.AddScoped<ReceiptService>();
|
||||
builder.Services.AddScoped<RemittanceService>();
|
||||
builder.Services.AddScoped<WarehouseService>();
|
||||
builder.Services.AddScoped<servReport>();
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Receipt.ADDValidation>();
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Receipt.UpdateValidation>();
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Receipt.DeleteValidation>();
|
||||
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Remittance.ADDValidation>();
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Remittance.UpdateValidation>();
|
||||
builder.Services.AddScoped<Back.Validations.Warehouse.Remittance.DeleteValidation>();
|
||||
|
||||
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
|
||||
|
||||
string origins = "OriginTaxPayer";
|
||||
|
@@ -216,6 +216,7 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
#endregion
|
||||
//--------Tax---------
|
||||
#region TaxPayer
|
||||
public async Task<bool> AllowSendTaxPayerInCompany(int CompanyID)
|
||||
{
|
||||
@@ -236,5 +237,14 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
#endregion
|
||||
//--------Invoice---------
|
||||
#region Warehouse
|
||||
public async Task<bool> AllowAddReceiptInCompany(int CompanyID, int Allowednumber = 1)
|
||||
{
|
||||
int PermissionID = 18;
|
||||
return await AllowPermissionInCompany(CompanyID, PermissionID, Allowednumber);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -10,33 +10,51 @@ namespace Back.Services.Warehouse
|
||||
public class ReceiptService
|
||||
{
|
||||
private readonly IAsyncRepository<Receipt> _ReceiptRepo;
|
||||
private readonly CheckPermission _checkPermission;
|
||||
|
||||
public ReceiptService(IAsyncRepository<Receipt> ReceiptRepo)
|
||||
public ReceiptService(IAsyncRepository<Receipt> receiptRepo, CheckPermission checkPermission)
|
||||
{
|
||||
_ReceiptRepo = ReceiptRepo;
|
||||
_ReceiptRepo = receiptRepo;
|
||||
_checkPermission = checkPermission;
|
||||
}
|
||||
|
||||
public async Task<ReceiptDto?> ADD(ReceiptDto item)
|
||||
public async Task<ReceiptDto?> ADD(ReceiptDto item, int CompanyID)
|
||||
{
|
||||
var model = new Receipt()
|
||||
try
|
||||
{
|
||||
Date = item.Date,
|
||||
CODID = item.CODID,
|
||||
Count = item.Count,
|
||||
ForSale = item.ForSale,
|
||||
info = item.info,
|
||||
Type = item.Type,
|
||||
};
|
||||
var returnmodel = await _ReceiptRepo.AddAsync(model);
|
||||
if (returnmodel!=null)
|
||||
{
|
||||
item.ID= returnmodel.ID;
|
||||
return item;
|
||||
if (await _checkPermission.ExtensionofAccess(CompanyID, 18, "-1"))
|
||||
{
|
||||
var model = new Receipt()
|
||||
{
|
||||
Date = item.Date,
|
||||
CODID = item.CODID,
|
||||
Count = item.Count,
|
||||
ForSale = item.ForSale,
|
||||
info = item.info,
|
||||
Type = item.Type,
|
||||
Deleted = false
|
||||
};
|
||||
var returnmodel = await _ReceiptRepo.AddAsync(model);
|
||||
if (returnmodel != null)
|
||||
{
|
||||
item.ID = returnmodel.ID;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<ReceiptDto?> Update(ReceiptDto item)
|
||||
{
|
||||
@@ -60,13 +78,13 @@ namespace Back.Services.Warehouse
|
||||
public async Task<bool> Delete(int itemID,int CompanyID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID==CompanyID).FirstOrDefaultAsync();
|
||||
model.Deleted= true;
|
||||
return await _ReceiptRepo.UpdateAsync(model);
|
||||
|
||||
return await _ReceiptRepo.DeleteAsync(model);
|
||||
|
||||
}
|
||||
public async Task<ReceiptDto?> Get(int itemID, int CompanyID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID)
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Include(inc=>inc.cODItem)
|
||||
.Select(s=>new ReceiptDto()
|
||||
{
|
||||
@@ -87,7 +105,7 @@ namespace Back.Services.Warehouse
|
||||
}
|
||||
public async Task<List<ReceiptDto>?> GetAll(int CompanyID, TypeReceipt? Type=null, int CODID=0)
|
||||
{
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID);
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted);
|
||||
if (Type != null)
|
||||
request = request.Where(w => w.Type == Type);
|
||||
|
||||
|
@@ -24,6 +24,7 @@ namespace Back.Services.Warehouse
|
||||
Count = item.Count,
|
||||
info = item.info,
|
||||
Type = item.Type,
|
||||
Deleted=false
|
||||
};
|
||||
var returnmodel = await _ReceiptRepo.AddAsync(model);
|
||||
if (returnmodel != null)
|
||||
@@ -36,6 +37,10 @@ namespace Back.Services.Warehouse
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task AddRange(List<Remittance> items)
|
||||
{
|
||||
await _ReceiptRepo.AddRangeAsync(items);
|
||||
}
|
||||
public async Task<RemittanceDto?> Update(RemittanceDto item)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync();
|
||||
@@ -44,6 +49,7 @@ namespace Back.Services.Warehouse
|
||||
model.Count = item.Count;
|
||||
model.info = item.info;
|
||||
model.Type = item.Type;
|
||||
|
||||
var returnmodel = await _ReceiptRepo.UpdateAsync(model);
|
||||
if (returnmodel)
|
||||
{
|
||||
@@ -56,14 +62,14 @@ namespace Back.Services.Warehouse
|
||||
}
|
||||
public async Task<bool> Delete(int itemID, int CompanyID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID).FirstOrDefaultAsync();
|
||||
|
||||
return await _ReceiptRepo.DeleteAsync(model);
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID && !w.Deleted).FirstOrDefaultAsync();
|
||||
model.Deleted = true;
|
||||
return await _ReceiptRepo.UpdateAsync(model);
|
||||
|
||||
}
|
||||
public async Task<RemittanceDto?> Get(int itemID, int CompanyID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID)
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Include(inc => inc.cODItem)
|
||||
.Select(s => new RemittanceDto()
|
||||
{
|
||||
@@ -83,7 +89,7 @@ namespace Back.Services.Warehouse
|
||||
}
|
||||
public async Task<List<RemittanceDto>?> GetAll(int CompanyID, TypeRemittance? Type = null, int CODID = 0)
|
||||
{
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID);
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted);
|
||||
if (Type != null)
|
||||
request = request.Where(w => w.Type == Type);
|
||||
|
||||
@@ -108,6 +114,20 @@ namespace Back.Services.Warehouse
|
||||
|
||||
|
||||
}
|
||||
public async Task<bool> HasaRemittance(int InvoiceID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && !w.Deleted).AnyAsync();
|
||||
}
|
||||
public async Task<bool> HasaRemittance(int InvoiceID,int CODID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.CODID==CODID && !w.Deleted).AnyAsync();
|
||||
}
|
||||
public async Task DeleteByInvoiceIDandCODID(int InvoiceID, int CODID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.CODID == CODID && !w.Deleted).FirstOrDefaultAsync();
|
||||
model.Deleted = true;
|
||||
await _ReceiptRepo.UpdateAsync(model);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ namespace Back.Services.Warehouse
|
||||
}
|
||||
public async Task<PagingDto<CirculationDto>> Circulation(int CompanyID,string date="",int CODID=0,int PageIndex=1,int PageSize=5)
|
||||
{
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Select(s=>new CirculationDto
|
||||
{
|
||||
CODID=s.CODID,
|
||||
@@ -42,7 +42,7 @@ namespace Back.Services.Warehouse
|
||||
if (CODID!=0)
|
||||
RequestRemittance = RequestRemittance.Where(w => w.CODID == CODID);
|
||||
//-----------
|
||||
var RequestReceipt = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
var RequestReceipt = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Select(s => new CirculationDto
|
||||
{
|
||||
CODID = s.CODID,
|
||||
@@ -64,10 +64,10 @@ namespace Back.Services.Warehouse
|
||||
//list.AddRange(await RequestRemittance.ToListAsync());
|
||||
//return await list.OrderByDescending(o=>o.Date).AsQueryable().Paging(PageIndex, PageSize);
|
||||
}
|
||||
public async Task<int> Inventory(int CompanyID,int CODID)
|
||||
public async Task<decimal> Inventory(int CompanyID,int CODID)
|
||||
{
|
||||
var CReceipt=await _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && w.CODID == CODID && w.ForSale ).SumAsync(s => s.Count);
|
||||
var CRemittance=await _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID && w.CODID == CODID ).SumAsync(s => s.Count);
|
||||
var CReceipt=await _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && w.CODID == CODID && w.ForSale && !w.Deleted).SumAsync(s => s.Count);
|
||||
var CRemittance=await _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID && w.CODID == CODID && !w.Deleted).SumAsync(s => s.Count);
|
||||
return CReceipt - CRemittance;
|
||||
}
|
||||
}
|
||||
|
45
Back/Validations/Warehouse/Receipt/ADDValidation.cs
Normal file
45
Back/Validations/Warehouse/Receipt/ADDValidation.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Back.Data.Contracts;
|
||||
using FluentValidation;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Net.Pkcs11Interop.Common;
|
||||
using Back.Services;
|
||||
using Back.Data.Models;
|
||||
|
||||
namespace Back.Validations.Warehouse.Receipt
|
||||
{
|
||||
public class ADDValidation : AbstractValidator<Tuple<ReceiptDto,int>>
|
||||
{
|
||||
public ADDValidation(ServCOD servCOD, CheckPermission checkPermission)
|
||||
{
|
||||
// کالا مدنظر برای شرکت است
|
||||
CascadeMode = CascadeMode.Stop;
|
||||
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) => {
|
||||
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
|
||||
context.AddFailure("کد کالا یافت نشد");
|
||||
});
|
||||
|
||||
|
||||
RuleFor(model => model.Item1.Count)
|
||||
.Custom((model, context) => {
|
||||
if (model <= 0)
|
||||
context.AddFailure("تعداد نمیتواند صفر یا کمتر از صفر باشد");
|
||||
});
|
||||
|
||||
RuleFor(model => model.Item1.info)
|
||||
.Custom((model, context) => {
|
||||
if (string.IsNullOrEmpty(model))
|
||||
context.AddFailure("توضیحی برای رسید در نظر بگیرید");
|
||||
});
|
||||
|
||||
RuleFor(r => r.Item2)
|
||||
.Custom((CompanyID, context) =>
|
||||
{
|
||||
if (!checkPermission.AllowAddReceiptInCompany(CompanyID).Result)
|
||||
context.AddFailure("اضافه کردن رسید محدود شده است");
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
30
Back/Validations/Warehouse/Receipt/DeleteValidation.cs
Normal file
30
Back/Validations/Warehouse/Receipt/DeleteValidation.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using FluentValidation;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Back.Validations.Warehouse.Receipt
|
||||
{
|
||||
public class DeleteValidation : AbstractValidator<Tuple<int, int>>
|
||||
{
|
||||
public DeleteValidation(IAsyncRepository<Back.Data.Models.Warehouse.Receipt> _ReceiptRepo, WarehouseService warehouseService)
|
||||
{
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) =>
|
||||
{
|
||||
var ORGitem = _ReceiptRepo.Get(w => w.ID == model.Item1 && w.cODItem.CompanyID == model.Item2 && !w.Deleted).Include(i => i.cODItem).FirstOrDefault();
|
||||
if (ORGitem == null)
|
||||
context.AddFailure("رسید یافت نشد");
|
||||
|
||||
var Inventory = warehouseService.Inventory(model.Item2, ORGitem.CODID).Result;
|
||||
if (Inventory - ORGitem.Count < 0)
|
||||
{
|
||||
context.AddFailure($"حذف رسید روی موجودی کالا {ORGitem.cODItem.Title} تاثیر میگذارد و آن را منفی میکند");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
78
Back/Validations/Warehouse/Receipt/UpdateValidation.cs
Normal file
78
Back/Validations/Warehouse/Receipt/UpdateValidation.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Shared.DTOs.Warehouse;
|
||||
|
||||
namespace Back.Validations.Warehouse.Receipt
|
||||
{
|
||||
public class UpdateValidation : AbstractValidator<Tuple<ReceiptDto, int>>
|
||||
{
|
||||
public UpdateValidation(IAsyncRepository<Back.Data.Models.Warehouse.Receipt> _ReceiptRepo, ServCOD servCOD, WarehouseService warehouseService)
|
||||
{
|
||||
CascadeMode = CascadeMode.Stop;
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) =>
|
||||
{
|
||||
var ORGitem = _ReceiptRepo.Get(w => w.ID == model.Item1.ID && !w.Deleted).Include(i => i.cODItem).FirstOrDefault();
|
||||
if (ORGitem.InvoiceID.HasValue)
|
||||
{
|
||||
context.AddFailure("رسید فاکتور قایل ویرایش نیست");
|
||||
return;
|
||||
}
|
||||
if (ORGitem == null)
|
||||
context.AddFailure("رسید یافت نشد");
|
||||
else
|
||||
{
|
||||
if (ORGitem.CODID != model.Item1.CODID)
|
||||
{
|
||||
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
|
||||
context.AddFailure("کد کالا یافت نشد");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ORGitem.CODID != model.Item1.CODID)
|
||||
{
|
||||
|
||||
context.AddFailure("در رسید امکان ویرایش کالا انکان پذیر نیست");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ORGitem.Count > model.Item1.Count && ORGitem.ForSale && !model.Item1.ForSale) ||
|
||||
ORGitem.Count > model.Item1.Count)
|
||||
{
|
||||
var ekh = ORGitem.Count - model.Item1.Count;
|
||||
var Inventory = warehouseService.Inventory(model.Item2, ORGitem.CODID).Result;
|
||||
if ((Inventory - ekh) < 0)
|
||||
{
|
||||
context.AddFailure($"این تغییرات روی موجودی کالا {ORGitem.cODItem.Title} تاثیر میگذارد و آن را منفی میکند");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (ORGitem.ForSale && !model.Item1.ForSale)
|
||||
{
|
||||
var Inventory = warehouseService.Inventory(model.Item2, ORGitem.CODID).Result;
|
||||
if (Inventory - ORGitem.Count < 0)
|
||||
{
|
||||
context.AddFailure($"این تغییرات روی موجودی کالا {ORGitem.cODItem.Title} تاثیر میگذارد و آن را منفی میکند");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.Item1.info))
|
||||
{
|
||||
context.AddFailure("توضیحی برای رسید در نظر بگیرید");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
42
Back/Validations/Warehouse/Remittance/ADDValidation.cs
Normal file
42
Back/Validations/Warehouse/Remittance/ADDValidation.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using FluentValidation;
|
||||
using Shared.DTOs.Warehouse;
|
||||
|
||||
namespace Back.Validations.Warehouse.Remittance
|
||||
{
|
||||
public class ADDValidation : AbstractValidator<Tuple<RemittanceDto, int>>
|
||||
{
|
||||
public ADDValidation(ServCOD servCOD, WarehouseService warehouseService)
|
||||
{
|
||||
CascadeMode = CascadeMode.Stop;
|
||||
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) =>
|
||||
{
|
||||
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
|
||||
context.AddFailure("کد کالا یافت نشد");
|
||||
});
|
||||
|
||||
RuleFor(model => model.Item1.Count)
|
||||
.Custom((model, context) => {
|
||||
if (model <= 0)
|
||||
context.AddFailure("تعداد نمیتواند صفر یا کمتر از صفر باشد");
|
||||
});
|
||||
|
||||
RuleFor(model => model.Item1.info)
|
||||
.Custom((model, context) => {
|
||||
if (string.IsNullOrEmpty(model))
|
||||
context.AddFailure("توضیحی برای رسید در نظر بگیرید");
|
||||
});
|
||||
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) =>
|
||||
{
|
||||
var inv = warehouseService.Inventory(model.Item2, model.Item1.CODID).Result;
|
||||
if (inv < model.Item1.Count)
|
||||
context.AddFailure("موجودی کمتر از مقدار حواله می باشد");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
22
Back/Validations/Warehouse/Remittance/DeleteValidation.cs
Normal file
22
Back/Validations/Warehouse/Remittance/DeleteValidation.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Services.Warehouse;
|
||||
using FluentValidation;
|
||||
using Shared.DTOs.Warehouse;
|
||||
|
||||
namespace Back.Validations.Warehouse.Remittance
|
||||
{
|
||||
public class DeleteValidation : AbstractValidator<Tuple<int, int>>
|
||||
{
|
||||
public DeleteValidation(IAsyncRepository<Back.Data.Models.Warehouse.Remittance> _Repo)
|
||||
{
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) =>
|
||||
{
|
||||
var ORGitem = _Repo.Get(w => w.ID == model.Item1 && w.cODItem.CompanyID == model.Item2 && !w.Deleted).FirstOrDefault();
|
||||
if (ORGitem == null)
|
||||
context.AddFailure("حواله یافت نشد");
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
55
Back/Validations/Warehouse/Remittance/UpdateValidation.cs
Normal file
55
Back/Validations/Warehouse/Remittance/UpdateValidation.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Services;
|
||||
using FluentValidation;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Back.Validations.Warehouse.Remittance
|
||||
{
|
||||
public class UpdateValidation : AbstractValidator<Tuple<RemittanceDto, int>>
|
||||
{
|
||||
public UpdateValidation(IAsyncRepository<Back.Data.Models.Warehouse.Remittance> _Repo, ServCOD servCOD, WarehouseService warehouseService)
|
||||
{
|
||||
CascadeMode = CascadeMode.Stop;
|
||||
RuleFor(model => model)
|
||||
.Custom((model, context) => {
|
||||
var ORGitem = _Repo.Get(w => w.ID == model.Item1.ID && !w.Deleted).Include(i => i.cODItem).FirstOrDefault();
|
||||
if (ORGitem.InvoiceID.HasValue)
|
||||
{
|
||||
context.AddFailure("حواله فاکتور قایل ویرایش نیست");
|
||||
return;
|
||||
}
|
||||
if (ORGitem == null)
|
||||
context.AddFailure("حواله یافت نشد");
|
||||
else
|
||||
{
|
||||
if (ORGitem.CODID != model.Item1.CODID)
|
||||
{
|
||||
|
||||
context.AddFailure("در حئاله امکان ویرایش کالا انکان پذیر نیست");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (ORGitem.Count < model.Item1.Count))
|
||||
{
|
||||
var Inventory = warehouseService.Inventory(model.Item2, model.Item1.CODID).Result;
|
||||
if (Inventory - (model.Item1.Count - ORGitem.Count) < 0)
|
||||
{
|
||||
context.AddFailure($"این تغییرات روی موجودی کالا تاثیر میگذارد و آن را منفی میکند");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Item1.info))
|
||||
{
|
||||
context.AddFailure("توضیحی برای حواله در نظر بگیرید");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ namespace Shared.DTOs.Warehouse
|
||||
{
|
||||
public int CODID { get; set; }
|
||||
public string? CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool? ForSale { get; set; }
|
||||
public string ModelTypeTitle { get; set; }
|
||||
|
@@ -12,10 +12,11 @@ namespace Shared.DTOs.Warehouse
|
||||
public int? ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public string? CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool ForSale { get; set; }
|
||||
public TypeReceipt Type { get; set; }
|
||||
public string info { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,10 @@ namespace Shared.DTOs.Warehouse
|
||||
public int? ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public string CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public TypeRemittance Type { get; set; }
|
||||
public string info { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user