...
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();
|
||||
|
||||
Reference in New Issue
Block a user