This commit is contained in:
mmrbnjd
2024-12-11 15:33:33 +03:30
parent f2de3710f6
commit 3d77585dee
8 changed files with 72 additions and 18 deletions

View File

@@ -81,7 +81,6 @@ namespace Back.Controllers
if (!resultValidationmodel.IsValid) if (!resultValidationmodel.IsValid)
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
//if (item.BillReference.HasValue) //if (item.BillReference.HasValue)
//{ //{
// Invoice ReferenceInvoice = await _servInvoice.GetInvoiceByInvoiceID(item.BillReference.Value); // Invoice ReferenceInvoice = await _servInvoice.GetInvoiceByInvoiceID(item.BillReference.Value);
@@ -144,12 +143,18 @@ namespace Back.Controllers
if (CheckTaxPayer) if (CheckTaxPayer)
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+ return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"}); "برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
else if (invoice.invoiceType == InvoiceType.BackFrmSale) else if (invoice.invoiceType == InvoiceType.BackFrmSale )
{ {
return BadRequest(new List<string> return BadRequest(new List<string>
{ "صورتحساب در وضعیت برگشت از فروش امکان تغییر مشتری یا الگو را ندارد"+'\n'+ { "صورتحساب در وضعیت برگشت از فروش امکان تغییر مشتری یا الگو را ندارد"+'\n'+
"بهتر است صورتحساب دیگر صادر کنید" }); "بهتر است صورتحساب دیگر صادر کنید" });
} }
else if (invoice.invoiceType == InvoiceType.Repair)
{
return BadRequest(new List<string>
{ "صورتحساب در وضعیت اصلاحی امکان تغییر مشتری یا الگو را ندارد"+'\n'+
"بهتر است صورتحساب دیگر صادر کنید" });
}
else if (invoice.invoiceType != InvoiceType.Bidding else if (invoice.invoiceType != InvoiceType.Bidding
&& invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair) && invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair)
{ {

View File

@@ -48,6 +48,14 @@ namespace Back.Controllers
if (invoice == null) if (invoice == null)
return BadRequest(new List<string> { "invoice notFound..." }); 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); invoice.LastChangeUserID = Convert.ToInt32(UserID);
@@ -81,10 +89,10 @@ namespace Back.Controllers
if (invoice == null) if (invoice == null)
return BadRequest(new List<string> { "invoice notFound..." }); return BadRequest(new List<string> { "invoice notFound..." });
//-----Validaton
//-----Validaton var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
if (!resultValidationmodel.IsValid) if (!resultValidationmodel.IsValid)
{ {
if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale
@@ -103,8 +111,27 @@ namespace Back.Controllers
if (invoiceitem == null) if (invoiceitem == null)
return BadRequest(new List<string> { "invoice Item notFound..." }); 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) 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); 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); invoiceitem.invoice.LastChangeUserID = Convert.ToInt32(UserID);

View File

@@ -33,10 +33,10 @@ namespace Back.Data.Models
public int? inp { get { return pattern?.inp; } } public int? inp { get { return pattern?.inp; } }
//شماره اقتصادی فروشنده //شماره اقتصادی فروشنده
[MaxLength(14)] [MaxLength(14)]
public string? tins { get { return company?.EconomicCode; } } public string? tins { get { return company?.EconomicCode; } }
//شماره اقتصادی خریدار //شماره اقتصادی خریدار
[MaxLength(14)] [MaxLength(14)]
public string? tinb { get { return Customer.EconomicCode; } } public string? tinb { get { return Customer.CustomerType==CustomerType.WithoutIdentity ?null : Customer.EconomicCode; } }
//مجموع مبلغ قبل از کسر تخفیف //مجموع مبلغ قبل از کسر تخفیف
[MaxLength(18)] [MaxLength(18)]
public decimal? tprdis { get { return invoiceDetails.Sum(i => i.prdis); } } 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); } } public decimal? tvop { get { return invoiceDetails.Sum(i => i.vop); } }
//نوع شخص خریدار //نوع شخص خریدار
[MaxLength(1)] [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 // Unix Time => from fild CottageDateOfCustomsDeclaration
[MaxLength(5)] [MaxLength(5)]
@@ -79,16 +79,16 @@ namespace Back.Data.Models
} } } }
//کد پستی خریدار //کد پستی خریدار
[MaxLength(10)] [MaxLength(10)]
public string? bpc { get { return Customer.ZipCode; } } public string? bpc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.ZipCode; } }
//کد شعبه خریدار //کد شعبه خریدار
[MaxLength(10)] [MaxLength(10)]
public string? bbc { get { return Customer.BranchID; } } public string? bbc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.BranchID; } }
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار
[MaxLength(14)] [MaxLength(14)]
public string? bid { get { return Customer.MeliCode; } } public string? bid { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.MeliCode; } }
//شماره گذرنامه خریدار //شماره گذرنامه خریدار
[MaxLength(9)] [MaxLength(9)]
public string? bpn { get { return Customer.PassportNumber; } } public string? bpn { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.PassportNumber; } }
//کد شعبه فروشنده //کد شعبه فروشنده
[MaxLength(9)] [MaxLength(9)]
public string? sbc { get { return company?.BranchID; } } public string? sbc { get { return company?.BranchID; } }

View File

@@ -33,13 +33,14 @@ namespace Back.Services
public int? Inp { get { return _invoice.inp ?? 1; } } public int? Inp { get { return _invoice.inp ?? 1; } }
public int? Ins { get { return _invoice.ins ?? 1; } } public int? Ins { get { return _invoice.ins ?? 1; } }
public string? Tins { get { return string.IsNullOrEmpty(_invoice.tins) ? null : _invoice.tins; } } 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 public string? Bid
{ {
get get
{ {
return level == 10 || string.IsNullOrEmpty(_invoice.bid) || !string.IsNullOrEmpty(_invoice.tinb) 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? 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; } } public string? Sbc { get { return string.IsNullOrEmpty(_invoice.sbc) ? null : _invoice.sbc; } }

View File

@@ -52,6 +52,7 @@ namespace Back.Validations
RuleFor(r => r.Item2.PatternID) RuleFor(r => r.Item2.PatternID)
.Custom((PatternID, context) => .Custom((PatternID, context) =>
{ {
if (PatternID != null && PatternID > 0 && !patternRepo.Get(w => w.Status && w.ID == PatternID).AnyAsync().Result) if (PatternID != null && PatternID > 0 && !patternRepo.Get(w => w.Status && w.ID == PatternID).AnyAsync().Result)
context.AddFailure("الگوی صورتحساب معتبر نیست"); context.AddFailure("الگوی صورتحساب معتبر نیست");
}); });
@@ -61,9 +62,17 @@ namespace Back.Validations
{ {
if (model.Item2.CustomerID == null || model.Item2.CustomerID <= 0) if (model.Item2.CustomerID == null || model.Item2.CustomerID <= 0)
context.AddFailure("برای صدور صورتحساب باید مشتری تعریف شود"); context.AddFailure("برای صدور صورتحساب باید مشتری تعریف شود");
else if (!servCustomer.ExistCustomerByCustomerID(model.Item2.CustomerID, model.Item1).Result) else if (!servCustomer.ExistCustomerByCustomerID(model.Item2.CustomerID, model.Item1).Result)
context.AddFailure("مشتری یافت نشد"); 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) RuleFor(r => r.Item2.InvoiceDate)

View File

@@ -16,7 +16,9 @@ namespace Shared.DTOs
[Display(Name = "حقیقی با شناسه ملی")] [Display(Name = "حقیقی با شناسه ملی")]
genuineByMeliCode = 5, genuineByMeliCode = 5,
[Display(Name = "اتباع عیر ایرانی با شناسه ملی")] [Display(Name = "اتباع عیر ایرانی با شناسه ملی")]
NonIranianNationalsByMeliCode = 6 NonIranianNationalsByMeliCode = 6,
[Display(Name = "بدون هویت")]
WithoutIdentity = 7
} }
} }

View File

@@ -54,6 +54,7 @@
<option value="3">مشارکت مدنی</option> <option value="3">مشارکت مدنی</option>
<option value="4">اتباع غیر ایرانی با کد اقتصادی</option> <option value="4">اتباع غیر ایرانی با کد اقتصادی</option>
<option value="6">اتباع غیر ایرانی با شناسه ملی</option> <option value="6">اتباع غیر ایرانی با شناسه ملی</option>
<option value="7">بدون هویت</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -32,6 +32,7 @@
<option value="3">مشارکت مدنی</option> <option value="3">مشارکت مدنی</option>
<option value="4">اتباع غیر ایرانی با کد اقتصادی</option> <option value="4">اتباع غیر ایرانی با کد اقتصادی</option>
<option value="6">اتباع غیر ایرانی با شناسه ملی</option> <option value="6">اتباع غیر ایرانی با شناسه ملی</option>
<option value="7">بدون هویت</option>
</select> </select>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">