...
This commit is contained in:
@@ -136,17 +136,19 @@ namespace Back.Controllers
|
||||
return BadRequest(new List<string> { "این صورتحساب دارای مرجع می باشد"+'\n'+
|
||||
"امکان تغییر الگو امکان پذیر نیست"});
|
||||
}
|
||||
if (invoice.PatternID != item.PatternID || invoice.CustomerID != item.CustomerID
|
||||
|| invoice.InvoicIssueDate != item.InvoicIssueDate || invoice.InvoiceDate != item.InvoiceDate)
|
||||
var CheckTaxPayer = await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice);
|
||||
if (invoice.PatternID != item.PatternID || invoice.CustomerID != item.CustomerID)
|
||||
{
|
||||
//----Check TaxPayer
|
||||
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
|
||||
|
||||
if (CheckTaxPayer)
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||
else if (invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
{
|
||||
return BadRequest(new List<string>
|
||||
{ "صورتحساب در وضعیت برگشت از فروش نمی تواند ویرایش شود" });
|
||||
{ "صورتحساب در وضعیت برگشت از فروش امکان تغییر مشتری یا الگو را ندارد"+'\n'+
|
||||
"بهتر است صورتحساب دیگر صادر کنید" });
|
||||
}
|
||||
else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair)
|
||||
@@ -155,7 +157,25 @@ namespace Back.Controllers
|
||||
$"فقط در حالت پیش نویس ، فاکتور و اصلاح (که به سازمان ارسال نشده باشد) میتوان سند را ویرایش کرد" });
|
||||
}
|
||||
}
|
||||
|
||||
else if (invoice.InvoicIssueDate != item.InvoicIssueDate || invoice.InvoiceDate != item.InvoiceDate)
|
||||
{
|
||||
if(CheckTaxPayer)
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"امکان تغییر تاریخ را ندارد"});
|
||||
else if(invoice.BillReference.HasValue)
|
||||
{
|
||||
if (invoice.InvoicIssueDate != item.InvoicIssueDate && Convert.ToInt32(invoice.invoice.InvoicIssueDate) > Convert.ToInt32(item.InvoicIssueDate))
|
||||
{
|
||||
return BadRequest(new List<string> { "این صورتحساب مرجع دارد"+'\n'+
|
||||
$"تاریخ صدور نمیتواند از تاریخ صدور مرجع ({invoice.invoice.InvoicIssueDate.ShamciToFormatShamci()}) کمتر باشد"});
|
||||
}
|
||||
if (invoice.InvoiceDate != item.InvoiceDate && Convert.ToInt32(invoice.invoice.InvoiceDate) > Convert.ToInt32(item.InvoiceDate))
|
||||
{
|
||||
return BadRequest(new List<string> { "این صورتحساب مرجع دارد"+'\n'+
|
||||
$"تاریخ صورتحساب نمیتواند از تاریخ صورتحساب مرجع ({invoice.invoice.InvoiceDate.ShamciToFormatShamci()}) کمتر باشد"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----change invoice
|
||||
|
@@ -176,6 +176,7 @@ namespace Back.Data.Models
|
||||
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
|
||||
[ForeignKey("BillReference")]
|
||||
public virtual Invoice? invoice { get; set; }
|
||||
public virtual ICollection<Invoice> Childinvoice { get; set; }
|
||||
public virtual ICollection<InvoicePayment> payments { get; set; }
|
||||
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
|
||||
public virtual ICollection<SentTax> sentTax { get; set; }
|
||||
|
@@ -43,7 +43,7 @@ namespace Back.Services
|
||||
|
||||
#endregion
|
||||
//-----------------------
|
||||
return await invok.Select(s => new RCOD()
|
||||
return await invok.OrderByDescending(o=>o.ID).Select(s => new RCOD()
|
||||
{
|
||||
ID = s.ID,
|
||||
TaxID = s.ItemTaxID,
|
||||
|
@@ -41,7 +41,9 @@ namespace Back.Services
|
||||
.Include(inc => inc.sentTax)
|
||||
//.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.ThenInclude(inc => inc.BillType).FirstOrDefaultAsync();
|
||||
.ThenInclude(inc => inc.BillType)
|
||||
|
||||
.FirstOrDefaultAsync();
|
||||
return new InvoiceDTO()
|
||||
{
|
||||
|
||||
@@ -143,6 +145,7 @@ namespace Back.Services
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
//.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.OrderByDescending(o=>o.ID)
|
||||
.Select(s => new InvoiceGridDTO()
|
||||
{
|
||||
|
||||
@@ -229,6 +232,7 @@ namespace Back.Services
|
||||
.Include(inc => inc.Customer)
|
||||
.Include(inc => inc.sentTax)
|
||||
.Include(inc => inc.pattern)
|
||||
.Include(inc => inc.invoice)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> DeleteInvoice(Invoice item)
|
||||
|
@@ -304,7 +304,7 @@ namespace Back.Services
|
||||
dt.Add(DateTime.Now.AddDays(i).ConvertMiladiToShamsi());
|
||||
|
||||
request.MostInvoicedProduct = await _invoiceitemRepo.Get(w => w.invoice.CompanyID == user.RolUsers.First().CompanyID && !w.invoice.IsDeleted
|
||||
&& ((w.invoice.invoiceType == InvoiceType.Sale || w.invoice.invoiceType == InvoiceType.Repair) && !w.invoice.BillReference.HasValue || (w.invoice.invoiceType == InvoiceType.BackFrmSale))
|
||||
&& (w.invoice.invoiceType == InvoiceType.BackFrmSale || w.invoice.invoiceType == InvoiceType.Repair || (w.invoice.invoiceType == InvoiceType.Sale && !w.invoice.Childinvoice.Any(a => !a.IsDeleted)))
|
||||
&& (dt.Contains(w.invoice.InvoiceDate)))
|
||||
.Include(inc => inc.cODItem)
|
||||
.GroupBy(g => g.CODID)
|
||||
@@ -317,7 +317,7 @@ namespace Back.Services
|
||||
.ToListAsync();
|
||||
|
||||
request.MostInvoicedCustomer = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted
|
||||
&& ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale))
|
||||
&& (w.invoiceType == InvoiceType.BackFrmSale || w.invoiceType == InvoiceType.Repair || (w.invoiceType == InvoiceType.Sale && !w.Childinvoice.Any(a => !a.IsDeleted) ))
|
||||
&& dt.Contains(w.InvoiceDate))
|
||||
.Include(inc => inc.Customer)
|
||||
.GroupBy(g => g.CustomerID)
|
||||
@@ -333,7 +333,7 @@ namespace Back.Services
|
||||
|
||||
|
||||
var sale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted
|
||||
&& ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale))
|
||||
&& (w.invoiceType == InvoiceType.BackFrmSale || w.invoiceType == InvoiceType.Repair || (w.invoiceType == InvoiceType.Sale && !w.Childinvoice.Any(a => !a.IsDeleted)))
|
||||
&& w.InvoiceDate.StartsWith(cdate))
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
@@ -346,7 +346,7 @@ namespace Back.Services
|
||||
cdate = DateTime.Now.AddMonths(-1).ConvertMiladiToShamsiAndGetYearMonth();
|
||||
|
||||
var lastonthsale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted
|
||||
&& ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale))
|
||||
&& (w.invoiceType == InvoiceType.BackFrmSale || w.invoiceType == InvoiceType.Repair || (w.invoiceType == InvoiceType.Sale && !w.Childinvoice.Any(a => !a.IsDeleted)))
|
||||
&& w.InvoiceDate.StartsWith(cdate))
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
@@ -376,7 +376,7 @@ namespace Back.Services
|
||||
for (int i = 1; i <= Convert.ToInt32(dateTime.Substring(6, 2)); i++)
|
||||
{
|
||||
var sumsale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted
|
||||
&& ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale))
|
||||
&& (w.invoiceType == InvoiceType.BackFrmSale || w.invoiceType == InvoiceType.Repair || (w.invoiceType == InvoiceType.Sale && !w.Childinvoice.Any(a => !a.IsDeleted)))
|
||||
&& w.InvoiceDate == dateTime.Substring(0, 4) + dateTime.Substring(4, 2) + i.ToString("00"))
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
|
@@ -5,6 +5,7 @@ using Back.Services;
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
using TaxCollectData.Library.Dto.Content;
|
||||
|
||||
namespace Back.Validations
|
||||
{
|
||||
@@ -71,6 +72,9 @@ namespace Back.Validations
|
||||
if (string.IsNullOrEmpty(InvoiceDate))
|
||||
context.AddFailure("تاریخ ایجاد صورتحساب نمی تواند خالی باشد");
|
||||
|
||||
else if(InvoiceDate.Length!=8)
|
||||
context.AddFailure("تاریخ ایجاد صورتحساب صحیح نمی باشد");
|
||||
|
||||
else if (InvoiceDate.Trim().ToMiladi() > DateTime.Now)
|
||||
context.AddFailure("تاریخ ایجاد صورتحساب نمی تواند از امروز جلوتر باشد");
|
||||
});
|
||||
@@ -80,6 +84,8 @@ namespace Back.Validations
|
||||
{
|
||||
if (string.IsNullOrEmpty(InvoicIssueDate))
|
||||
context.AddFailure("تاریخ صدور صورتحساب نمی تواند خالی باشد");
|
||||
else if (InvoicIssueDate.Length != 8)
|
||||
context.AddFailure("تاریخ صدور صورتحساب صحیح نمی باشد");
|
||||
|
||||
else if (InvoicIssueDate.Trim().ToMiladi() > DateTime.Now)
|
||||
context.AddFailure("تاریخ صدور صورتحساب نمی تواند از امروز جلوتر باشد");
|
||||
|
Reference in New Issue
Block a user