public async Task <ICollection <EmployeeDto> > GetAllCompanyEmployees(int companyId) { var employees = await employeeRepository.AllAsNoTracking().Where(e => e.PartnerId == companyId) .Select(e => new EmployeeDto() { Id = e.Id, FullName = e.FullName, IsActive = e.IsActive, }).ToListAsync(); return(employees); }
public async Task <ICollection <VatTypeDto> > GetAll() { var vatTypes = await vatTypeRepository.AllAsNoTracking().Select(vt => new VatTypeDto() { Id = vt.Id, Name = vt.Name, Percantage = vt.Percantage, Description = vt.Description, IsActive = vt.IsActive, }).ToListAsync(); return(vatTypes); }
public async Task <ICollection <QuantityTypeDto> > GetAllQuantityTypes() { var quantityTypes = await quantityTypeRepository.AllAsNoTracking() .Select(e => new QuantityTypeDto() { Id = e.Id, Type = e.Type, Description = e.Description, IsActive = e.IsActive, }).ToListAsync(); return(quantityTypes); }
public async Task <ICollection <EmployeeDto> > GetAllCompanyEmployees() { var company = await employeeRepository.Context.Companies.OrderBy(c => c.Id).LastOrDefaultAsync(); var employees = await employeeRepository.AllAsNoTracking().Where(e => e.CompanyId == company.Id) .Select(e => new EmployeeDto() { Id = e.Id, FullName = e.FullName, IsActive = e.IsActive, }).ToListAsync(); return(employees); }
public async Task <ICollection <PaymentTypeDto> > GetAllCompanyPaymentTypes() { var paymentType = await paymentTypeRepository.AllAsNoTracking() .Select(e => new PaymentTypeDto() { Id = e.Id, Name = e.Name, Description = e.Description, IsActiv = e.IsActiv, RequiredBankAccount = e.RequireBankAccount, }).ToListAsync(); return(paymentType); }
public async Task <ICollection <BankAccountDto> > GetAllCompanyBankAccounts(int companyId) { var bankAccounts = await bankAccountRepository.AllAsNoTracking().Where(ba => ba.PartnerId == companyId) .Select(ba => new BankAccountDto() { Id = ba.Id, Name = ba.Name, BankName = ba.BankName, BIC = ba.BIC, IBAN = ba.IBAN, Description = ba.Description, IsActive = ba.IsActive }).ToListAsync(); return(bankAccounts); }
public async Task <ICollection <BankAccountDto> > GetAllCompanyBankAccounts() { var company = await bankAccountRepository.Context.Companies.OrderBy(c => c.Id).LastOrDefaultAsync(); var bankAccounts = await bankAccountRepository.AllAsNoTracking().Where(ba => ba.CompanyId == company.Id) .Select(ba => new BankAccountDto() { Id = ba.Id, Name = ba.Name, BankName = ba.BankName, BIC = ba.BIC, IBAN = ba.IBAN, Description = ba.Description, IsActive = ba.IsActive }).ToListAsync(); return(bankAccounts); }
public async Task <PaginatedList <DocumentShortView> > GetPaginatedNonVatDocumentAsync(int page, int itemPerPage) { var query = nonVatDocumentRepo.AllAsNoTracking().OrderByDescending(e => e.CreatedDate).Select(e => new DocumentShortView() { Id = e.Id, PartnerName = e.Partner.Name, CreatedDate = e.CreatedDate.ToString("dd.MM.yyyy"), DocumentType = e.Type.ToString(), Base = e.SubTottal, Vat = e.Vat ?? 0, Tottal = e.Tottal, IsVatDocument = false, }); var result = await PaginatedList <DocumentShortView> .CreateAsync(query, page, itemPerPage); foreach (var item in result) { item.DocumentType = SetType(item.DocumentType); } return(result); }
public async Task <ICollection <ProductDto> > GetAllProduct() { var products = await productRepositoy.AllAsNoTracking().Select(e => new ProductDto() { Name = e.Name, Id = e.Id, Description = e.Description, Barcode = e.Barcode, Price = e.Price, BasePrice = e.BasePrice, Quantity = e.Quantity, PriceWithVat = e.Price * ((e.VatType.Percantage / 100) + 1), VatTypeId = e.VatTypeId, VatType = new VatTypeView() { Name = e.VatType.Name + "-" + e.VatType.Percantage.ToString("F2") + "%", Id = e.VatType.Id }, QuantityTypeId = e.QuantityTypeId, QuantityType = new QuantityTypeShortView { Id = e.QuantityType.Id, Type = e.QuantityType.Type }, }).ToListAsync(); return(products); }
public async Task <IEnumerable <PartnerShortViewDto> > GetAllPartners() { var result = await partnerRepository.AllAsNoTracking().OrderBy(p => p.Name).Select(p => new PartnerShortViewDto() { Id = p.Id, Name = p.Name, Address = p.City + ", " + p.Address, EIK = p.EIK, CountOfDocuments = p.VatDocuments.Count + p.NonVatDocuments.Count, }).ToListAsync(); return(result); }
public async Task <NonVatDocumentDto> PrepareEditNonVatDocumentModelAsync(long id) { var model = await NonVatDocumentRepo.AllAsNoTracking().Where(d => d.Id == id) .Select(vt => new NonVatDocumentDto() { Id = vt.Id, CreatedDate = vt.CreatedDate.ToString("dd.MM.yyyy"), VatReasonDate = vt.VatReasonDate.ToString("dd.MM.yyyy"), Description = vt.Description, FreeText = vt.FreeText, RecipientEmployee = vt.RecipientEmployee.FullName, WriterEmployee = vt.WriterEmployee.FullName, SubTottal = vt.SubTottal, Vat = vt.Vat, Tottal = vt.Tottal, Type = (dto.NonVatDocumentTypes)vt.Type, PartnerId = vt.PartnerId, BankAccountId = vt.BankAccountId, CompanyObjectId = vt.CompanyObjectId, PaymentTypeId = vt.PaymentTypeId, } ).FirstOrDefaultAsync(); if (model is null) { return(null); } var sales = await NonVatDocumentRepo.Context.Sales .Include(s => s.Product) .Include(s => s.Product.QuantityType) .Include(s => s.FreeProduct) .Where(s => s.NonVatDocumentId == id) .ToListAsync(); var salesResult = new List <ProductDocumentDto>(); foreach (var sale in sales) { if (sale.ProductId != null && sale.ProductId != 0) { var product = new ProductDocumentDto() { ProductId = sale.ProductId, Name = sale.Product.Name, ProductType = sale.Product.QuantityType.Type, Quantity = sale.Quantity, Price = sale.UnitPrice, TottalPrice = sale.Total, VatTypeId = sale.Product.VatTypeId, SaleId = sale.Id, IsProduct = true, }; salesResult.Add(product); } else if (sale.FreeProductId != null && sale.FreeProductId != 0) { var product = new ProductDocumentDto() { FreeProductID = sale.FreeProductId, Name = sale.FreeProduct.Name, ProductType = sale.FreeProduct.QuantityType, Quantity = sale.Quantity, Price = sale.UnitPrice, TottalPrice = sale.Total, VatTypeId = sale.FreeProduct.VatTypeId, SaleId = sale.Id, }; salesResult.Add(product); } } model.Sales = salesResult; return(model); }
public async Task <Report> GetPaginatedVatDocumentByCriteriaAsync(int page, int itemPerPage, long?documentId, string partnerName, string type, string startDate, string endDate, string objGuid) { var query = vatDocumentRepo.AllAsNoTracking(); var report = new Report(); if (documentId != null) { query = query.Where(e => e.Id == documentId); } else { if (!string.IsNullOrEmpty(type)) { if (type == "invoice") { query = query.Where(e => e.Type == Data.CompanyData.Models.Enums.VatDocumentTypes.Invoice); } else if (type == "credit") { query = query.Where(e => e.Type == Data.CompanyData.Models.Enums.VatDocumentTypes.Credit); } else if (type == "debit") { query = query.Where(e => e.Type == Data.CompanyData.Models.Enums.VatDocumentTypes.Debit); } } if (!string.IsNullOrEmpty(partnerName)) { var partnerId = await partnerService.GetPartnerByName(partnerName); if (partnerId != null) { query = query.Where(e => e.PartnerId == partnerId.Id); } else { query = query.Where(e => e.PartnerId == 0); } } if (!string.IsNullOrEmpty(startDate)) { DateTime date; var isDate = DateTime.TryParse(startDate, new CultureInfo("bg-BG"), DateTimeStyles.None, out date); if (isDate) { query = query.Where(e => e.CreatedDate >= date); } } if (!string.IsNullOrEmpty(endDate)) { DateTime date; var isDate = DateTime.TryParse(endDate, new CultureInfo("bg-BG"), DateTimeStyles.None, out date); if (isDate) { query = query.Where(e => e.CreatedDate <= date); } } if (!string.IsNullOrEmpty(objGuid)) { query = query.Where(e => e.CompanyObject.GUID == objGuid); } } var sums = await query.GroupBy(x => true).Select(x => new { Base = x.Sum(y => y.SubTottal), Vat = x.Sum(y => y.Vat), Tottal = x.Sum(y => y.Tottal) }).FirstOrDefaultAsync(); report.Base = sums.Base; report.Vat = sums.Vat ?? 0; report.Tottal = sums.Tottal; var newQuery = query.OrderByDescending(e => e.CreatedDate).ThenByDescending(e => e.Id).Select(e => new DocumentShortView() { Id = e.Id, PartnerName = e.Partner.Name, CreatedDate = e.CreatedDate.ToString("dd.MM.yyyy"), DocumentType = e.Type.ToString(), Base = e.SubTottal, Vat = e.Vat ?? 0, Tottal = e.Tottal, IsVatDocument = true, }); var result = await PaginatedList <DocumentShortView> .CreateAsync(newQuery, page, itemPerPage); foreach (var item in result) { item.DocumentType = SetType(item.DocumentType); } report.Documents = result; return(report); }