...
This commit is contained in:
@@ -81,7 +81,6 @@ namespace Back.Controllers
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
||||
//if (item.BillReference.HasValue)
|
||||
//{
|
||||
// Invoice ReferenceInvoice = await _servInvoice.GetInvoiceByInvoiceID(item.BillReference.Value);
|
||||
@@ -144,12 +143,18 @@ namespace Back.Controllers
|
||||
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'+
|
||||
"بهتر است صورتحساب دیگر صادر کنید" });
|
||||
}
|
||||
else if (invoice.invoiceType == InvoiceType.Repair)
|
||||
{
|
||||
return BadRequest(new List<string>
|
||||
{ "صورتحساب در وضعیت اصلاحی امکان تغییر مشتری یا الگو را ندارد"+'\n'+
|
||||
"بهتر است صورتحساب دیگر صادر کنید" });
|
||||
}
|
||||
else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair)
|
||||
{
|
||||
|
@@ -48,6 +48,14 @@ namespace Back.Controllers
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.Repair)
|
||||
{
|
||||
return BadRequest(new List<string> { "امکان افزودن کالا جدید در صورتحساب اصلاحی وجود ندارد" });
|
||||
}
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
{
|
||||
return BadRequest(new List<string> { "امکان افزودن کالا جدید در صورتحساب برگشت از فروش وجود ندارد" });
|
||||
}
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
@@ -81,10 +89,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
|
||||
@@ -103,8 +111,27 @@ namespace Back.Controllers
|
||||
if (invoiceitem == null)
|
||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
if (invoice.invoiceType == InvoiceType.Repair && invoiceitem.CODID != model.item.CODID)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب اصلاجی نمیتوان کالا را تغییر داد" });
|
||||
}
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale && invoiceitem.CODID != model.item.CODID)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب برگشت از فروش نمیتوان کالا را تغییر داد" });
|
||||
}
|
||||
|
||||
if (invoice.invoiceType == InvoiceType.Repair && invoiceitem.fee != model.item.fee)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب اصلاجی نمیتوان مبلغ واحد را تغییر داد" });
|
||||
}
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale && invoiceitem.fee != model.item.fee)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب برگشت از فروش نمیتوان مبلغ واحد را تغییر داد" });
|
||||
}
|
||||
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.BackFrmSale && invoiceitem.am < model.item.am)
|
||||
return BadRequest(new List<string> { "در حالت برگشت از فروش تعداد آیتم فقط میتواند کاهشی باشد" });
|
||||
return BadRequest(new List<string> { "در صورتحساب برگشت از فروش تعداد آیتم فقط میتواند کاهشی باشد" });
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
@@ -146,6 +173,14 @@ namespace Back.Controllers
|
||||
|
||||
|
||||
|
||||
if (invoiceitem.invoice.invoiceType == InvoiceType.Repair )
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب اصلاجی نمیتوان کالا را حذف کذد" });
|
||||
}
|
||||
if (invoiceitem.invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
{
|
||||
return BadRequest(new List<string> { "در صورتحساب برگشت از فروش نمیتوان کالا را حذف کذد" });
|
||||
}
|
||||
invoiceitem.invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
|
||||
|
@@ -33,10 +33,10 @@ namespace Back.Data.Models
|
||||
public int? inp { get { return pattern?.inp; } }
|
||||
//شماره اقتصادی فروشنده
|
||||
[MaxLength(14)]
|
||||
public string? tins { get { return company?.EconomicCode; } }
|
||||
public string? tins { get { return company?.EconomicCode; } }
|
||||
//شماره اقتصادی خریدار
|
||||
[MaxLength(14)]
|
||||
public string? tinb { get { return Customer.EconomicCode; } }
|
||||
public string? tinb { get { return Customer.CustomerType==CustomerType.WithoutIdentity ?null : Customer.EconomicCode; } }
|
||||
//مجموع مبلغ قبل از کسر تخفیف
|
||||
[MaxLength(18)]
|
||||
public decimal? tprdis { get { return invoiceDetails.Sum(i => i.prdis); } }
|
||||
@@ -69,7 +69,7 @@ namespace Back.Data.Models
|
||||
public decimal? tvop { get { return invoiceDetails.Sum(i => i.vop); } }
|
||||
//نوع شخص خریدار
|
||||
[MaxLength(1)]
|
||||
public int tob { get { return (int)Customer.CustomerType; } }
|
||||
public int tob { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? 0 : (int)Customer.CustomerType; } }
|
||||
//اریخ کوتاژ اظهارنامه گمرکی
|
||||
// Unix Time => from fild CottageDateOfCustomsDeclaration
|
||||
[MaxLength(5)]
|
||||
@@ -79,16 +79,16 @@ namespace Back.Data.Models
|
||||
} }
|
||||
//کد پستی خریدار
|
||||
[MaxLength(10)]
|
||||
public string? bpc { get { return Customer.ZipCode; } }
|
||||
public string? bpc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.ZipCode; } }
|
||||
//کد شعبه خریدار
|
||||
[MaxLength(10)]
|
||||
public string? bbc { get { return Customer.BranchID; } }
|
||||
public string? bbc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.BranchID; } }
|
||||
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار
|
||||
[MaxLength(14)]
|
||||
public string? bid { get { return Customer.MeliCode; } }
|
||||
public string? bid { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.MeliCode; } }
|
||||
//شماره گذرنامه خریدار
|
||||
[MaxLength(9)]
|
||||
public string? bpn { get { return Customer.PassportNumber; } }
|
||||
public string? bpn { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.PassportNumber; } }
|
||||
//کد شعبه فروشنده
|
||||
[MaxLength(9)]
|
||||
public string? sbc { get { return company?.BranchID; } }
|
||||
|
@@ -33,13 +33,14 @@ namespace Back.Services
|
||||
public int? Inp { get { return _invoice.inp ?? 1; } }
|
||||
public int? Ins { get { return _invoice.ins ?? 1; } }
|
||||
public string? Tins { get { return string.IsNullOrEmpty(_invoice.tins) ? null : _invoice.tins; } }
|
||||
public int? Tob { get { return level == 10 ? null : _invoice.tob == 5 ? 1 : _invoice.tob == 6 ? 4 : _invoice.tob; } }
|
||||
public int? Tob { get { return level == 10 || _invoice.tob==0 ? null : _invoice.tob == 5 ? 1 : _invoice.tob == 6 ? 4 : _invoice.tob; } }
|
||||
public string? Bid
|
||||
{
|
||||
get
|
||||
{
|
||||
return level == 10 || string.IsNullOrEmpty(_invoice.bid) || !string.IsNullOrEmpty(_invoice.tinb)
|
||||
|| _invoice.tob == 1 || _invoice.tob == 2 || _invoice.tob == 3 || _invoice.tob == 4 ? null : _invoice.bid};
|
||||
|| _invoice.tob == 1 || _invoice.tob == 2 || _invoice.tob == 3 || _invoice.tob == 4 ? null : _invoice.bid;
|
||||
}
|
||||
}
|
||||
public string? Tinb { get { return level == 10 || string.IsNullOrEmpty(_invoice.tinb) || _invoice.tob == 5 || _invoice.tob == 6 ? null : _invoice.tinb; } }
|
||||
public string? Sbc { get { return string.IsNullOrEmpty(_invoice.sbc) ? null : _invoice.sbc; } }
|
||||
|
@@ -52,6 +52,7 @@ namespace Back.Validations
|
||||
RuleFor(r => r.Item2.PatternID)
|
||||
.Custom((PatternID, context) =>
|
||||
{
|
||||
|
||||
if (PatternID != null && PatternID > 0 && !patternRepo.Get(w => w.Status && w.ID == PatternID).AnyAsync().Result)
|
||||
context.AddFailure("الگوی صورتحساب معتبر نیست");
|
||||
});
|
||||
@@ -61,9 +62,17 @@ namespace Back.Validations
|
||||
{
|
||||
if (model.Item2.CustomerID == null || model.Item2.CustomerID <= 0)
|
||||
context.AddFailure("برای صدور صورتحساب باید مشتری تعریف شود");
|
||||
|
||||
|
||||
else if (!servCustomer.ExistCustomerByCustomerID(model.Item2.CustomerID, model.Item1).Result)
|
||||
context.AddFailure("مشتری یافت نشد");
|
||||
|
||||
var cus = servCustomer.GetCustomerByCustomerID(model.Item2.CustomerID, model.Item1).Result;
|
||||
if (cus.CustomerType == CustomerType.WithoutIdentity && !(model.Item2.PatternID == 3 || model.Item2.PatternID == 5 ||
|
||||
model.Item2.PatternID == 5 || model.Item2.PatternID == 6 || model.Item2.PatternID == 8 || model.Item2.PatternID == 9 || model.Item2.PatternID == 14))
|
||||
context.AddFailure("مشتری بدون هویت برای این الگو نمیتوان در نظر گرفت");
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
RuleFor(r => r.Item2.InvoiceDate)
|
||||
|
@@ -16,7 +16,9 @@ namespace Shared.DTOs
|
||||
[Display(Name = "حقیقی با شناسه ملی")]
|
||||
genuineByMeliCode = 5,
|
||||
[Display(Name = "اتباع عیر ایرانی با شناسه ملی")]
|
||||
NonIranianNationalsByMeliCode = 6
|
||||
NonIranianNationalsByMeliCode = 6,
|
||||
[Display(Name = "بدون هویت")]
|
||||
WithoutIdentity = 7
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -54,6 +54,7 @@
|
||||
<option value="3">مشارکت مدنی</option>
|
||||
<option value="4">اتباع غیر ایرانی با کد اقتصادی</option>
|
||||
<option value="6">اتباع غیر ایرانی با شناسه ملی</option>
|
||||
<option value="7">بدون هویت</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -32,6 +32,7 @@
|
||||
<option value="3">مشارکت مدنی</option>
|
||||
<option value="4">اتباع غیر ایرانی با کد اقتصادی</option>
|
||||
<option value="6">اتباع غیر ایرانی با شناسه ملی</option>
|
||||
<option value="7">بدون هویت</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
|
Reference in New Issue
Block a user