This commit is contained in:
mmrbnjd
2024-05-27 18:01:50 +03:30
parent ef530f0d81
commit e8c5dfcda4
10 changed files with 182 additions and 93 deletions

View File

@@ -59,8 +59,8 @@ namespace Back.Controllers
// return BadRequest(item);
//-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
var claim = "64"/* HttpContext.User.Claims.First(c => c.Type == "UserID")*/;
var UserID = claim;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
//-----Validaton

View File

@@ -11,6 +11,7 @@ namespace Back.Data.Contracts
public interface IAsyncRepository<T>
{
IQueryable<T> GetAll();
IQueryable<T> TrackingGet(Expression<Func<T, bool>> predicate);
IQueryable<T> Get(Expression<Func<T, bool>> predicate);
IQueryable<T> Get(Expression<Func<T, bool>> predicate = null,
Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,

View File

@@ -30,10 +30,14 @@ namespace Back.Data.Infrastructure.Repository
public IQueryable<T> Get(Expression<Func<T, bool>> predicate)
{
var query = _query.AsQueryable();
query = query.AsNoTracking();
// query = query.AsNoTracking();
return query.Where(predicate).AsQueryable();
}
public IQueryable<T> TrackingGet(Expression<Func<T, bool>> predicate)
{
var query = _query.AsQueryable();
return query.Where(predicate).AsQueryable();
}
public IQueryable<T> Get(
Expression<Func<T, bool>> predicate = null,
Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
@@ -80,9 +84,18 @@ namespace Back.Data.Infrastructure.Repository
public async Task<T> AddAsync(T entity)
{
await _query.AddAsync(entity);
await _dbContext.SaveChangesAsync();
return entity;
try
{
await _query.AddAsync(entity);
await _dbContext.SaveChangesAsync();
return entity;
}
catch (Exception ex)
{
throw;
}
}
public T? Add(T entity)
{
@@ -109,7 +122,7 @@ namespace Back.Data.Infrastructure.Repository
{
try
{
_dbContext.Entry(entity).State = EntityState.Modified;
var result = await _dbContext.SaveChangesAsync();
return result > 0;

View File

@@ -26,7 +26,7 @@ namespace Back.Data.Models
public long? Indati2m { get { return new DateTimeOffset(InvoiceDate.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
//نوع صورتحساب
[MaxLength(1)]
public int? inty { get { return pattern.BillType.inty; } }
public int? inty { get { return pattern?.BillType.inty; } }
//الگوی صورتحساب
[MaxLength(2)]
public int? inp { get { return pattern?.inp; } }
@@ -102,7 +102,7 @@ namespace Back.Data.Models
public InvoiceType invoiceType { get; set; }
//شماره منحصر به فرد مالیاتی
[MaxLength(22)]
public string? taxid { get; set; }
public string? taxid { get; set; }
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
[MaxLength(22)]
public string? irtaxid { get; set; }
@@ -160,13 +160,13 @@ namespace Back.Data.Models
public virtual Customer Customer { get; set; }
[ForeignKey("LastChangeUserID")]
public virtual User user { get; set; }
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
public virtual ICollection<InvoiceItem>? invoiceDetails { get; set; }
[ForeignKey("BillReference")]
public virtual Invoice? invoice { get; set; }
public virtual ICollection<InvoicePayment> payments { get; set; }
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
public virtual ICollection<SentTax> sentTax { get; set; }
[ForeignKey("PatternsID")]
public virtual ICollection<InvoicePayment>? payments { get; set; }
public virtual ICollection<InvoiceStatusChang>? invoiceStatusChangs { get; set; }
public virtual ICollection<SentTax>? sentTax { get; set; }
[ForeignKey("PatternID")]
public virtual Pattern? pattern { get; set; }
[ForeignKey("CompanyID")]
public virtual Company? company { get; set; }

View File

@@ -6,6 +6,7 @@ using Back.Services;
using Back.Validations;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using System.Text;
using TaxPayer.Infrastructure.Persistence;
@@ -16,7 +17,34 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(option =>
{
option.SwaggerDoc("v1", new OpenApiInfo { Title = "TaxPayer API", Version = "Preview" });
option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please enter a valid token",
Name = "Authorization",
Type = SecuritySchemeType.Http,
BearerFormat = "JWT",
Scheme = "Bearer"
});
option.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type=ReferenceType.SecurityScheme,
Id="Bearer"
}
},
new string[]{}
}
});
});
builder.Services.AddDbContext<SqlDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
@@ -27,7 +55,7 @@ builder.Services.AddScoped<Back.Services.ServBase>();
builder.Services.AddScoped<MobileValidation> ();
builder.Services.AddScoped<Service.Main>();
builder.Services.AddScoped<servTicket > ();
builder.Services.AddScoped < ServValidatinMsg>();
builder.Services.AddScoped<ServValidatinMsg>();
builder.Services.AddScoped<GetVerificationValidation> ();
builder.Services.AddScoped<GetVerificationValidation>();
builder.Services.AddScoped<CheckPermission>();

View File

@@ -17,10 +17,10 @@ namespace Back.Services
}
private async Task<bool> AllowPermissionInCompany(int CompanyID,int PermissionID,int Allowednumber = 1)
{
PermissionPeriod? permissionPeriod = _repoPermissionPeriod
.Get(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID && (!w.IsLocked.HasValue || !w.IsLocked.Value))
.FirstOrDefault();
PermissionPeriod permissionPeriod =await _repoPermissionPeriod
.TrackingGet(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID && (!w.IsLocked.HasValue || !w.IsLocked.Value)
)
.FirstOrDefaultAsync();
if (permissionPeriod == null)
return false;
@@ -51,7 +51,8 @@ namespace Back.Services
{
return await _repoPermissionUser
.Get(w => w.RolUser.UserID == UserID && w.RolUser.CompanyID == CompanyID && w.PermissionID==PermissionID)
.TrackingGet(w => w.RolUser.UserID == UserID && w.RolUser.CompanyID == CompanyID && w.PermissionID==PermissionID
)
.AnyAsync();
@@ -59,10 +60,10 @@ namespace Back.Services
}
public async Task<bool> ExtensionofAccess(int CompanyID, int PermissionID, string value)
{
PermissionPeriod? permissionPeriod = _repoPermissionPeriod
.Get(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID
PermissionPeriod permissionPeriod = await _repoPermissionPeriod
.TrackingGet(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID
&& (!w.IsLocked.HasValue || !w.IsLocked.Value))
.FirstOrDefault();
.FirstOrDefaultAsync();
//تعداد
@@ -76,8 +77,8 @@ namespace Back.Services
}
try
{
return await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
var res= await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
return res;
//SysLog log = new SysLog()
//{
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,

View File

@@ -107,7 +107,7 @@ namespace Back.Services
if (item.ID == null || item.ID <= 0)
{
if (await _checkPermission.ExtensionofAccess(item.CompanyID, 5, "-1"))
if (await _checkPermission.ExtensionofAccess(item.CompanyID, 4, "-1"))
return await _CODRepo.AddBoolResultAsync(item);
return false;

View File

@@ -136,11 +136,11 @@ namespace Back.Services
invoice.PreparedtoSendtoTax = false;
if (calculate)
{
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
{
//if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
// {
var item= await _invoiceRepo.AddAsync(invoice);
return item.ID;
}
// }
return -1;
}

View File

@@ -2,6 +2,8 @@
@using Shared.DTOs
@inject HttpClientController hc;
@inject Fixedvalues fv;
<ConfirmDialog @ref="dialog" />
<form>
@* alert *@
<div class="row">
@@ -13,10 +15,11 @@
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<div class="form-group col-md-5">
<label class="col-sm-4 col-form-label" style="color:red" for="inputcod">کالا</label>
<select @bind="itemDTO.CODID" @bind:after="() =>
<select @bind="itemDTO.CODID" @bind:after="async () =>
{
await AfterAsync();
if(itemDTO.ID==null)
itemDTO.vra=cods.Where(w=>w.ID==itemDTO.CODID).Select(s=>s.Tax).FirstOrDefault();
}" class="form-control" aria-label="Default select example" id="inputcod">
@@ -49,41 +52,47 @@
</select>
</div>
<div class="form-group col-md-3">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div>
<div class="form-group col-md-3">
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
<InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ کل</label>
<InputNumber @bind-Value="itemDTO.prdis" type="text" class="form-control" id="inputfee" placeholder="مبلغ کل" readonly />
</div>
<div class="col-md-4">
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
<InputNumber @bind-Value="itemDTO.dis" type="text" @bind-Value:after="AfterAsync" class="form-control" id="inputdis" placeholder="مبلغ تخفیف" />
</div>
<div class="col-md-4">
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">نرخ مالیات</label>
<InputNumber @bind-Value="itemDTO.vra" type="text" class="form-control" id="inputvra" placeholder="نرخ مالیات" readonly />
</div>
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
<InputNumber @bind-Value="itemDTO.vam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div>
<div class="form-group col-md-4">
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
<CurrencyInput TValue="decimal" @bind-Value="@itemDTO.fee" @bind-Value:after="AfterAsync" Locale="fa-Ir" Placeholder="مبلغ واحد" />
@* <InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" /> *@
</div>
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ کل</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.prdis" Locale="fa-Ir" Placeholder="مبلغ کل" readonly />
</div>
</div>
<div class="row g-3">
<div class="col-md-6">
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.dis" Locale="fa-Ir" @bind-Value:after="AfterAsync" Placeholder="مبلغ تخفیف" />
</div>
<div class="col-md-6">
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.adis" Locale="fa-Ir" Placeholder="مبلغ بعد تخفیف" readonly />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.vam" Locale="fa-Ir" Placeholder="مبلغ مالیات" readonly />
</div>
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ نهایی" readonly />
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.tsstam" Locale="fa-Ir" Placeholder="مبلغ نهایی" readonly />
</div>
</div>
</form>
@@ -100,13 +109,15 @@ else
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
}
@code {
[Inject] ToastService ToastService { get; set; } = default!;
private ConfirmDialog dialog = default!;
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
@@ -233,22 +244,22 @@ else
return;
}
var rsp = await hc.Put<InvoiceItemDTO>($"InvoiceItem/UpdateItem/{InvoiceID}", itemDTO);
if (rsp.IsSuccessStatusCode)
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.update;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
result.Status = ComponentStatus.success;
result.Action = ComponentAction.update;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
public async Task OnClickAdd()
{
@@ -281,19 +292,40 @@ else
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
private async Task ShowConfirmationDeleteAsync()
{
if (itemDTO.ID != null && itemDTO.ID > 0 && InvoiceID != null && InvoiceID > 0)
{
var confirmation = await dialog.ShowAsync(
title: "عملیات حذف آیتم صورتحساب",
message1: $"از حذف آیتم {itemDTO.ID} از صورتحساب {InvoiceID}",
message2: "اطمینان دارید?");
if (confirmation)
{
await OnClickDelete();
}
else
{
ToastService.Notify(new ToastMessage(ToastType.Secondary, $"عملیات حذف متوقف شد"));
}
}
}
}

View File

@@ -27,7 +27,8 @@
</div>
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" for="inputinvoiceTypeTitle">نوع</label>
<select @bind="invoice.invoiceType" class="form-control" aria-label="Default select example" id="inputinvoiceTypeTitle">
@if (InvoiceID == 0 || InvoiceID == null ? false : true){
<select @bind="invoice.invoiceType" disabled class="form-control" aria-label="Default select example" id="inputinvoiceTypeTitle">
@if (!invoice.invoiceType.HasValue)
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
@@ -53,7 +54,15 @@
}
</select>
</select>
}
else
{
<select @bind="invoice.invoiceType" class="form-control" aria-label="Default select example" disabled id="inputinvoiceTypeTitle">
<option value="10" style="color: #b5b5b5" selected>پیشنهاد قیمت</option>
</select>
}
</div>
<div class="form-group col-md-2">
@@ -121,6 +130,9 @@
<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)
{
<br /> <hr class="hr" />
<div class="row g-3">
<Tabs NavStyle="NavStyle.VerticalUnderline">
@@ -160,19 +172,21 @@
</Tabs>
</div>
}
<hr class="hr" />
<br />
<div class="row g-3">
<div class="form-group col-md-8">
<label class="col-sm-4 col-form-label" for="inputdes">توضیحات</label>
<div class="form-group col-md-6">
<label class="col-form-label" for="inputdes">توضیحات</label>
<InputText @bind-Value="invoice.Des" type="text" class="form-control" id="inputdes" placeholder="توضیحات" />
</div>
<div class="form-group col-md-2">
<label class="col-sm-5 col-form-label" for="inputUdate">آخرین ویرایش</label>
<label class="col-form-label" for="inputUdate">آخرین ویرایش</label>
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
</div>
<div class="form-group col-md-2">
<div class="form-group col-md-4">
<br />
@if (invoice.ID == 0)
{
@@ -411,8 +425,8 @@
{
CustomerID = invoice.CustomerID,
Des = invoice.Des,
InvoiceDate = invoice.InvoiceDate,
InvoicIssueDate = invoice.InvoicIssueDate,
InvoiceDate = invoice.InvoiceDate.Replace("/",""),
InvoicIssueDate = invoice.InvoicIssueDate.Replace("/", ""),
PatternID = invoice.PatternID,
Title = invoice.Title
});