models
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Back.Data.Models;
|
||||
using Back.Data.Models.Warehouse;
|
||||
|
||||
namespace TaxPayer.Infrastructure.Persistence
|
||||
{
|
||||
@@ -50,6 +51,8 @@ namespace TaxPayer.Infrastructure.Persistence
|
||||
public DbSet<Promotion> Promotions { get; set; }
|
||||
public DbSet<PromotionDetails> PromotionDetails { get; set; }
|
||||
public DbSet<CreditDocuments> CreditDocuments { get; set; }
|
||||
public DbSet<Receipt> Receipts { get; set; }
|
||||
public DbSet<Remittance> Remittances { get; set; }
|
||||
#endregion
|
||||
//public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
//{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Back.Data.Models
|
||||
@@ -21,6 +22,8 @@ namespace Back.Data.Models
|
||||
[ForeignKey("CompanyID")]
|
||||
public virtual Company Company { get; set; }
|
||||
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
|
||||
public virtual ICollection<Receipt> Receipts { get; set; }
|
||||
public virtual ICollection<Remittance> Remittances { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
21
Back/Data/Models/Warehouse/Receipt.cs
Normal file
21
Back/Data/Models/Warehouse/Receipt.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Shared.Enums;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Back.Data.Models.Warehouse
|
||||
{
|
||||
|
||||
//رسید
|
||||
public class Receipt
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool ForSale { get; set; }
|
||||
public TypeReceipt Type { get; set; }
|
||||
public string info { get; set; }
|
||||
|
||||
[ForeignKey("CODID")]
|
||||
public CODItem cODItem { get; set; }
|
||||
}
|
||||
}
|
20
Back/Data/Models/Warehouse/Remittance.cs
Normal file
20
Back/Data/Models/Warehouse/Remittance.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Shared.Enums;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Back.Data.Models.Warehouse
|
||||
{
|
||||
|
||||
//حواله
|
||||
public class Remittance
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public TypeRemittance Type { get; set; }
|
||||
public string info { get; set; }
|
||||
|
||||
[ForeignKey("CODID")]
|
||||
public CODItem cODItem { get; set; }
|
||||
}
|
||||
}
|
118
Back/Services/Warehouse/ReceiptService.cs
Normal file
118
Back/Services/Warehouse/ReceiptService.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
|
||||
namespace Back.Services.Warehouse
|
||||
{
|
||||
|
||||
public class ReceiptService
|
||||
{
|
||||
private readonly IAsyncRepository<Receipt> _ReceiptRepo;
|
||||
|
||||
public ReceiptService(IAsyncRepository<Receipt> ReceiptRepo)
|
||||
{
|
||||
_ReceiptRepo = ReceiptRepo;
|
||||
}
|
||||
|
||||
public async Task<ReceiptDto?> ADD(ReceiptDto item)
|
||||
{
|
||||
var model = new Receipt()
|
||||
{
|
||||
Date = item.Date,
|
||||
CODID = item.CODID,
|
||||
Count = item.Count,
|
||||
ForSale = item.ForSale,
|
||||
info = item.info,
|
||||
Type = item.Type,
|
||||
};
|
||||
var returnmodel = await _ReceiptRepo.AddAsync(model);
|
||||
if (returnmodel!=null)
|
||||
{
|
||||
item.ID= returnmodel.ID;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<ReceiptDto?> Update(ReceiptDto item)
|
||||
{
|
||||
var model= await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync();
|
||||
model.Date= item.Date;
|
||||
model.CODID= item.CODID;
|
||||
model.Count= item.Count;
|
||||
model.ForSale= item.ForSale;
|
||||
model.info = item.info;
|
||||
model.Type = item.Type;
|
||||
var returnmodel = await _ReceiptRepo.UpdateAsync(model);
|
||||
if (returnmodel)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> Delete(int itemID,int CompanyID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID==CompanyID).FirstOrDefaultAsync();
|
||||
|
||||
return await _ReceiptRepo.DeleteAsync(model);
|
||||
|
||||
}
|
||||
public async Task<ReceiptDto?> Get(int itemID, int CompanyID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID)
|
||||
.Include(inc=>inc.cODItem)
|
||||
.Select(s=>new ReceiptDto()
|
||||
{
|
||||
Date = s.Date,
|
||||
CODID=s.CODID,
|
||||
Count = s.Count,
|
||||
ForSale= s.ForSale,
|
||||
ID=s.ID,
|
||||
CODTitle=s.cODItem.Title,
|
||||
info = s.info,
|
||||
Type=s.Type
|
||||
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task<List<ReceiptDto>?> GetAll(int CompanyID, TypeReceipt? Type=null, int CODID=0)
|
||||
{
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID);
|
||||
if (Type != null)
|
||||
request = request.Where(w => w.Type == Type);
|
||||
|
||||
if (CODID != 0)
|
||||
request = request.Where(w => w.CODID == CODID);
|
||||
|
||||
|
||||
return await request
|
||||
.Include(inc => inc.cODItem)
|
||||
.Select(s => new ReceiptDto()
|
||||
{
|
||||
Date = s.Date,
|
||||
CODID = s.CODID,
|
||||
Count = s.Count,
|
||||
ForSale = s.ForSale,
|
||||
ID = s.ID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
info = s.info,
|
||||
Type = s.Type
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
113
Back/Services/Warehouse/RemittanceService.cs
Normal file
113
Back/Services/Warehouse/RemittanceService.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
|
||||
namespace Back.Services.Warehouse
|
||||
{
|
||||
public class RemittanceService
|
||||
{
|
||||
private readonly IAsyncRepository<Remittance> _ReceiptRepo;
|
||||
|
||||
public RemittanceService(IAsyncRepository<Remittance> remittanceRepo)
|
||||
{
|
||||
_ReceiptRepo = remittanceRepo;
|
||||
}
|
||||
|
||||
public async Task<RemittanceDto?> ADD(RemittanceDto item)
|
||||
{
|
||||
var model = new Remittance()
|
||||
{
|
||||
Date = item.Date,
|
||||
CODID = item.CODID,
|
||||
Count = item.Count,
|
||||
info = item.info,
|
||||
Type = item.Type,
|
||||
};
|
||||
var returnmodel = await _ReceiptRepo.AddAsync(model);
|
||||
if (returnmodel != null)
|
||||
{
|
||||
item.ID = returnmodel.ID;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<RemittanceDto?> Update(RemittanceDto item)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync();
|
||||
model.Date = item.Date;
|
||||
model.CODID = item.CODID;
|
||||
model.Count = item.Count;
|
||||
model.info = item.info;
|
||||
model.Type = item.Type;
|
||||
var returnmodel = await _ReceiptRepo.UpdateAsync(model);
|
||||
if (returnmodel)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> Delete(int itemID, int CompanyID)
|
||||
{
|
||||
var model = await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID).FirstOrDefaultAsync();
|
||||
|
||||
return await _ReceiptRepo.DeleteAsync(model);
|
||||
|
||||
}
|
||||
public async Task<RemittanceDto?> Get(int itemID, int CompanyID)
|
||||
{
|
||||
return await _ReceiptRepo.Get(w => w.ID == itemID && w.cODItem.CompanyID == CompanyID)
|
||||
.Include(inc => inc.cODItem)
|
||||
.Select(s => new RemittanceDto()
|
||||
{
|
||||
Date = s.Date,
|
||||
CODID = s.CODID,
|
||||
Count = s.Count,
|
||||
ID = s.ID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
info = s.info,
|
||||
Type = s.Type
|
||||
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task<List<RemittanceDto>?> GetAll(int CompanyID, TypeRemittance? Type = null, int CODID = 0)
|
||||
{
|
||||
var request = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID);
|
||||
if (Type != null)
|
||||
request = request.Where(w => w.Type == Type);
|
||||
|
||||
if (CODID != 0)
|
||||
request = request.Where(w => w.CODID == CODID);
|
||||
|
||||
|
||||
return await request
|
||||
.Include(inc => inc.cODItem)
|
||||
.Select(s => new RemittanceDto()
|
||||
{
|
||||
Date = s.Date,
|
||||
CODID = s.CODID,
|
||||
Count = s.Count,
|
||||
ID = s.ID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
info = s.info,
|
||||
Type = s.Type
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
65
Back/Services/Warehouse/WarehouseService.cs
Normal file
65
Back/Services/Warehouse/WarehouseService.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Back.Services.Warehouse
|
||||
{
|
||||
public class WarehouseService
|
||||
{
|
||||
private readonly IAsyncRepository<Remittance> _RemittanceRepo;
|
||||
private readonly IAsyncRepository<Receipt> _ReceiptRepo;
|
||||
|
||||
public WarehouseService(IAsyncRepository<Remittance> remittanceRepo, IAsyncRepository<Receipt> receiptRepo)
|
||||
{
|
||||
_RemittanceRepo = remittanceRepo;
|
||||
_ReceiptRepo = receiptRepo;
|
||||
}
|
||||
public async Task<List<CirculationDto>> Circulation(int CompanyID,string date="",int CODID=0)
|
||||
{
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
.Select(s=>new CirculationDto
|
||||
{
|
||||
CODID=s.CODID,
|
||||
CODTitle=s.cODItem.Title,
|
||||
Date=s.Date,
|
||||
Count=s.Count,
|
||||
info=s.info,
|
||||
Type=TypeCirculation.Remittance,
|
||||
ModelTypeID = (int)s.Type,
|
||||
ModelTypeTitle= s.Type.GetDisplayName()
|
||||
});
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
RequestRemittance = RequestRemittance.Where(w => w.Date == date);
|
||||
if (CODID!=0)
|
||||
RequestRemittance = RequestRemittance.Where(w => w.CODID == CODID);
|
||||
//-----------
|
||||
var RequestReceipt = _ReceiptRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
.Select(s => new CirculationDto
|
||||
{
|
||||
CODID = s.CODID,
|
||||
CODTitle = s.cODItem.Title,
|
||||
Date = s.Date,
|
||||
Count = s.Count,
|
||||
info = s.info,
|
||||
Type = TypeCirculation.Receipt,
|
||||
ModelTypeID = (int)s.Type,
|
||||
ModelTypeTitle = s.Type.GetDisplayName()
|
||||
});
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
RequestReceipt = RequestReceipt.Where(w => w.Date == date);
|
||||
if (CODID != 0)
|
||||
RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID);
|
||||
|
||||
var list = await RequestReceipt.ToListAsync();
|
||||
list.AddRange(await RequestRemittance.ToListAsync());
|
||||
return list.OrderByDescending(o=>o.Date).ToList();
|
||||
}
|
||||
}
|
||||
}
|
31
Shared/DTOs/Warehouse/CirculationDto.cs
Normal file
31
Shared/DTOs/Warehouse/CirculationDto.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Shared.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs.Warehouse
|
||||
{
|
||||
public enum TypeCirculation
|
||||
{
|
||||
[Display(Name = "رسید")]
|
||||
Receipt,
|
||||
|
||||
[Display(Name = "حواله")]
|
||||
Remittance
|
||||
}
|
||||
public class CirculationDto
|
||||
{
|
||||
public int CODID { get; set; }
|
||||
public string? CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool? ForSale { get; set; }
|
||||
public string ModelTypeTitle { get; set; }
|
||||
public int ModelTypeID { get; set; }
|
||||
public string info { get; set; }
|
||||
public TypeCirculation Type { get; set; }
|
||||
}
|
||||
}
|
21
Shared/DTOs/Warehouse/ReceiptDto.cs
Normal file
21
Shared/DTOs/Warehouse/ReceiptDto.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Shared.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs.Warehouse
|
||||
{
|
||||
public class ReceiptDto
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public string? CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public bool ForSale { get; set; }
|
||||
public TypeReceipt Type { get; set; }
|
||||
public string info { get; set; }
|
||||
}
|
||||
}
|
20
Shared/DTOs/Warehouse/RemittanceDto.cs
Normal file
20
Shared/DTOs/Warehouse/RemittanceDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Shared.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs.Warehouse
|
||||
{
|
||||
public class RemittanceDto
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public int CODID { get; set; }
|
||||
public string CODTitle { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string Date { get; set; }
|
||||
public TypeRemittance Type { get; set; }
|
||||
public string info { get; set; }
|
||||
}
|
||||
}
|
17
Shared/Enums/TypeReceipt.cs
Normal file
17
Shared/Enums/TypeReceipt.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Enums
|
||||
{
|
||||
public enum TypeReceipt
|
||||
{
|
||||
[Display(Name = "خرید")]
|
||||
Shopping=1,
|
||||
[Display(Name = "امانت")]
|
||||
trust=2
|
||||
}
|
||||
}
|
17
Shared/Enums/TypeRemittance.cs
Normal file
17
Shared/Enums/TypeRemittance.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Enums
|
||||
{
|
||||
public enum TypeRemittance
|
||||
{
|
||||
[Display(Name = "فروش")]
|
||||
Sale=3,
|
||||
[Display(Name = "امانت")]
|
||||
trust=4
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user