This commit is contained in:
mmrbnjd
2025-01-25 12:57:07 +03:30
parent 48072d6e00
commit b57839a212
14 changed files with 2229 additions and 74 deletions

View File

@@ -52,6 +52,17 @@ namespace Back.Controllers
});
}
[HttpGet("GetVra/{ID}")]
public async Task<ActionResult<decimal>> GetVra(int ID)
{
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
var cod = await _servCOD.GetCodByCodID(ID, user.RolUsers.First().CompanyID);
if(cod!=null)
return Ok(cod.TaxRate);
return NotFound();
}
[HttpGet("GetAllForidName")]
public async Task<ActionResult<List<CODIdName<int>>>> GetAllForidName()
{

View File

@@ -234,40 +234,31 @@ namespace Back.Controllers
//{
// return BadRequest(new List<string> { $"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود" });
//}
if (invoice.invoiceType!=InvoiceType.Cancellation)
{
bool InvoiceHasaRemittanceBillReference = invoice.BillReference.HasValue && await _remittanceService.HasaRemittance(invoice.BillReference.Value);
foreach (var item in invoice.invoiceDetails)
{
if (await _remittanceService.HasaRemittance(invoice.ID, item.CODID))
{
await _receiptService.ADD(new Shared.DTOs.Warehouse.ReceiptDto()
{
CODID = item.CODID,
Count = item.am.GetValueOrDefault(),
Date = DateTime.Now.ConvertMiladiToShamsi(),
ForSale = true,
InvoiceID = item.InvoiceID,
Type = TypeReceipt.Shopping,
info = $"حذف صورتحساب {item.InvoiceID}",
//if (invoice.invoiceType!=InvoiceType.Cancellation)
//{
//bool InvoiceHasaRemittanceBillReference = invoice.BillReference.HasValue && await _remittanceService.HasaRemittance(invoice.BillReference.Value);
await _receiptService.DeleteByInvoiceID(invoice.ID, user.RolUsers.First().CompanyID);
await _remittanceService.DeleteByInvoiceID(invoice.ID,user.RolUsers.First().CompanyID);
//foreach (var item in invoice.invoiceDetails)
//{
// if (await _remittanceService.HasaRemittance(invoice.ID, item.CODID))
// {
// await _receiptService.ADD(new Shared.DTOs.Warehouse.ReceiptDto()
// {
// CODID = item.CODID,
// Count = item.am.GetValueOrDefault(),
// Date = DateTime.Now.ConvertMiladiToShamsi(),
// ForSale = true,
// InvoiceID = item.InvoiceID,
// Type = TypeReceipt.Shopping,
// info = $"حذف صورتحساب {item.InvoiceID}",
}, user.RolUsers.First().CompanyID, true);
// }, user.RolUsers.First().CompanyID, true);
//if (invoice.BillReference.HasValue && InvoiceHasaRemittanceBillReference)
//{
// await _remittanceService.ADD(new Shared.DTOs.Warehouse.RemittanceDto()
// {
// CODID = item.CODID,
// Count = item.am.GetValueOrDefault(),
// Date = DateTime.Now.ConvertMiladiToShamsi(),
// InvoiceID = invoice.BillReference.Value,
// Type = TypeRemittance.Sale,
// info = $"حواله خودکار از صورتحساب {invoice.BillReference.Value}",
// });
//}
}
}
}
// }
//}
// }
invoice.LastChangeUserID = Convert.ToInt32(UserID);
//----Update and sendResult

View File

@@ -100,6 +100,7 @@ namespace Back.Controllers
return Ok(await _servInvoiceItem.Add(new InvoiceItem
{
vra=model.item.vra,
am = model.item.am,
fee = model.item.fee,
dis = model.item.dis,
@@ -196,6 +197,7 @@ namespace Back.Controllers
invoiceitem.fee = model.item.fee;
invoiceitem.dis = model.item.dis;
invoiceitem.CODID = model.item.CODID;
invoiceitem.vra = model.item.vra;
}
if (await _servInvoice.UpdateInvoice(invoice))

View File

@@ -64,18 +64,16 @@ namespace Back.Data.Models
//مبلغ قبل از تخفیف
[MaxLength(18)]
public decimal? prdis { get { return am * fee; } }
//نرخ مالیات بر ازش افزوده
[MaxLength(5)]
public decimal? vra { get { return
//صادرات مالیات ندارد
invoice?.pattern?.ID == 10 ? 0
:cODItem != null ? cODItem.TaxRate
: null; } }
//واحد اندازه گیری عنوان
public string? unitTitle { get { return cODItem!=null ? cODItem.CODUnit.Title : null; } }
#endregion
#region fild
//نرخ مالیات بر ازش افزوده
[MaxLength(5)]
public decimal? vra { get; set; }
//تعداد/مقدار
[MaxLength(36)]
public decimal? am { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Back.Migrations
{
/// <inheritdoc />
public partial class invoicetb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "vra",
table: "InvoiceItems",
type: "decimal(18,2)",
maxLength: 5,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "vra",
table: "InvoiceItems");
}
}
}

View File

@@ -584,6 +584,7 @@ namespace Back.Migrations
b.Property<decimal?>("_cfee")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("am")
.HasMaxLength(36)
.HasColumnType("decimal(18,2)");
@@ -668,6 +669,10 @@ namespace Back.Migrations
.HasMaxLength(18)
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("vra")
.HasMaxLength(5)
.HasColumnType("decimal(18,2)");
b.HasKey("ID");
b.HasIndex("CODID");

View File

@@ -33,7 +33,7 @@ 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 || _invoice.tob==0 ? 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
@@ -96,14 +96,22 @@ namespace Back.Services
public decimal? Nw { get { return level == 10 ? bitem.nw : null; } }
public decimal? Fee { get { return level == 4 ? null : bitem.fee; } }
public decimal? Cfee { get { return bitem.cfee == 0 || level == 8 || level == 10 ? null : bitem.cfee; } }
public string? Cut { get{ return level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut; } }
public string? Cut { get { return level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut; } }
public decimal? Exr { get { return level == 8 ? null : bitem.exr; } }
public decimal? Ssrv { get { return level == 10 ? bitem.ssrv : null; } }
public decimal? Sscv { get { return level == 10 ? bitem.sscv : null; } }
public decimal? Prdis { get { return level == 10 ? null : bitem.prdis; } }
public decimal? Dis { get { return level == 10 ? null : bitem.dis; } }
public decimal? Adis { get { return level == 10 ? null : bitem.adis; } }
public decimal? Vra { get { return bitem.vra; } }
public decimal? Vra
{
get
{
return level == 14 ? 0
:
bitem.vra;
}
}
public decimal? Vam { get { return bitem.vam; } }
public string? Odt { get { return string.IsNullOrEmpty(bitem.odt) ? null : bitem.odt; } }
public decimal? Odr { get { return bitem.odr; } }

View File

@@ -33,6 +33,7 @@ namespace Back.Services.Warehouse
ForSale = item.ForSale,
info = item.info,
Type = item.Type,
InvoiceID=item.InvoiceID,
Deleted = false
};
var returnmodel = await _ReceiptRepo.AddAsync(model);
@@ -88,7 +89,9 @@ namespace Back.Services.Warehouse
var models = await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.cODItem.CompanyID == CompanyID && !w.Deleted).ToListAsync();
foreach (var model in models)
model.Deleted = true;
return await _ReceiptRepo.UpdateRangeAsync(models);
if (models.Any())
return await _ReceiptRepo.UpdateRangeAsync(models);
return true;
}

View File

@@ -73,8 +73,9 @@ namespace Back.Services.Warehouse
var models = await _ReceiptRepo.Get(w => w.InvoiceID == InvoiceID && w.cODItem.CompanyID == CompanyID && !w.Deleted).ToListAsync();
foreach (var model in models)
model.Deleted = true;
if(models.Any())
return await _ReceiptRepo.UpdateRangeAsync(models);
return true;
}
public async Task<bool> DeleteByCODIDAndInvoiceID(int InvoiceID, int CODID, int CompanyID)
{

View File

@@ -37,9 +37,13 @@ namespace Back.Validations
if (!servCOD.ExistCodByCompanyID(model.Item3.CODID, model.Item1).Result)
context.AddFailure("کالا یافت نشد");
}
else context.AddFailure("کالا صحیح نمی باشد");
if (!model.Item3.vra.HasValue)
context.AddFailure("نرخ مالیات را وارد کنید");
});
RuleFor(r => r.Item3.am)
.NotEmpty().WithMessage("تعداد مشخص نشده")