diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index 44e6a21..e491935 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -72,7 +72,7 @@ namespace Back.Controllers } [HttpPost("PreparationInvoiceBeforeSending")] - public async Task> PreparationInvoiceBeforeSending([FromBody] Atemplatefield item) + public async Task> PreparationInvoiceBeforeSending([FromBody] Atemplatefield item) { var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs index 6da3514..57b49f5 100644 --- a/Back/Data/Models/Invoice.cs +++ b/Back/Data/Models/Invoice.cs @@ -15,6 +15,7 @@ namespace Back.Data.Models public int? BillReference { get; set; } #endregion + #region autofild //تاریخ و زمان صدور صورتحساب )میالدی( @@ -94,11 +95,14 @@ namespace Back.Data.Models [MaxLength(18)] public decimal? cap { get { return - setm == 1 ? tbill : setm == 2 ? 0 : tbill - insp; + setm == 1 ? tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault() + : setm == 2 ? 0 + : tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault() - insp.GetValueOrDefault(); } } //موضوع صورتحساب [MaxLength(1)] public int? ins { get { return (int)invoiceType; } } + public decimal Calcinsp { get { return tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault(); } } #endregion #region fild @@ -143,7 +147,7 @@ namespace Back.Data.Models { get { - return pattern.BillTypeID == 3 || pattern.BillTypeID == 4 || pattern.inp == 8 + return pattern.BillTypeID == 3 || pattern.BillTypeID == 4 || pattern.ID == 2 || pattern.ID == 10 ? 1 : _setm; } diff --git a/Back/Data/Models/InvoiceItem.cs b/Back/Data/Models/InvoiceItem.cs index 1331922..d5ab882 100644 --- a/Back/Data/Models/InvoiceItem.cs +++ b/Back/Data/Models/InvoiceItem.cs @@ -27,15 +27,14 @@ namespace Back.Data.Models //میزان ارز [MaxLength(18)] public decimal? cfee { get { return - invoice?.pattern?.inp == 2 ? _cfee - : invoice?.pattern?.inp == 1 && exr != null && exr != 0 ? Math.Floor(fee.Value / exr.Value) - : null ; } } + invoice?.pattern?.ID == 4 ? _cfee + : exr.HasValue ? Math.Floor(fee.GetValueOrDefault() / exr.GetValueOrDefault()) : 0; } } //مبلغ مالیات بر ارزش افزوده [MaxLength(18)] public decimal? vam { get { - return vra==0 ? 0 : invoice?.pattern?.inp == 9 ? fee*vra/100 : - invoice?.pattern?.inp == 13 ? ((tcpbs+9)/100)+((prdis*vra)/100) + return vra==0 ? 0 : invoice?.pattern?.ID == 9 ? fee*vra/100 : + invoice?.pattern?.ID == 13 || invoice?.pattern?.ID == 5 ? ((tcpbs+9)/100)+((prdis*vra)/100) : vra * adis / 100; } } //جمع کل اجرت ،حق العمل و سود @@ -51,28 +50,27 @@ namespace Back.Data.Models [MaxLength(18)] public decimal? tsstam { get { - if (invoice==null || invoice.pattern==null) - { - return vam + adis; - } - else - return invoice?.pattern?.inp == 9 ? fee+vam : - invoice?.pattern?.inp == 10 ? sscv + vam + odam + olam : - invoice?.pattern?.inp == 4 ? prdis + vam + odam + olam : + return /*invoice?.pattern?.ID == 9 ? fee+vam :*/ + invoice?.pattern?.ID == 10 ? ssrv + vam + odam + olam : + invoice?.pattern?.ID == 4 ? prdis + vam + odam + olam : vam + adis + odam + olam; } } //مبلغ بعد از تخفیف [MaxLength(18)] public decimal? adis { get { - return invoice?.pattern?.inp == 13 ? prdis+ tcpbs - dis: prdis - dis; + return invoice?.pattern?.ID == 5 || invoice?.pattern?.ID == 13 ? prdis+ tcpbs - dis: prdis - dis; } } //مبلغ قبل از تخفیف [MaxLength(18)] public decimal? prdis { get { return am * fee; } } //نرخ مالیات بر ازش افزوده [MaxLength(5)] - public decimal? vra { get { return cODItem != null ? cODItem.TaxRate : null; } } + 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 diff --git a/Back/Services/servTaxPayer.cs b/Back/Services/servTaxPayer.cs index 4047abf..2767757 100644 --- a/Back/Services/servTaxPayer.cs +++ b/Back/Services/servTaxPayer.cs @@ -129,7 +129,21 @@ namespace Back.Services foreach (_TaxPayer.Fild item in head) { var resval = InvoiceItem.GetType().GetProperties().Where(w => w.Name == item.eName).Select(s => s.GetValue(InvoiceItem)).FirstOrDefault(); - item.Value = resval == null ? "" : (item.eName == "InvoicIssueDate" || item.eName == "InvoiceDate" || item.eName == "CottageDateOfCustomsDeclaration" ? resval.ToString().ShamciToFormatShamci() :resval.ToString().Split('.').Length==2 ? ((decimal)resval).ToString("N0") : resval.ToString()); + item.Value = resval == null ? "" : (item.eName == "InvoicIssueDate" || item.eName == "InvoiceDate" || item.eName == "CottageDateOfCustomsDeclaration" ? resval.ToString().ShamciToFormatShamci() : resval.ToString().Split('.').Length == 2 ? ((decimal)resval).ToString("N0") : resval.ToString()); + + if (item.eName == "insp" ) + // زمانی که صورتحساب فقط نسیه بود مبلغ کل فاکتور در نسیه نشسته شود + { + if (InvoiceItem.setm == 1) item.Value = "0"; + + if (InvoiceItem.setm == 2) + { + var rescalcinsp = InvoiceItem.GetType().GetProperties().Where(w => w.Name == "Calcinsp").Select(s => s.GetValue(InvoiceItem)).FirstOrDefault(); + item.Value = rescalcinsp == null ? "" : rescalcinsp.ToString().Split('.').Length == 2 ? ((decimal)rescalcinsp).ToString("N0") : rescalcinsp.ToString(); + } + } + + item.DefVals = item.InputBox == "fromdb" ? _codingRepo.Get(w => w.FildID == item.FildID).Select(ss => new _TaxPayer.Coding() { ID = ss.Code, Name = ss.Title }).ToList() : new List<_TaxPayer.Coding>(); item.Des = /*item.ModeID == 3 ?*/ _specialConditionRepo.Get(w => w.FildID == item.FildID).Select(ss => ss.condition).ToArray() /*: null*/; } diff --git a/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor b/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor index e53a3d0..7a5202a 100644 --- a/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor +++ b/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor @@ -301,7 +301,6 @@ else - @if (invoice != null) { @* action *@ @@ -382,19 +381,22 @@ else public async Task Send() { SpinnerVisible = true; - - string route = "PreparationInvoiceBeforeSending"; - if (FullInvoice) - route = "UpdateInvoice"; - var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/{route}", invoice); - if (rsp.IsSuccessStatusCode) + string route = "PreparationInvoiceBeforeSending"; + if (FullInvoice) + route = "UpdateInvoice"; + + var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/{route}", invoice); + if (rsp.IsSuccessStatusCode) + { + var response = await rsp.Content.ReadFromJsonAsync(); + if (response) { - var response = await rsp.Content.ReadFromJsonAsync(); - if (response) + if (FullInvoice) { - if (FullInvoice) - ShowMessage(ToastType.Success, "تغییرات با موفقیت انجام شد"); + ShowMessage(ToastType.Success, "تغییرات با موفقیت انجام شد"); + await LoadData(); + } else {