...
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Back.Controllers
|
||||
private readonly IAsyncRepository<rptQueue> _rptQueueRepository;
|
||||
private readonly RemittanceService _remittanceService;
|
||||
private readonly WarehouseService _warehouseService;
|
||||
private readonly ReceiptService _receiptService;
|
||||
|
||||
public InvoiceController(IConfiguration configuration, servInvoice servInvoice, servUser servUser, AddOrUpdateInvoiceValidation validationInvoice, servTaxPayer servTaxPayer, servReport servReport, IAsyncRepository<rptQueue> rptQueueRepository, RemittanceService remittanceService, WarehouseService warehouseService)
|
||||
{
|
||||
@@ -136,7 +137,7 @@ namespace Back.Controllers
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, item.ID.Value);
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
if (invoice.PatternID != item.PatternID && invoice.invoice!=null)
|
||||
if (invoice.PatternID != item.PatternID && invoice.invoice != null)
|
||||
{
|
||||
return BadRequest(new List<string> { "این صورتحساب دارای مرجع می باشد"+'\n'+
|
||||
"امکان تغییر الگو امکان پذیر نیست"});
|
||||
@@ -145,11 +146,11 @@ namespace Back.Controllers
|
||||
if (invoice.PatternID != item.PatternID || invoice.CustomerID != item.CustomerID)
|
||||
{
|
||||
//----Check TaxPayer
|
||||
|
||||
|
||||
if (CheckTaxPayer)
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||
else if (invoice.invoiceType == InvoiceType.BackFrmSale )
|
||||
else if (invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
{
|
||||
return BadRequest(new List<string>
|
||||
{ "صورتحساب در وضعیت برگشت از فروش امکان تغییر مشتری یا الگو را ندارد"+'\n'+
|
||||
@@ -170,10 +171,10 @@ namespace Back.Controllers
|
||||
}
|
||||
else if (invoice.InvoicIssueDate != item.InvoicIssueDate || invoice.InvoiceDate != item.InvoiceDate)
|
||||
{
|
||||
if(CheckTaxPayer)
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
if (CheckTaxPayer)
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"امکان تغییر تاریخ را ندارد"});
|
||||
else if(invoice.BillReference.HasValue)
|
||||
else if (invoice.BillReference.HasValue)
|
||||
{
|
||||
if (invoice.InvoicIssueDate != item.InvoicIssueDate && Convert.ToInt32(invoice.invoice.InvoicIssueDate) > Convert.ToInt32(item.InvoicIssueDate))
|
||||
{
|
||||
@@ -268,9 +269,27 @@ namespace Back.Controllers
|
||||
|
||||
switch (invoiceType)
|
||||
{
|
||||
//ابطال
|
||||
case 3:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
{
|
||||
await _receiptService.ADD(new Shared.DTOs.Warehouse.ReceiptDto()
|
||||
{
|
||||
CODID = item.CODID,
|
||||
Count = item.am.GetValueOrDefault(),
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
ForSale = true,
|
||||
InvoiceID = item.InvoiceID,
|
||||
Type = TypeReceipt.Shopping,
|
||||
info = $"ابطال شدن صورتحساب {item.InvoiceID}",
|
||||
|
||||
}, user.RolUsers.First().CompanyID, true);
|
||||
}
|
||||
}
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
//اصلاح
|
||||
case 2:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Repair, false);
|
||||
var result = await _servInvoice.AddInvoice(new Invoice()
|
||||
@@ -322,22 +341,30 @@ namespace Back.Controllers
|
||||
pspd = s.pspd,
|
||||
cui = s.cui,
|
||||
}).ToList(),
|
||||
payments=Invoice.payments.Select(s=>new InvoicePayment()
|
||||
payments = Invoice.payments.Select(s => new InvoicePayment()
|
||||
{
|
||||
acn=s.acn,
|
||||
iinn=s.iinn,
|
||||
PaymentDateTime=s.PaymentDateTime,
|
||||
pcn=s.pcn,
|
||||
pid=s.pid,
|
||||
pmt=s.pmt,
|
||||
pv=s.pv,
|
||||
trmn=s.trmn,
|
||||
trn=s.trn,
|
||||
acn = s.acn,
|
||||
iinn = s.iinn,
|
||||
PaymentDateTime = s.PaymentDateTime,
|
||||
pcn = s.pcn,
|
||||
pid = s.pid,
|
||||
pmt = s.pmt,
|
||||
pv = s.pv,
|
||||
trmn = s.trmn,
|
||||
trn = s.trn,
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result > 0)
|
||||
{
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
await _remittanceService.ChangeRemittance(Invoice.ID, item.CODID, result);
|
||||
}
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result));
|
||||
}
|
||||
break;
|
||||
//برگشت
|
||||
case 4:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.BackFrmSale, false);
|
||||
var result1 = await _servInvoice.AddInvoice(new Invoice()
|
||||
@@ -403,7 +430,14 @@ namespace Back.Controllers
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result1 > 0)
|
||||
{
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
await _remittanceService.ChangeRemittance(Invoice.ID, item.CODID, result1);
|
||||
}
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -415,6 +449,23 @@ namespace Back.Controllers
|
||||
switch (invoiceType)
|
||||
{
|
||||
case 3:
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
{
|
||||
await _receiptService.ADD(new Shared.DTOs.Warehouse.ReceiptDto()
|
||||
{
|
||||
CODID = item.CODID,
|
||||
Count = item.am.GetValueOrDefault(),
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
ForSale = true,
|
||||
InvoiceID = item.InvoiceID,
|
||||
Type = TypeReceipt.Shopping,
|
||||
info = $"ابطال شدن صورتحساب {item.InvoiceID}",
|
||||
|
||||
}, user.RolUsers.First().CompanyID, true);
|
||||
}
|
||||
}
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
|
||||
case 4:
|
||||
@@ -482,7 +533,14 @@ namespace Back.Controllers
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result2 > 0)
|
||||
{
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
await _remittanceService.ChangeRemittance(Invoice.ID, item.CODID, result2);
|
||||
}
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -495,6 +553,23 @@ namespace Back.Controllers
|
||||
switch (invoiceType)
|
||||
{
|
||||
case 3:
|
||||
foreach (var item in Invoice.invoiceDetails)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(Invoice.ID, item.CODID))
|
||||
{
|
||||
await _receiptService.ADD(new Shared.DTOs.Warehouse.ReceiptDto()
|
||||
{
|
||||
CODID = item.CODID,
|
||||
Count = item.am.GetValueOrDefault(),
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
ForSale = true,
|
||||
InvoiceID = item.InvoiceID,
|
||||
Type = TypeReceipt.Shopping,
|
||||
info = $"ابطال شدن صورتحساب {item.InvoiceID}",
|
||||
|
||||
}, user.RolUsers.First().CompanyID, true);
|
||||
}
|
||||
}
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
@@ -547,7 +622,7 @@ namespace Back.Controllers
|
||||
scc = Invoice.scc,
|
||||
scln = Invoice.scln,
|
||||
seventeentax = Invoice.seventeentax,
|
||||
tinc = Invoice.tinc,
|
||||
tinc = Invoice.tinc,
|
||||
invoiceDetails = Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
@@ -566,11 +641,11 @@ namespace Back.Controllers
|
||||
olam = s.olam,
|
||||
olr = s.olr,
|
||||
olt = s.olt,
|
||||
spro=s.spro,
|
||||
spro = s.spro,
|
||||
sscv = s.sscv,
|
||||
ssrv = s.ssrv,
|
||||
pspd= s.pspd,
|
||||
cui= s.cui,
|
||||
pspd = s.pspd,
|
||||
cui = s.cui,
|
||||
}).ToList(),
|
||||
payments = Invoice.payments.Select(s => new InvoicePayment()
|
||||
{
|
||||
@@ -610,9 +685,9 @@ namespace Back.Controllers
|
||||
if (!await _servInvoice.ExistInvoiceByInvoiceID(CompanyID.Value, InvoiceID))
|
||||
return NotFound();
|
||||
|
||||
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,InvoiceID);
|
||||
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID);
|
||||
|
||||
string base64= await _servReport.CreateImage(result, user?.RolUsers.First().Company.Logo==null ?"":Convert.ToBase64String(user?.RolUsers.First().Company.Logo), user?.RolUsers.First().Company.Name);
|
||||
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}")]
|
||||
@@ -636,17 +711,21 @@ namespace Back.Controllers
|
||||
{
|
||||
List<string> errors = new List<string>();
|
||||
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID);
|
||||
if (result.invoiceType == InvoiceType.Bidding || result.invoiceType == InvoiceType.Cancellation)
|
||||
{
|
||||
return BadRequest(new List<string>() { $"در وضعیت {result.invoiceType.GetEnumDisplayName()} امکان صدور حواله ممکن نیست" });
|
||||
}
|
||||
//check
|
||||
foreach (var item in result.items
|
||||
.GroupBy(i => i.CODID).Select(g => new { CODID = g.Key,TotalAm = g.Sum(i => i.am) }))
|
||||
.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 )
|
||||
var Inventory = await _warehouseService.Inventory(CompanyID.Value, item.CODID);
|
||||
if (Inventory - item.TotalAm <= 0)
|
||||
{
|
||||
errors.Add($"موجودی کالا {item.CODID} کمتر از درخواست شماست");
|
||||
}
|
||||
}
|
||||
if (errors.Count==0)
|
||||
if (errors.Count == 0)
|
||||
{
|
||||
//save
|
||||
await _remittanceService.AddRange(result.items.Select(s => new Data.Models.Warehouse.Remittance()
|
||||
@@ -665,13 +744,31 @@ namespace Back.Controllers
|
||||
{
|
||||
return BadRequest(errors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
[HttpGet("HasaRemittance/{InvoiceID}")]
|
||||
public async Task<ActionResult> HasaRemittance(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 NotFound();
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,13 +66,16 @@ namespace Back.Controllers
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
{
|
||||
|
||||
//check mojodi
|
||||
//add
|
||||
|
||||
//check mojodi
|
||||
//add
|
||||
var lastitemCOD= invoice.invoiceDetails.OrderByDescending(o => o.ID).Select(s => s.CODID).FirstOrDefault();
|
||||
if (lastitemCOD!=null && lastitemCOD!=0 && await _remittanceService.HasaRemittance(invoice.ID, lastitemCOD))
|
||||
{
|
||||
var inv = await _warehouseService.Inventory(user.RolUsers.First().CompanyID, model.item.CODID);
|
||||
if (inv- model.item.am <= 0)
|
||||
if (inv - model.item.am <= 0)
|
||||
{
|
||||
return BadRequest(new List<string> { "موجودی کالا کمتر از درخواست شماست" });
|
||||
return BadRequest(new List<string> { "موجودی کالا کمتر از درخواست شماست" });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,22 +88,22 @@ namespace Back.Controllers
|
||||
InvoiceID = model.invoiceID,
|
||||
Type = TypeRemittance.Sale
|
||||
});
|
||||
|
||||
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,
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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,
|
||||
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
|
||||
@@ -186,16 +189,30 @@ namespace Back.Controllers
|
||||
}
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(invoiceitem.invoice.ID, invoiceitem.CODID))
|
||||
await _remittanceService.DeleteByInvoiceIDandCODID(invoiceitem.invoice.ID, invoiceitem.CODID);
|
||||
{
|
||||
if (invoiceitem.am != model.item.am || invoiceitem.CODID != model.item.CODID)
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(invoiceitem.invoice.ID, invoiceitem.CODID))
|
||||
{
|
||||
var inv = await _warehouseService.Inventory(user.RolUsers.First().CompanyID, model.item.CODID);
|
||||
if (inv - model.item.am <= 0)
|
||||
return BadRequest(new List<string> { "موجودی کالا کمتر از درخواست شماست" });
|
||||
else await _remittanceService.DeleteByInvoiceIDandCODID(invoiceitem.invoice.ID, invoiceitem.CODID);
|
||||
|
||||
var inv = await _warehouseService.Inventory(user.RolUsers.First().CompanyID, model.item.CODID);
|
||||
if (inv - model.item.am <= 0)
|
||||
return BadRequest(new List<string> { "موجودی کالا کمتر از درخواست شماست" });
|
||||
|
||||
else
|
||||
return Ok(await _servInvoiceItem.Update(invoiceitem));
|
||||
// حواله جئدید
|
||||
await _remittanceService.ADD(new Shared.DTOs.Warehouse.RemittanceDto()
|
||||
{
|
||||
CODID = model.item.CODID,
|
||||
Count = model.item.am,
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
info = $"حواله خودکار از صورتحساب {invoiceitem.invoice.ID}",
|
||||
Type = TypeRemittance.Sale,
|
||||
InvoiceID = invoiceitem.invoice.ID
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
return Ok(await _servInvoiceItem.Update(invoiceitem));
|
||||
}
|
||||
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
@@ -239,7 +256,7 @@ namespace Back.Controllers
|
||||
{
|
||||
if (await _remittanceService.HasaRemittance(invoiceitem.invoice.ID, invoiceitem.CODID))
|
||||
await _remittanceService.DeleteByInvoiceIDandCODID(invoiceitem.invoice.ID, invoiceitem.CODID);
|
||||
|
||||
|
||||
return Ok(await _servInvoiceItem.Delete(invoiceitem));
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Back.Controllers.Warehouse
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class WarehouseController : ControllerBase
|
||||
{
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Identity.Client;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
|
||||
@@ -18,11 +19,11 @@ namespace Back.Services.Warehouse
|
||||
_checkPermission = checkPermission;
|
||||
}
|
||||
|
||||
public async Task<ReceiptDto?> ADD(ReceiptDto item, int CompanyID)
|
||||
public async Task<ReceiptDto?> ADD(ReceiptDto item, int CompanyID,bool IneffectiveinAccounting=false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await _checkPermission.ExtensionofAccess(CompanyID, 18, "-1"))
|
||||
if (IneffectiveinAccounting || await _checkPermission.ExtensionofAccess(CompanyID, 18, "-1"))
|
||||
{
|
||||
var model = new Receipt()
|
||||
{
|
||||
|
@@ -122,6 +122,17 @@ namespace Back.Services.Warehouse
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.CODID==CODID && !w.Deleted).AnyAsync();
|
||||
}
|
||||
public async Task<bool> ChangeRemittance(int InvoiceID, int CODID,int newnvoceID)
|
||||
{
|
||||
var item= await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.CODID == CODID && !w.Deleted).FirstOrDefaultAsync();
|
||||
if (item!=null)
|
||||
{
|
||||
item.InvoiceID = newnvoceID;
|
||||
item.info = $"حواله خودکار از صورتحساب {newnvoceID}";
|
||||
return await _ReceiptRepo.UpdateAsync(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public async Task DeleteByInvoiceIDandCODID(int InvoiceID, int CODID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.CODID == CODID && !w.Deleted).FirstOrDefaultAsync();
|
||||
|
@@ -28,6 +28,7 @@ namespace Back.Services.Warehouse
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Select(s=>new CirculationDto
|
||||
{
|
||||
ID= s.ID,
|
||||
CODID=s.CODID,
|
||||
CODTitle=s.cODItem.Title,
|
||||
Date=s.Date,
|
||||
@@ -45,6 +46,7 @@ namespace Back.Services.Warehouse
|
||||
var RequestReceipt = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID && !w.Deleted)
|
||||
.Select(s => new CirculationDto
|
||||
{
|
||||
ID = s.ID,
|
||||
CODID = s.CODID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
Date = s.Date,
|
||||
|
@@ -18,14 +18,23 @@ namespace Shared.DTOs.Warehouse
|
||||
}
|
||||
public class CirculationDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
[Display(Name = "کالا")]
|
||||
public string? CODTitle { get; set; }
|
||||
[Display(Name = "تعداد")]
|
||||
public decimal Count { get; set; }
|
||||
[Display(Name = "تاریخ")]
|
||||
public string Date { get; set; }
|
||||
[Display(Name = "اجازه فروش")]
|
||||
public bool? ForSale { get; set; }
|
||||
[Display(Name = "نوع")]
|
||||
public string ModelTypeTitle { get; set; }
|
||||
public int ModelTypeID { get; set; }
|
||||
[Display(Name = "توضیحات")]
|
||||
public string info { get; set; }
|
||||
public TypeCirculation Type { get; set; }
|
||||
[Display(Name = "نوع سند")]
|
||||
public string msgType { get { return Type.GetEnumDisplayName(); } }
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,214 @@
|
||||
<PageTitle>انبارداری</PageTitle>
|
||||
@page "/Warehouse"
|
||||
@using Front.Services
|
||||
@using Shared.DTOs
|
||||
@using Shared.DTOs.Warehouse
|
||||
@layout PanelLayout
|
||||
<Modal Size="ModalSize.Regular" @ref="modal" />
|
||||
@inject Fixedvalues fv;
|
||||
@inject HttpClientController hc;
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
@* search *@
|
||||
<div class="row">
|
||||
<h4 class="fw-bold py-3 mb-4">
|
||||
<span class="text-muted fw-light">سرویس ها /</span> مشتری
|
||||
</h4>
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-2">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="list-group fa-padding" style="border: 2px solid #0d6efd">
|
||||
<li class="list-group-item" data-toggle="modal" data-target="#issue">
|
||||
<div class="row g-3">
|
||||
=
|
||||
<div class="col-md-2">
|
||||
<input @bind-value="date" placeholder="تاریخ" style="text-align:center" dir="ltr" class="form-control" type="number">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<select style="text-align:center" @bind="CODID" class="form-control" aria-label="Default select example">
|
||||
<option value="0" style="color: #b5b5b5" selected>کالا ...</option>
|
||||
@if (CODrequest != null)
|
||||
{
|
||||
foreach (var item in CODrequest)
|
||||
{
|
||||
<option value="@item.ID">@item.Title</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
<Button Disabled="SpinnerVisible" @onclick="() => Load(1)" Color="ButtonColor.Primary">جستجو</Button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* action *@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="mb-2">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-auto">
|
||||
<Button Disabled="SpinnerVisible" Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="()=>Item(-1)">رسید جدید</Button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<Button Disabled="SpinnerVisible" Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="()=>Item(-2)">حواله جدید</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
<Icon Name="@alertIconName" class="me-2"></Icon>
|
||||
@alertMessage
|
||||
</Alert>
|
||||
|
||||
</div>
|
||||
@* data *@
|
||||
@if (request != null)
|
||||
{
|
||||
<LTable ModelinComponent="request?.list" OnMultipleOfThree="EventCallback.Factory.Create<int>(this,Item)" />
|
||||
@* pagination *@
|
||||
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination justify-content-center">
|
||||
@for (int page = 1; page <= request?.PageCount; page++)
|
||||
{
|
||||
if (page == PageIndex)
|
||||
{
|
||||
<li class="page-item active">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
@code {
|
||||
public bool SpinnerVisible { get; set; } = false;
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
[Parameter, SupplyParameterFromQuery]
|
||||
public int? PageIndex { get; set; }
|
||||
public Shared.DTOs.PagingDto<CirculationDto>? request { get; set; }
|
||||
private Modal modal = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
//itemSearch
|
||||
public string date { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public List<CODIdName<int>>? CODrequest { get; set; }
|
||||
}
|
||||
@functions {
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
SpinnerVisible = true;
|
||||
CODrequest = await fv.GetCODs();
|
||||
SpinnerVisible = false;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
SpinnerVisible = true;
|
||||
if (PageIndex == null) PageIndex = 1;
|
||||
await Load(PageIndex.Value);
|
||||
SpinnerVisible = false;
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Success;
|
||||
alertIconName = IconName.CheckCircleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private void ShowDangerAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Danger;
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
public async Task Load(int pi)
|
||||
{
|
||||
string query = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
query = $"date={date}&";
|
||||
|
||||
if (CODID != null && CODID != 0)
|
||||
query += $"CODID={CODID}&";
|
||||
|
||||
SpinnerVisible = true;
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get("Warehouse/Circulation?" + query + $"PageIndex={pi}&PageSize=5");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<CirculationDto>>();
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.Forbidden)
|
||||
{
|
||||
ShowDangerAlert("شما دسترسی به خواندن اطلاعات را نداربد");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
PreloadService.Hide();
|
||||
SpinnerVisible = false;
|
||||
}
|
||||
public async Task CallBackItem(ActionInResultComponent result)
|
||||
{
|
||||
|
||||
}
|
||||
public async Task Item(int ID)
|
||||
{
|
||||
//رسید جدید
|
||||
if (ID == -1)
|
||||
{
|
||||
|
||||
}
|
||||
//حواله جدید
|
||||
if (ID == -2)
|
||||
{
|
||||
|
||||
}
|
||||
if (ID >0)
|
||||
{
|
||||
request.list.Where(w=>w.i)
|
||||
}
|
||||
// var parameters = new Dictionary<string, object>();
|
||||
|
||||
// if (ID == 0) parameters.Add("Cus", new RCustomer() { ID = 0 });
|
||||
// else parameters.Add("Cus", request.list.Where(w => w.ID == ID).First().Clone());
|
||||
|
||||
// parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||
// await modal.ShowAsync<CustomerItem>(title: ID == 0 ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user