...
This commit is contained in:
@@ -10,15 +10,20 @@ namespace Back.Services
|
||||
public class servInvoice
|
||||
{
|
||||
private readonly IAsyncRepository<Invoice> _invoiceRepo;
|
||||
private readonly IAsyncRepository<Coding> _CodingRepo;
|
||||
private readonly IAsyncRepository<InvoiceStatusChang> _invoiceStatusChangPaymentRepo;
|
||||
private readonly CheckPermission _checkPermission;
|
||||
public servInvoice(IAsyncRepository<Invoice> invoiceRepo, CheckPermission checkPermission
|
||||
, IAsyncRepository<InvoiceStatusChang> invoiceStatusChangPaymentRepo)
|
||||
, IAsyncRepository<InvoiceStatusChang> invoiceStatusChangPaymentRepo, IAsyncRepository<Coding> codingRepo)
|
||||
{
|
||||
_invoiceStatusChangPaymentRepo = invoiceStatusChangPaymentRepo;
|
||||
_invoiceRepo = invoiceRepo;
|
||||
_checkPermission = checkPermission;
|
||||
|
||||
_CodingRepo = codingRepo;
|
||||
}
|
||||
public async Task<List<Coding>> GetCodingPMT()
|
||||
{
|
||||
return await _CodingRepo.Get(w => w.FildID == 71).ToListAsync();
|
||||
}
|
||||
public async Task<InvoiceDTO?> GetInvoice(int CompanyID, int ID, bool notloaddelete = true)
|
||||
{
|
||||
@@ -33,18 +38,16 @@ namespace Back.Services
|
||||
}
|
||||
#endregion
|
||||
//-----------------------
|
||||
var item= await invok
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.ThenInclude(inc => inc.cODItem)
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
.Include(inc => inc.Customer)
|
||||
.Include(inc => inc.sentTax)
|
||||
.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.ThenInclude(inc => inc.BillType)
|
||||
|
||||
.FirstOrDefaultAsync();
|
||||
return new InvoiceDTO()
|
||||
var item = await invok.Include(inc => inc.invoiceDetails) .ThenInclude(inc => inc.cODItem).ThenInclude(inc => inc.CODUnit).Include(inc => inc.Customer)
|
||||
.Include(inc => inc.sentTax).Include(inc => inc.payments).Include(inc => inc.pattern).ThenInclude(inc => inc.BillType).FirstOrDefaultAsync();
|
||||
|
||||
//-------------pmt
|
||||
List<Coding> codings = new List<Coding>();
|
||||
if (item != null)
|
||||
codings =await GetCodingPMT();
|
||||
//-----------------------
|
||||
|
||||
return new InvoiceDTO()
|
||||
{
|
||||
|
||||
IsDeleted = item.IsDeleted,
|
||||
@@ -66,33 +69,33 @@ namespace Back.Services
|
||||
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(),
|
||||
Time = s.Time,
|
||||
ID = s.ID,
|
||||
InvoiceID = s.InvoiceID,
|
||||
SentStatus = s.SentStatus,
|
||||
InvoiceType = s.InvoiceType,
|
||||
msgInvoiceType = s.InvoiceType.GetEnumDisplayName(),
|
||||
msgSentStatus = s.SentStatus.GetEnumDisplayName()
|
||||
}).ToList(),
|
||||
items = item.invoiceDetails.OrderBy(o => o.ID).Select(x => new InvoiceItemDTO()
|
||||
{
|
||||
ID = x.ID,
|
||||
CODID = x.CODID,
|
||||
adis = x.adis,
|
||||
am = x.am.Value,
|
||||
dis = x.dis,
|
||||
fee = x.fee.Value,
|
||||
mu = x.unitTitle,
|
||||
sstt = x.sstt,
|
||||
tsstam = x.tsstam,
|
||||
vam = x.vam,
|
||||
vra = x.vra,
|
||||
prdis = x.prdis
|
||||
}).ToList(),
|
||||
payments =
|
||||
InvoiceSendTaxs = item.sentTax.OrderBy(o => o.ID).Select(s => new SentTaxDto()
|
||||
{
|
||||
Date = s.Date.ShamciToFormatShamci(),
|
||||
Time = s.Time,
|
||||
ID = s.ID,
|
||||
InvoiceID = s.InvoiceID,
|
||||
SentStatus = s.SentStatus,
|
||||
InvoiceType = s.InvoiceType,
|
||||
msgInvoiceType = s.InvoiceType.GetEnumDisplayName(),
|
||||
msgSentStatus = s.SentStatus.GetEnumDisplayName()
|
||||
}).ToList(),
|
||||
items = item.invoiceDetails.OrderBy(o => o.ID).Select(x => new InvoiceItemDTO()
|
||||
{
|
||||
ID = x.ID,
|
||||
CODID = x.CODID,
|
||||
adis = x.adis,
|
||||
am = x.am.Value,
|
||||
dis = x.dis,
|
||||
fee = x.fee.Value,
|
||||
mu = x.unitTitle,
|
||||
sstt = x.sstt,
|
||||
tsstam = x.tsstam,
|
||||
vam = x.vam,
|
||||
vra = x.vra,
|
||||
prdis = x.prdis
|
||||
}).ToList(),
|
||||
payments =
|
||||
item.payments.OrderBy(o => o.ID).Select(x => new InvoicePaymentDTO()
|
||||
{
|
||||
ID = x.ID,
|
||||
@@ -104,9 +107,10 @@ namespace Back.Services
|
||||
pmt = x.pmt,
|
||||
pv = x.pv,
|
||||
trmn = x.trmn,
|
||||
trn = x.acn
|
||||
trn = x.acn,
|
||||
paymentMethod = x.pmt.HasValue ? codings.Where(w=>w.Code== x.pmt.Value.ToString()).Select(s=>s.Title).FirstOrDefault() : null,
|
||||
}).ToList()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -144,7 +148,7 @@ namespace Back.Services
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
//.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.OrderByDescending(o=>o.ID)
|
||||
.OrderByDescending(o => o.ID)
|
||||
.Select(s => new InvoiceGridDTO()
|
||||
{
|
||||
|
||||
@@ -232,7 +236,7 @@ namespace Back.Services
|
||||
.Include(inc => inc.sentTax)
|
||||
.Include(inc => inc.pattern)
|
||||
.Include(inc => inc.invoice)
|
||||
.Include(inc=>inc.payments)
|
||||
.Include(inc => inc.payments)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> DeleteInvoice(Invoice item)
|
||||
|
@@ -9,17 +9,19 @@ namespace Back.Services
|
||||
public class servInvoicePayment
|
||||
{
|
||||
private readonly IAsyncRepository<InvoicePayment> _Repo;
|
||||
public servInvoicePayment(IAsyncRepository<InvoicePayment> Repo)
|
||||
private readonly IAsyncRepository<Coding> _CodingRepo;
|
||||
public servInvoicePayment(IAsyncRepository<InvoicePayment> Repo, IAsyncRepository<Coding> CodingRepo)
|
||||
{
|
||||
_Repo = Repo;
|
||||
_CodingRepo = CodingRepo;
|
||||
}
|
||||
public async Task<bool> Add(InvoicePayment item)
|
||||
public async Task<InvoicePayment> Add(InvoicePayment item)
|
||||
{
|
||||
return await _Repo.AddBoolResultAsync(item);
|
||||
return await _Repo.AddAsync(item);
|
||||
}
|
||||
public async Task<bool> Update(InvoicePayment item)
|
||||
public async Task<InvoicePayment> Update(InvoicePayment item)
|
||||
{
|
||||
return await _Repo.UpdateAsync(item);
|
||||
return await _Repo.UpdateByObjAsync(item);
|
||||
}
|
||||
public async Task<bool> Delete(InvoicePayment item)
|
||||
{
|
||||
@@ -40,6 +42,15 @@ namespace Back.Services
|
||||
{
|
||||
return await _Repo.Get(w => w.InvoiceID == invoiceID && w.ID == ID && w.invoice.CompanyID == companyID).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<List<IdName<string>>> GetPaymentMethods()
|
||||
{
|
||||
return await _CodingRepo.Get(w => w.FildID == 71)
|
||||
.Select(s=>new IdName<string>
|
||||
{
|
||||
ID=s.Code,Title=s.Title
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user