This commit is contained in:
mmrbnjd
2024-09-08 17:23:33 +03:30
parent 745412ee56
commit b81c950c39
9 changed files with 468 additions and 126 deletions

View File

@@ -1,4 +1,5 @@
using Back.Common;
using Back.Data.Contracts;
using Back.Data.Models;
using Back.Services;
using Back.Validations;
@@ -10,6 +11,7 @@ using Shared.DTOs;
using System.Net;
using System.Runtime.ConstrainedExecution;
using System.Security.Cryptography;
using static Shared.DTOs._TaxPayer;
namespace Back.Controllers
{
@@ -31,8 +33,13 @@ namespace Back.Controllers
_servInvoice = servInvoice;
}
[HttpGet("PaymentMethods")]
public async Task<ActionResult<List<IdName<string>>>> PaymentMethods()
{
return Ok(await _servpay.GetPaymentMethods());
}
[HttpPost("AddPay")]
public async Task<ActionResult<bool>> AddItem([FromBody] InvoiceItemAction<InvoicePaymentDTO> model)
public async Task<ActionResult<InvoicePaymentDTO>> AddItem([FromBody] InvoiceItemAction<InvoicePaymentDTO> model)
{
//-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
@@ -49,12 +56,15 @@ namespace Back.Controllers
if (invoice == null)
return BadRequest(new List<string> { "invoice notFound..." });
//-------------pmt
List<Back.Data.Models.Coding> codings = await _servInvoice.GetCodingPMT();
//-----------------------
invoice.LastChangeUserID = Convert.ToInt32(UserID);
if (await _servInvoice.UpdateInvoice(invoice))
{
return Ok(await _servpay.Add(new Data.Models.InvoicePayment
var item = await _servpay.Add(new Data.Models.InvoicePayment
{
InvoiceID = model.invoiceID,
acn = model.item.acn,
@@ -68,7 +78,21 @@ namespace Back.Controllers
trn = model.item.trn,
}));
});
return Ok(item!=null ?new InvoicePaymentDTO
{
ID = item.ID,
acn = item.acn,
iinn = item.acn,
pcn = item.acn,
PaymentDateTime = item.PaymentDateTime.ShamciToFormatShamci(),
pid = item.pid,
pmt = item.pmt,
pv = item.pv,
trmn = item.trmn,
trn = item.acn,
paymentMethod = item.pmt.HasValue ? codings.Where(w => w.Code == item.pmt.Value.ToString()).Select(s => s.Title).FirstOrDefault() : null,
} :null);
}
else return BadRequest(new List<string> { "خطایی رخ داده" });
@@ -124,7 +148,29 @@ namespace Back.Controllers
item.trn = model.item.trn;
if (await _servInvoice.UpdateInvoice(invoice))
return Ok(await _servpay.Update(item));
{
var modelout = await _servpay.Update(item);
//-------------pmt
List<Back.Data.Models.Coding> codings = await _servInvoice.GetCodingPMT();
//-----------------------
return Ok(modelout!=null ? new InvoicePaymentDTO
{
ID = modelout.ID,
acn = modelout.acn,
iinn = modelout.acn,
pcn = modelout.acn,
PaymentDateTime = modelout.PaymentDateTime.ShamciToFormatShamci(),
pid = modelout.pid,
pmt = modelout.pmt,
pv = modelout.pv,
trmn = modelout.trmn,
trn = modelout.acn,
paymentMethod = modelout.pmt.HasValue ? codings.Where(w => w.Code == modelout.pmt.Value.ToString()).Select(s => s.Title).FirstOrDefault() : null,
} : null);
}
else
return BadRequest(new List<string> { "خطایی رخ داده" });