...
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -6,10 +6,12 @@ using Shared.DTOs;
|
||||
using System.Xml.Linq;
|
||||
using Back.Common;
|
||||
using Back.Validations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class CODController : ControllerBase
|
||||
{
|
||||
@@ -45,6 +47,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpGet("GetUnits")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<List<IdName<int>>>> GetUnits()
|
||||
{
|
||||
return Ok(await _servCOD.GetUnits());
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Validations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
@@ -10,6 +11,7 @@ using Shared.DTOs.Serch;
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class InvoiceController : ControllerBase
|
||||
{
|
||||
@@ -36,7 +38,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpGet("Get/{ID}")]
|
||||
public async Task<ActionResult<PagingDto<InvoiceGridDTO>?>> GetAll(int ID)
|
||||
public async Task<ActionResult<InvoiceGridDTO>?> GetAll(int ID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
|
@@ -2,6 +2,8 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Validations;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
@@ -10,6 +12,7 @@ using System.Net;
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class InvoiceItemController : ControllerBase
|
||||
{
|
||||
@@ -26,8 +29,8 @@ namespace Back.Controllers
|
||||
_servInvoice = servInvoice;
|
||||
|
||||
}
|
||||
[HttpPost("AddItem/{invoiceID}")]
|
||||
public async Task<ActionResult<bool>> AddItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
||||
[HttpPost("AddItem")]
|
||||
public async Task<ActionResult<bool>> AddItem([FromBody]InvoiceItemAction<InvoiceItemDTO> model)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -35,12 +38,12 @@ namespace Back.Controllers
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceID, model, eActionValidation.add));
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.add));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
//-----Get invoice
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, model.invoiceID);
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
@@ -51,11 +54,11 @@ namespace Back.Controllers
|
||||
{
|
||||
return Ok(await _servInvoiceItem.Add(new InvoiceItem
|
||||
{
|
||||
am=model.am,
|
||||
fee=model.fee,
|
||||
dis=model.dis,
|
||||
CODID=model.CODID,
|
||||
InvoiceID=invoiceID,
|
||||
am=model.item.am,
|
||||
fee=model.item.fee,
|
||||
dis=model.item.dis,
|
||||
CODID=model.item.CODID,
|
||||
InvoiceID=model.invoiceID,
|
||||
|
||||
}));
|
||||
}
|
||||
@@ -63,8 +66,8 @@ namespace Back.Controllers
|
||||
|
||||
|
||||
}
|
||||
[HttpPut("UpdateItem/{invoiceID}")]
|
||||
public async Task<ActionResult<bool>> UpdateItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
||||
[HttpPut("UpdateItem")]
|
||||
public async Task<ActionResult<bool>> UpdateItem([FromBody] InvoiceItemAction<InvoiceItemDTO> model)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -72,33 +75,33 @@ namespace Back.Controllers
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceID, model, eActionValidation.update));
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
//-----Get invoice
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, model.invoiceID);
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
|
||||
var invoiceitem=await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, invoiceID, model.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..." });
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.BackFrmSale && invoiceitem.am < model.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.am;
|
||||
invoiceitem.am = model.item.am;
|
||||
else
|
||||
{
|
||||
invoiceitem.am = model.am;
|
||||
invoiceitem.fee = model.fee;
|
||||
invoiceitem.dis = model.dis;
|
||||
invoiceitem.CODID = model.CODID;
|
||||
invoiceitem.am = model.item.am;
|
||||
invoiceitem.fee = model.item.fee;
|
||||
invoiceitem.dis = model.item.dis;
|
||||
invoiceitem.CODID = model.item.CODID;
|
||||
}
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
@@ -108,34 +111,32 @@ namespace Back.Controllers
|
||||
|
||||
|
||||
}
|
||||
[HttpDelete("DeleteItem/{invoiceID}/{invoiceItemID}")]
|
||||
public async Task<ActionResult<bool>> DeleteItem([FromRoute] int invoiceID, [FromRoute] int invoiceItemID)
|
||||
[HttpDelete("DeleteItem/{InvoiceItemID}")]
|
||||
public async Task<ActionResult<bool>> DeleteItem(int InvoiceItemID)
|
||||
{
|
||||
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceID, new InvoiceItemDTO(), eActionValidation.delete)) ;
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
//-----Get invoice
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
||||
if (invoice == null)
|
||||
return NotFound(new List<string> { "invoice notFound..." });
|
||||
|
||||
|
||||
var invoiceitem = await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, invoiceID, invoiceItemID);
|
||||
var invoiceitem = await _servInvoiceItem.GetInvoiceItemByInvoiceItemID(user.RolUsers.First().CompanyID, InvoiceItemID);
|
||||
if (invoiceitem == null)
|
||||
return NotFound(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
//-----Validaton
|
||||
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());
|
||||
|
||||
|
||||
|
||||
invoiceitem.invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
if (await _servInvoice.UpdateInvoice(invoiceitem.invoice))
|
||||
return Ok(await _servInvoiceItem.Delete(invoiceitem));
|
||||
|
||||
else return BadRequest(new List<string> { "خطایی رخ داده" });
|
||||
|
@@ -138,7 +138,7 @@ namespace Back.Data.Models
|
||||
}
|
||||
//مبلغ نسیه
|
||||
[MaxLength(18)]
|
||||
public decimal? insp { get; set; }
|
||||
public decimal? insp { get; set; } = 0;
|
||||
//مالیات موضوع ماده 17
|
||||
[MaxLength(18)]
|
||||
public string? seventeentax { get; set; }
|
||||
|
@@ -19,10 +19,10 @@ namespace Back.Data.Models
|
||||
// شرح کاال/خدمت
|
||||
[MaxLength(13)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public string? sstt { get { return cODItem.Title; } }
|
||||
public string? sstt { get { return cODItem != null ? cODItem.Title : null; } }
|
||||
//واحد اندازهگیری
|
||||
[MaxLength(8)]
|
||||
public string? mu { get { return cODItem.CODUnit.UnitTaxID; } }
|
||||
public string? mu { get { return cODItem != null ? cODItem.CODUnit.UnitTaxID : null; } }
|
||||
//میزان ارز
|
||||
[MaxLength(18)]
|
||||
public decimal? cfee { get { return fee / exr; } }
|
||||
@@ -30,8 +30,8 @@ namespace Back.Data.Models
|
||||
[MaxLength(18)]
|
||||
public decimal? vam { get
|
||||
{
|
||||
return invoice.pattern.inp == 9 ? fee*vra/100 :
|
||||
invoice.pattern.inp == 13 ? ((tcpbs+9)/100)+((prdis*vra)/100)
|
||||
return invoice?.pattern?.inp == 9 ? fee*vra/100 :
|
||||
invoice?.pattern?.inp == 13 ? ((tcpbs+9)/100)+((prdis*vra)/100)
|
||||
: vra * adis / 100;
|
||||
} }
|
||||
//جمع کل اجرت ،حق العمل و سود
|
||||
@@ -39,33 +39,38 @@ namespace Back.Data.Models
|
||||
public decimal? tcpbs { get { return consfee + spro + bros; } }
|
||||
//سهم نقدی از پرداخت
|
||||
[MaxLength(18)]
|
||||
public decimal? cop { get { return (tsstam * invoice.cap) / invoice.tadis; } }
|
||||
public decimal? cop { get { return (tsstam * invoice?.cap) / invoice?.tadis; } }
|
||||
//سهم مالیات بر ارزش افزوده از پرداخت
|
||||
[MaxLength(18)]
|
||||
public decimal? vop { get { return vra == 0 ? 0 : (vam * invoice.cap) / invoice.tadis; } }
|
||||
public decimal? vop { get { return vra == 0 ? 0 : (vam * invoice?.cap) / invoice?.tadis; } }
|
||||
//مبلغ کل کالا/خدمت
|
||||
[MaxLength(18)]
|
||||
public decimal? tsstam { get
|
||||
{
|
||||
return invoice.pattern.inp == 9 ? fee+vam :
|
||||
invoice.pattern.inp == 10 ? sscv + vam + odam + olam :
|
||||
invoice.pattern.inp == 4 ? prdis + vam + odam + olam :
|
||||
if (invoice==null || invoice.pattern==null)
|
||||
{
|
||||
return vam + adis;
|
||||
}
|
||||
else
|
||||
return invoice?.pattern?.inp == 9 ? fee+vam :
|
||||
invoice?.pattern?.inp == 10 ? sscv + vam + odam + olam :
|
||||
invoice?.pattern?.inp == 4 ? prdis + vam + odam + olam :
|
||||
vam + adis + odam + olam;
|
||||
} }
|
||||
//مبلغ بعد از تخفیف
|
||||
[MaxLength(18)]
|
||||
public decimal? adis { get
|
||||
{
|
||||
return invoice.pattern.inp == 13 ? prdis+ tcpbs - dis: prdis - dis;
|
||||
return invoice?.pattern?.inp == 13 ? prdis+ tcpbs - dis: prdis - dis;
|
||||
} }
|
||||
//مبلغ قبل از تخفیف
|
||||
[MaxLength(18)]
|
||||
public decimal? prdis { get { return am * fee; } }
|
||||
//نرخ مالیات بر ازش افزوده
|
||||
[MaxLength(5)]
|
||||
public decimal? vra { get { return cODItem.TaxRate; } }
|
||||
public decimal? vra { get { return cODItem != null ? cODItem.TaxRate : null; } }
|
||||
//واحد اندازه گیری عنوان
|
||||
public string? unitTitle { get { return cODItem.CODUnit.Title; } }
|
||||
public string? unitTitle { get { return cODItem!=null ? cODItem.CODUnit.Title : null; } }
|
||||
#endregion
|
||||
|
||||
#region fild
|
||||
@@ -86,13 +91,13 @@ namespace Back.Data.Models
|
||||
public decimal? exr { get; set; }
|
||||
//ارزش ریالی کالا
|
||||
[MaxLength(18)]
|
||||
public decimal? ssrv { get; set; }
|
||||
public decimal? ssrv { get; set; } = 0;
|
||||
//ارزش ارزی کالا
|
||||
[MaxLength(18)]
|
||||
public decimal? sscv { get; set; }
|
||||
public decimal? sscv { get; set; } = 0;
|
||||
//مبلغ تخفیف
|
||||
[MaxLength(18)]
|
||||
public decimal? dis { get; set; }
|
||||
public decimal? dis { get; set; } = 0;
|
||||
//موضوع سایر مالیات و عوارض
|
||||
[MaxLength(255)]
|
||||
public string? odt { get; set; }
|
||||
@@ -101,7 +106,7 @@ namespace Back.Data.Models
|
||||
public decimal? odr { get; set; }
|
||||
//مبلغ سایر مالیات و عواض
|
||||
[MaxLength(18)]
|
||||
public decimal? odam { get; set; }
|
||||
public decimal? odam { get; set; } = 0;
|
||||
//موضوع سایر وجوه قانونی
|
||||
[MaxLength(255)]
|
||||
public string? olt { get; set; }
|
||||
@@ -110,16 +115,16 @@ namespace Back.Data.Models
|
||||
public decimal? olr { get; set; }
|
||||
//مبلغ سایر وجوه قانونی
|
||||
[MaxLength(18)]
|
||||
public decimal? olam { get; set; }
|
||||
public decimal? olam { get; set; } = 0;
|
||||
//اجرت دساخت
|
||||
[MaxLength(18)]
|
||||
public decimal? consfee { get; set; }
|
||||
public decimal? consfee { get; set; } = 0;
|
||||
//سود فروشنده
|
||||
[MaxLength(18)]
|
||||
public decimal? spro { get; set; }
|
||||
public decimal? spro { get; set; } = 0;
|
||||
//حق العمل
|
||||
[MaxLength(18)]
|
||||
public decimal? bros { get; set; }
|
||||
public decimal? bros { get; set; } = 0;
|
||||
//شناسه یکتای ثبت قرارداد حق العمل کاری
|
||||
[MaxLength(12)]
|
||||
public string? bsrn { get; set; }
|
||||
|
@@ -24,17 +24,20 @@ namespace Back.Services
|
||||
{
|
||||
#region AdvancedSearch
|
||||
var invok = _invoiceRepo
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && w.ID==ID);
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && w.ID == ID);
|
||||
|
||||
|
||||
#endregion
|
||||
//-----------------------
|
||||
return await invok
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
//.Include(inc => inc.payments)
|
||||
//.Include(inc => inc.pattern)
|
||||
.Select(s => new InvoiceDTO()
|
||||
{
|
||||
|
||||
PatternID = s.PatternID,
|
||||
PatternTitle = s.pattern.Title,
|
||||
CustomerID = s.CustomerID,
|
||||
@@ -56,30 +59,32 @@ namespace Back.Services
|
||||
{
|
||||
ID = x.ID,
|
||||
CODID = x.CODID,
|
||||
//adis = x.adis,
|
||||
adis = x.adis,
|
||||
am = x.am.Value,
|
||||
dis = x.dis,
|
||||
fee = x.fee.Value,
|
||||
mu = x.unitTitle,
|
||||
sstt = x.sstt,
|
||||
tsstam = x.tsstam,
|
||||
vam = x.am,
|
||||
vra = x.vra
|
||||
}).ToList(),
|
||||
payments = s.payments.OrderBy(o => o.ID).Select(x => new InvoicePaymentDTO()
|
||||
{
|
||||
ID = x.ID,
|
||||
acn = x.acn,
|
||||
iinn = x.acn,
|
||||
pcn = x.acn,
|
||||
pdt = x.pdt,
|
||||
PaymentDateTime=x.PaymentDateTime,
|
||||
pid = x.pid,
|
||||
pmt = x.pmt,
|
||||
pv = x.pv,
|
||||
trmn = x.trmn,
|
||||
trn = x.acn
|
||||
vam = x.vam,
|
||||
vra = x.vra,
|
||||
prdis = x.prdis
|
||||
}).ToList(),
|
||||
payments = new List<InvoicePaymentDTO>() //s.payments.OrderBy(o => o.ID).Select(x => new InvoicePaymentDTO()
|
||||
//{
|
||||
// ID = x.ID,
|
||||
// acn = x.acn,
|
||||
// iinn = x.acn,
|
||||
// pcn = x.acn,
|
||||
// pdt = x.pdt,
|
||||
// PaymentDateTime=x.PaymentDateTime,
|
||||
// pid = x.pid,
|
||||
// pmt = x.pmt,
|
||||
// pv = x.pv,
|
||||
// trmn = x.trmn,
|
||||
// trn = x.acn
|
||||
//}).ToList()
|
||||
,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
@@ -107,10 +112,13 @@ namespace Back.Services
|
||||
//-----------------------
|
||||
return await invok
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
//.Include(inc => inc.payments)
|
||||
//.Include(inc => inc.pattern)
|
||||
.Select(s => new InvoiceGridDTO()
|
||||
{
|
||||
|
||||
CustomerID = s.CustomerID,
|
||||
CustomerName = s.Customer.FullName,
|
||||
ID = s.ID,
|
||||
@@ -121,6 +129,7 @@ namespace Back.Services
|
||||
tdis = s.tdis,
|
||||
tvam = s.tvam,
|
||||
Udate = s.Udate.ShamciToFormatShamci(),
|
||||
|
||||
})
|
||||
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
|
||||
}
|
||||
|
@@ -27,7 +27,13 @@ namespace Back.Services
|
||||
{
|
||||
return await _invoiceitemRepo.Get(w => w.InvoiceID == invoiceID && w.ID == invoiceitemID && w.invoice.CompanyID == companyID).AnyAsync();
|
||||
}
|
||||
|
||||
public async Task<InvoiceItem?> GetInvoiceItemByInvoiceItemID(int CompanyID, int InvoiceItemID)
|
||||
{
|
||||
return await _invoiceitemRepo
|
||||
.Get(w => w.ID == InvoiceItemID && w.invoice.CompanyID == CompanyID && !w.invoice.IsDeleted)
|
||||
.Include(s=>s.invoice)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<InvoiceItem> Getinvoiceitem(int companyID, int invoiceID, int invoiceitemID)
|
||||
{
|
||||
return await _invoiceitemRepo.Get(w => w.InvoiceID == invoiceID && w.ID == invoiceitemID && w.invoice.CompanyID == companyID).FirstOrDefaultAsync();
|
||||
|
@@ -105,7 +105,7 @@ namespace Shared.DTOs
|
||||
//مبلغ قبل از تخفیف
|
||||
public decimal? prdis { get; set; }
|
||||
//مبلغ بعد از تخفیف
|
||||
[MaxLength(18)]
|
||||
|
||||
public decimal? adis { get; set; }
|
||||
|
||||
}
|
||||
|
14
Shared/DTOs/InvoiceItemAction.cs
Normal file
14
Shared/DTOs/InvoiceItemAction.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class InvoiceItemAction<T>
|
||||
{
|
||||
public int invoiceID { get; set; }
|
||||
public T item { get; set; }
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
@inject HttpClientController hc;
|
||||
@inject Fixedvalues fv;
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
<Toasts class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
|
||||
|
||||
<form>
|
||||
@* alert *@
|
||||
@@ -116,7 +117,7 @@ else
|
||||
|
||||
|
||||
@code {
|
||||
[Inject] ToastService ToastService { get; set; } = default!;
|
||||
List<ToastMessage> messages = new List<ToastMessage>();
|
||||
private ConfirmDialog dialog = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
@@ -147,6 +148,14 @@ else
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
private void ShowMessage(ToastType toastType,string msg) => messages.Add(CreateToastMessage(toastType,msg));
|
||||
|
||||
private ToastMessage CreateToastMessage(ToastType toastType,string msg)
|
||||
=> new ToastMessage
|
||||
{
|
||||
Type = toastType,
|
||||
Message = msg,
|
||||
};
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
@@ -164,25 +173,25 @@ else
|
||||
//-----------------------
|
||||
private async Task prdisAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.prdis = itemDTO.fee * itemDTO.am;
|
||||
// if (itemDTO.ID == null)
|
||||
itemDTO.prdis = itemDTO.fee * itemDTO.am;
|
||||
}
|
||||
private async Task adisAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.adis = itemDTO.prdis - itemDTO.dis;
|
||||
// if (itemDTO.ID == null)
|
||||
itemDTO.adis = itemDTO.prdis - itemDTO.dis;
|
||||
|
||||
// await AftervamAsync();
|
||||
}
|
||||
private async Task vamAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.vam = itemDTO.vra * itemDTO.adis / 100;
|
||||
// if (itemDTO.ID == null)
|
||||
itemDTO.vam = itemDTO.vra * itemDTO.adis / 100;
|
||||
}
|
||||
private async Task tsstamAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.tsstam = itemDTO.vam + itemDTO.adis;
|
||||
// if (itemDTO.ID == null)
|
||||
itemDTO.tsstam = itemDTO.vam + itemDTO.adis;
|
||||
}
|
||||
private async Task AfterAsync()
|
||||
{
|
||||
@@ -195,7 +204,7 @@ else
|
||||
public async Task OnClickDelete()
|
||||
{
|
||||
|
||||
var rsp = await hc.Delete($"InvoiceItem/DeleteItem/{InvoiceID}/{itemDTO.ID}");
|
||||
var rsp = await hc.Delete($"InvoiceItem/DeleteItem/{itemDTO.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
@@ -243,7 +252,12 @@ else
|
||||
ShowDangerAlert("مبلغ تخفیف درست نیست");
|
||||
return;
|
||||
}
|
||||
var rsp = await hc.Put<InvoiceItemDTO>($"InvoiceItem/UpdateItem/{InvoiceID}", itemDTO);
|
||||
var rsp = await hc.Put<InvoiceItemAction<InvoiceItemDTO>>($"InvoiceItem/UpdateItem"
|
||||
, new InvoiceItemAction<InvoiceItemDTO>
|
||||
{
|
||||
invoiceID=InvoiceID,
|
||||
item = itemDTO
|
||||
});
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
@@ -287,7 +301,11 @@ else
|
||||
return;
|
||||
}
|
||||
|
||||
var rsp = await hc.Post<InvoiceItemDTO>($"InvoiceItem/AddItem/{InvoiceID}", itemDTO);
|
||||
var rsp = await hc.Post<InvoiceItemAction<InvoiceItemDTO>>($"InvoiceItem/AddItem", new InvoiceItemAction<InvoiceItemDTO>
|
||||
{
|
||||
invoiceID = InvoiceID,
|
||||
item = itemDTO
|
||||
});
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
@@ -313,7 +331,7 @@ else
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "عملیات حذف آیتم صورتحساب",
|
||||
message1: $"از حذف آیتم {itemDTO.ID} از صورتحساب {InvoiceID}",
|
||||
message1: $"از حذف کالای {itemDTO.sstt} از صورتحساب {InvoiceID}",
|
||||
message2: "اطمینان دارید?");
|
||||
|
||||
if (confirmation)
|
||||
@@ -322,7 +340,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Secondary, $"عملیات حذف متوقف شد"));
|
||||
ShowMessage(ToastType.Secondary, "عملیات حذف متوقف شد");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
<Modal @ref="modal" />
|
||||
|
||||
<Grid TItem="InvoiceItemDTO"
|
||||
Class="table table-hover table-bordered table-striped"
|
||||
AllowRowClick="true"
|
||||
AllowSorting="true"
|
||||
Class="table table-hover"
|
||||
DataProvider="DataProvider"
|
||||
AllowPaging="true"
|
||||
PageSize="10"
|
||||
@@ -12,35 +14,35 @@
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="شناسه">
|
||||
@context.ID
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="کد">
|
||||
@* <GridColumn TItem="InvoiceItemDTO" HeaderText="کد">
|
||||
@context.CODID
|
||||
</GridColumn>
|
||||
</GridColumn> *@
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="کالا">
|
||||
@context.sstt
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="واحد">
|
||||
@context.mu
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="تعداد/مقدار">
|
||||
@context.am
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="تعداد">
|
||||
@context.am.ToString().Split('٫')[0]
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ واحد">
|
||||
@context.fee
|
||||
@context.fee.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="نرخ مالیات">
|
||||
@context.vra
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ مالیات">
|
||||
@context.vam
|
||||
@context.vam?.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="تخفیف">
|
||||
@context.dis
|
||||
@context.dis?.ToString("N0")
|
||||
</GridColumn>
|
||||
@* <GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ بعد از تخفیف">
|
||||
@context.adis
|
||||
</GridColumn> *@
|
||||
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ کل">
|
||||
@context.tsstam
|
||||
@context.tsstam?.ToString("N0")
|
||||
</GridColumn>
|
||||
</Grid>
|
||||
|
||||
@@ -88,11 +90,11 @@
|
||||
if (result.Status == ComponentStatus.success)
|
||||
msg="آیتم با موفقیت حذف شد";
|
||||
}
|
||||
|
||||
await OnMultipleOfThree.InvokeAsync(msg);
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// await LoadCod(1);
|
||||
|
||||
await modal.HideAsync();
|
||||
// await modal.HideAsync();
|
||||
}
|
||||
private IEnumerable<InvoiceItemDTO> GetInvoiceItems()
|
||||
{
|
||||
|
@@ -44,7 +44,17 @@
|
||||
|
||||
if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute"))
|
||||
{
|
||||
<td>@property.GetValue(item, null)</td>
|
||||
if (property.PropertyType == typeof(Nullable<System.Decimal>) || property.PropertyType == typeof(System.Decimal))
|
||||
{
|
||||
<td>
|
||||
@decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>@property.GetValue(item, null)</td>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -122,17 +122,21 @@
|
||||
<InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" />
|
||||
</div>
|
||||
</div>
|
||||
@if (InvoiceID == 0 || InvoiceID == null ? false : true)
|
||||
{
|
||||
@if (InvoiceID == 0 || InvoiceID == null ? false : true)
|
||||
{
|
||||
|
||||
<br /> <hr class="hr" />
|
||||
<div class="row g-3">
|
||||
<Tabs NavStyle="NavStyle.VerticalUnderline">
|
||||
<Tab Title="آیتم ها" IsActive="InvoiceID==0 || InvoiceID==null ? false : true">
|
||||
<Tab Title="آیتم ها" IsActive="true">
|
||||
<Content>
|
||||
<div class="row g-3">
|
||||
<div class="form-group col-md-11">
|
||||
<LGridInvoiceItem InvoiceID="InvoiceID??0" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
|
||||
@if (InvoiceID.HasValue && invoice.items.Count > 0)
|
||||
{
|
||||
<LGridInvoiceItem InvoiceID="InvoiceID.Value" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
|
||||
|
||||
}
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
|
||||
@@ -229,7 +233,7 @@
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
|
||||
Cus = await fv.GetCustomers();
|
||||
Patterns = await fv.GetPatterns();
|
||||
if (InvoiceID != null && InvoiceID > 0)
|
||||
@@ -252,7 +256,7 @@
|
||||
|
||||
Hidealert = true;
|
||||
alertMessage = "";
|
||||
PreloadService.Hide();
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@@ -273,6 +277,7 @@
|
||||
}
|
||||
private async Task LoadData()
|
||||
{
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -280,6 +285,8 @@
|
||||
}
|
||||
else
|
||||
hc._nav.NavigateTo("/Panel");
|
||||
|
||||
PreloadService.Hide();
|
||||
}
|
||||
public async Task CallBack(ActionInResultComponent result)
|
||||
{
|
||||
|
@@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
||||
}) ;
|
||||
|
||||
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||
|
||||
|
Reference in New Issue
Block a user