From 95c0a6a93f37f68f531176ecb75aede42033e34a Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Tue, 6 Aug 2024 17:24:25 +0330 Subject: [PATCH] tax --- Back/Back.csproj | 4 +- Back/Controllers/TaxPayerController.cs | 264 +++--------------- Back/Data/Models/Invoice.cs | 7 +- Back/Services/servInvoice.cs | 4 +- Back/Services/servTaxPayer.cs | 5 + Back/Validations/TaxSystemRules.cs | 9 + Shared/DTOs/InvoiceDtos.cs | 5 + TaxPayerFull/Pages/UserPanel/Invoice.razor | 4 +- .../Pages/UserPanel/InvoiceItem.razor | 14 +- TaxPayerFull/Program.cs | 4 +- 10 files changed, 88 insertions(+), 232 deletions(-) create mode 100644 Back/Validations/TaxSystemRules.cs diff --git a/Back/Back.csproj b/Back/Back.csproj index fd97cd7..0f43de6 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -23,7 +23,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -36,7 +36,7 @@ - ..\..\Dlls\Service.dll + C:\Dlls\Service.dll diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index 5d0b40f..156f865 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -188,22 +188,47 @@ namespace Back.Controllers if (result.inty == 1 && result.inp == 1) header = new InvoiceHeaderDto { - //نوع شخص خریدار - Tob = result.tob, + //شماره منحصر به فرد مالیاتی + Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()), + //زمان صدور + Indatim = result.indatim ?? null, + //زمان ایجاد + Indati2m = result.Indati2m ?? null, // صورتحساب نوع * Inty = result.inty ?? 1, + //سریال صورت حساب + Inno = string.IsNullOrEmpty(result.inno) ? null : result.inno, + //شماره منحصر به فرد مالیاتی صورتحساب مرجع + Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid + : result.invoiceType == InvoiceType.Cancellation ? result.taxid : null, //الگوی صورتحساب * Inp = result.inp ?? 1, //موضوع صورتحساب * Ins = result.ins ?? 1, - //شماره منحصر به فرد مالیاتی - Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()), - //سریال صورت حساب - Inno = string.IsNullOrEmpty(result.inno) ? null : result.inno, //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد Tins = string.IsNullOrEmpty(result.tins) ? null : result.tins, + //نوع شخص خریدار + Tob = result.tob, + //شماره/شناسه ملی/شناسه مشارکت مدنی / کد فراگیر + Bid = string.IsNullOrEmpty(result.bid) ? null : result.bid, + //شماره اقتصادی خریدار + Tinb = string.IsNullOrEmpty(result.tinb) ? null : result.tinb, + //کد شعبه فروشنده + Sbc = string.IsNullOrEmpty(result.sbc) ? null : result.sbc, + //کد پستی خریدار + Bpc = string.IsNullOrEmpty(result.bpc) ? null : result.bpc, + //کد شعبه خریدار + Bbc = string.IsNullOrEmpty(result.bbc) ? null : result.bbc, + //شماره پروانه گمرکی + Scln = string.IsNullOrEmpty(result.scln) ? null : result.scln, + //کد گمرک محل اظهار فروشنده + Scc = string.IsNullOrEmpty(result.scc) ? null : result.scc, + //شناسه یکتای ثبت قزارداد فروشنده + Crn = string.IsNullOrEmpty(result.crn) ? null : result.crn, //مجموع مبلغ قبل از کسر تخفیف Tprdis = result.tprdis ?? null, + //مجموع تخفیفات + Tdis = result.tdis ?? null, // مجموع مبلغ پس از کسر تخفیف Tadis = result.tadis ?? null, //مجموع مالیات بر ارزش افزوده @@ -218,129 +243,15 @@ namespace Back.Controllers Cap = result.cap ?? null, //پرداختی نسیه Insp = result.insp ?? null, - //مجموع تخفیفات - Tdis = result.tdis ?? null, - //شماره منحصر به فرد مالیاتی صورتحساب مرجع - Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null, - //شماره اقتصادی خریدار - Tinb = string.IsNullOrEmpty(result.tinb) ? null : result.tinb , - //زمان صدور - Indatim = result.indatim ?? null, - //زمان ایجاد - Indati2m = result.Indati2m ?? null, - //کد شعبه خریدار - Bbc = string.IsNullOrEmpty(result.bbc) ? null : result.bbc, + //مجموع سهم مالیات بر ارزش افزوده از پرداخت Tvop = result.tvop ?? null, - Crn = string.IsNullOrEmpty(result.crn) ? null : result.crn , + //مالیات موضوع 17 Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax), - Scc = string.IsNullOrEmpty(result.scc) ? null : result.scc , - Scln = string.IsNullOrEmpty(result.scln) ? null : result.scln , - Bid = string.IsNullOrEmpty(result.bid) ? null : result.bid , + + + }; - //if (header.Inty == 1 && header.Inp == 2) - // header = new InvoiceHeaderDto - // { - // //نوع شخص خریدار - // Tob = result.tob, - // // صورتحساب نوع * - // Inty = result.inty ?? 1, - // //الگوی صورتحساب * - // Inp = result.inp ?? 1, - // //موضوع صورتحساب * - // Ins = result.ins ?? 1, - // //شماره منحصر به فرد مالیاتی - // Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()), - // //سریال صورت حساب - // Inno = result.inno ?? null, - // //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد - // Tins = result.tins ?? null, - // //مجموع مبلغ قبل از کسر تخفیف - // Tprdis = result.tprdis ?? null, - // // مجموع مبلغ پس از کسر تخفیف - // Tadis = result.tadis ?? null, - // //مجموع مالیات بر ارزش افزوده - // Tvam = result.tvam ?? null, - // // مجموع سایر مالیات، عوارض و وجوه قانونی - // Todam = result.todam ?? null, - // //صورتحساب مجموع - // Tbill = result.tbill ?? null, - // // تسویه روش - // Setm = result.setm ?? null, - // //نقدی پرداختی مبلغ - // Cap = result.cap ?? null, - // //پرداختی نسیه - // Insp = result.insp ?? null, - // //مجموع تخفیفات - // Tdis = result.tdis ?? null, - // //شماره منحصر به فرد مالیاتی صورتحساب مرجع - // Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null, - // //شماره اقتصادی خریدار - // Tinb = result.tinb ?? null, - // //زمان صدور - // Indatim = result.indatim ?? null, - // //زمان ایجاد - // Indati2m = result.Indati2m ?? null, - // //کد شعبه خریدار - // Bbc = result.bbc ?? null, - // Tvop = result.tvop ?? null, - // Crn = result.crn ?? null, - // Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax), - // Scc = result.scc ?? null, - // Scln = result.scln ?? null, - // Bpn = result.bpn ?? null, - // Bid = result.bid ?? null, - // }; - //if (header.Inty == 1 && header.Inp == 3) - // header = new InvoiceHeaderDto - // { - // //نوع شخص خریدار - // Tob = result.tob, - // // صورتحساب نوع * - // Inty = result.inty ?? 1, - // //الگوی صورتحساب * - // Inp = result.inp ?? 1, - // //موضوع صورتحساب * - // Ins = result.ins ?? 1, - // //شماره منحصر به فرد مالیاتی - // Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()), - // //سریال صورت حساب - // Inno = result.inno ?? null, - // //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد - // Tins = result.tins ?? null, - // //مجموع مبلغ قبل از کسر تخفیف - // Tprdis = result.tprdis ?? null, - // // مجموع مبلغ پس از کسر تخفیف - // Tadis = result.tadis ?? null, - // //مجموع مالیات بر ارزش افزوده - // Tvam = result.tvam ?? null, - // // مجموع سایر مالیات، عوارض و وجوه قانونی - // Todam = result.todam ?? null, - // //صورتحساب مجموع - // Tbill = result.tbill ?? null, - // // تسویه روش - // Setm = result.setm ?? null, - // //نقدی پرداختی مبلغ - // Cap = result.cap ?? null, - // //پرداختی نسیه - // Insp = result.insp ?? null, - // //مجموع تخفیفات - // Tdis = result.tdis ?? null, - // //شماره منحصر به فرد مالیاتی صورتحساب مرجع - // Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null, - // //شماره اقتصادی خریدار - // Tinb = result.tinb ?? null, - // //زمان صدور - // Indatim = result.indatim ?? null, - // //زمان ایجاد - // Indati2m = result.Indati2m ?? null, - // //کد شعبه خریدار - // Bbc = result.bbc ?? null, - // Tvop = result.tvop ?? null, - // Crn = result.crn ?? null, - // Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax), - // Bid = result.bid ?? null, - // }; else return BadRequest(new List { "این الگو فعلا در دسترس نمی باشد" }); #endregion header List InvoiceBody = new List(); @@ -379,100 +290,15 @@ namespace Back.Controllers Odt = string.IsNullOrEmpty(bitem.odt) ? null : bitem.odt, Odr = bitem.odr, Odam = bitem.odam, - Olt =string.IsNullOrEmpty(bitem.olt) ? null : bitem.olt, + Olt = string.IsNullOrEmpty(bitem.olt) ? null : bitem.olt, Olr = bitem.olr, Olam = bitem.olam, Cop = bitem.cop, Vop = bitem.vop, - Bsrn =string.IsNullOrEmpty(bitem.bsrn) ? null :bitem.bsrn, + Bsrn = string.IsNullOrEmpty(bitem.bsrn) ? null : bitem.bsrn, }; - - //else if (header.Inty == 1 && header.Inp == 2) - // item = new InvoiceBodyDto - // { - // //شناسه کالا / خدمت - // Sstid = bitem.sstid, - // //شرح کاال/خدمت - // Sstt = bitem.sstt, - // //واحد اندازه گیری - // Mu = bitem.mu, - // // تعداد - // Am = bitem.am, - // // مبلغ واحد - // Fee = bitem.fee, - // //مبلغ قبل از تخفیف - // Prdis = bitem.prdis, - // //مبلغ تخفیف - // Dis = bitem.dis, - // //مبلغ بعد از تخفیف - // Adis = bitem.adis, - // //نرخ مالیات بر ارزش افزوده - // Vra = bitem.vra, - // //مبلغ مالیات بر ارزش افزوده - // Vam = bitem.vam, - // // مبلغ کل کالا / خدمت - // Tsstam = bitem.tsstam, - // Cfee = bitem.cfee, - // Cut = bitem.cut, - // Exr = bitem.exr, - // Odt = bitem.odt, - // Odr = bitem.odr, - // Odam = bitem.odam, - // Olt = bitem.olt, - // Olr = bitem.olr, - // Olam = bitem.olam, - // Cop = bitem.cop, - // Vop = bitem.vop, - // Bsrn = bitem.bsrn, - - - // }; - - //else if (header.Inty == 1 && header.Inp == 3) - // item = new InvoiceBodyDto - // { - // //شناسه کالا / خدمت - // Sstid = bitem.sstid, - // //شرح کاال/خدمت - // Sstt = bitem.sstt, - // //واحد اندازه گیری - // Mu = bitem.mu, - // // تعداد - // Am = bitem.am, - // // مبلغ واحد - // Fee = bitem.fee, - // //مبلغ قبل از تخفیف - // Prdis = bitem.prdis, - // //مبلغ تخفیف - // Dis = bitem.dis, - // //مبلغ بعد از تخفیف - // Adis = bitem.adis, - // //نرخ مالیات بر ارزش افزوده - // Vra = bitem.vra, - // //مبلغ مالیات بر ارزش افزوده - // Vam = bitem.vam, - // // مبلغ کل کالا / خدمت - // Tsstam = bitem.tsstam, - // Cfee = bitem.cfee, - // Cut = bitem.cut, - // Exr = bitem.exr, - // Odt = bitem.odt, - // Odr = bitem.odr, - // Odam = bitem.odam, - // Olt = bitem.olt, - // Olr = bitem.olr, - // Olam = bitem.olam, - // Cop = bitem.cop, - // Vop = bitem.vop, - // Bsrn = bitem.bsrn, - // Consfee = bitem.consfee, - // Spro = bitem.spro, - // Bros = bitem.bros, - // Tcpbs = bitem.tcpbs, - // }; - #endregion InvoiceBody.Add(item); } @@ -487,7 +313,7 @@ namespace Back.Controllers { foreach (var item in responseModel.Body.Result) { - + var ressenttax = new SentTax { @@ -498,12 +324,12 @@ namespace Back.Controllers ReferenceNumber = item.ReferenceNumber, uId = item.Uid, SentStatus = SentStatus.Send, - InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented,new JsonSerializerSettings - { + InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings + { PreserveReferencesHandling = PreserveReferencesHandling.Objects }), ResponseModel = JsonConvert.SerializeObject(responseModel) - + }; await _servTaxPayer.AddSentTax(ressenttax); } @@ -553,7 +379,7 @@ namespace Back.Controllers return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); DataInSendTaxDto desData = new DataInSendTaxDto(); - + if (item.SentStatus == SentStatus.Unsuccessful && !string.IsNullOrEmpty(item.ErrorsModel)) { @@ -562,13 +388,13 @@ namespace Back.Controllers InquiryResultModel inquiryResult = JsonConvert.DeserializeObject(item.InquiryResultModel); if (inquiryResult.Data != null) { - + desData = new DataInSendTaxDto(); desData.SentStatus = SentStatus.Unsuccessful; desData.error = inquiryerrorResult; - + } return Ok(desData); } diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs index 4703ebc..a9fab92 100644 --- a/Back/Data/Models/Invoice.cs +++ b/Back/Data/Models/Invoice.cs @@ -16,9 +16,7 @@ namespace Back.Data.Models #endregion #region autofild - //سریال صورتحساب داخلی حافظه مالیاتی - [MaxLength(10)] - public string? inno { get { return ID.ToString("0000000000"); } } + //تاریخ و زمان صدور صورتحساب )میالدی( [MaxLength(13)] public long? indatim { get { return new DateTimeOffset(InvoicIssueDate.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } } @@ -98,6 +96,9 @@ namespace Back.Data.Models #endregion #region fild + //سریال صورتحساب داخلی حافظه مالیاتی + [MaxLength(10)] + public string? inno { get; set; } public string Title { get; set; } public string? Des { get; set; } public InvoiceType invoiceType { get; set; } diff --git a/Back/Services/servInvoice.cs b/Back/Services/servInvoice.cs index db4c564..65a0a5d 100644 --- a/Back/Services/servInvoice.cs +++ b/Back/Services/servInvoice.cs @@ -63,7 +63,7 @@ namespace Back.Services tdis = item.tdis, tvam = item.tvam, Udate = item.Udate.ShamciToFormatShamci(), - + inno = item.inno, InvoiceSendTaxs = item.sentTax.OrderBy(o => o.ID).Select(s => new SentTaxDto() { Date = s.Date.ShamciToFormatShamci(), @@ -116,7 +116,7 @@ namespace Back.Services .Get(w => w.CompanyID == CompanyID && !w.IsDeleted/* && !w.BillReference.HasValue*/); if (itemSerch.InvoiceID != null) - invok = invok.Where(w => w.ID == itemSerch.InvoiceID); + invok = invok.Where(w => w.ID == itemSerch.InvoiceID || w.inno == itemSerch.InvoiceID.ToString()); if (itemSerch.CustomerID != null) invok = invok.Where(w => w.CustomerID == itemSerch.CustomerID); diff --git a/Back/Services/servTaxPayer.cs b/Back/Services/servTaxPayer.cs index de11207..bf6b3e0 100644 --- a/Back/Services/servTaxPayer.cs +++ b/Back/Services/servTaxPayer.cs @@ -176,6 +176,11 @@ namespace Back.Services SetValue(item, ref InvoiceItem); } + // سریال صورتحساب + var innoS=await _invoiceRepo.Get(w => w.CompanyID == InvoiceItem.CompanyID).Select(s => s.inno).ToListAsync(); + var result = Enumerable.Range(1, 1000000000) .Except(innoS.Select(t => t).ToList().Select(int.Parse).ToList()).FirstOrDefault(); + InvoiceItem.inno = result.ToString("0000000000"); + if (await _invoiceRepo.UpdateAsync(InvoiceItem)) { foreach (var Bitem in FildItems.Bodys) diff --git a/Back/Validations/TaxSystemRules.cs b/Back/Validations/TaxSystemRules.cs new file mode 100644 index 0000000..450289c --- /dev/null +++ b/Back/Validations/TaxSystemRules.cs @@ -0,0 +1,9 @@ +using FluentValidation; +using TaxCollectData.Library.Dto.Content; + +namespace Back.Validations +{ + public class TaxSystemRules : AbstractValidator, PaymentDto>> + { + } +} diff --git a/Shared/DTOs/InvoiceDtos.cs b/Shared/DTOs/InvoiceDtos.cs index 8065c5a..10c6858 100644 --- a/Shared/DTOs/InvoiceDtos.cs +++ b/Shared/DTOs/InvoiceDtos.cs @@ -84,6 +84,11 @@ namespace Shared.DTOs // public ICollection Invoicestatuschanges { get; set; } public ICollection InvoiceSendTaxs { get; set; }=new List { }; + [MaxLength(10)] + [Display(Name = "سریال صورتحساب داخلی حافظه مالیاتی")] + public string? inno { get; set; } + + } public class InvoiceItemDTO { diff --git a/TaxPayerFull/Pages/UserPanel/Invoice.razor b/TaxPayerFull/Pages/UserPanel/Invoice.razor index fd28083..c35281f 100644 --- a/TaxPayerFull/Pages/UserPanel/Invoice.razor +++ b/TaxPayerFull/Pages/UserPanel/Invoice.razor @@ -23,8 +23,8 @@
  • -
    - +
    +
    diff --git a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor index 730570e..733d14d 100644 --- a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor +++ b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor @@ -338,7 +338,7 @@
    -
    +

    @if (!invoice.IsDeleted) { @@ -371,6 +371,10 @@ }
    + +
    +
    +
    @if (!invoice.IsDeleted && invoice.invoiceType != InvoiceType.Bidding && SendInvoice) {
    @@ -380,7 +384,13 @@
    } - + else + { +
    + + +
    + }

    diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index ea0270a..670070e 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); //Home -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); //farzan -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");