public static InvoiceDataDTO InvoiceToDto(Invoice invoice, InvoiceSettingsDTO invoiceSettingsDTO, ICollection <RateType> rateTypes, ICollection <UserRateAmount> rateAmounts)
        {
            var timesheetDto     = TimesheetToDto(invoice.Timesheet);
            var summaryNetAmount = TimesheetDtoToSummaryNetAmount(timesheetDto, rateAmounts);

            return(new InvoiceDataDTO()
            {
                Id = invoice.Id.ToString(),
                IssuedDate = invoice.GeneratedDate.ToShortDateString(),
                IssuedPlace = "Wroclaw",
                InvoiceNumber = invoice.InvoiceNumber,
                InvoiceSettings = invoiceSettingsDTO,
                InvoiceItems = TimesheetDtoToInvoiceItemDtos(timesheetDto, rateTypes, rateAmounts),
                TimesheetId = timesheetDto.Id.ToString(),
                InvoiceForMonth = invoice.Timesheet.Date.Month.ToString(),
                InvoiceForYear = invoice.Timesheet.Date.Year.ToString(),
                TaxRate = "23%",
                SummaryNetAmount = summaryNetAmount.ToString(CultureInfo.InvariantCulture),
                SummaryTaxAmount = Math.Round(summaryNetAmount * 0.23, 2).ToString(CultureInfo.InvariantCulture),
                SummaryGrossAmount = Math.Round(summaryNetAmount * 1.23, 2).ToString(CultureInfo.InvariantCulture),
                PayToDate = invoice.GeneratedDate.AddDays(30).ToShortDateString(),
                SellDate = invoice.GeneratedDate.ToShortDateString(),
                IssuedBy = invoiceSettingsDTO.IssuedBy
            });
        }
Exemple #2
0
        public async Task <IActionResult> PutUserInvoiceSettings(InvoiceSettingsDTO userInvoiceSettings)
        {
            var currentUser = await _userManager.FindByNameAsync(User?.Identity?.Name);

            var invoiceSettings = await _context.UserInvoiceSettings.Where(settings => settings.UserId.Equals(currentUser.Id)).FirstAsync();

            invoiceSettings.UpdatePropertiesFromDto(userInvoiceSettings);

            _context.Entry(invoiceSettings).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
 public void UpdatePropertiesFromDto(InvoiceSettingsDTO dto)
 {
     SellerName          = dto.SellerName;
     SellerTaxId         = dto.SellerTaxId;
     SellerAccountNumber = dto.SellerAccountNumber;
     SellerAddressLine1  = dto.SellerAddressLine1;
     SellerAddressLine2  = dto.SellerAddressLine2;
     SellerBankName      = dto.SellerBankName;
     SellerEmail         = dto.SellerEmail;
     BuyerAddressLine1   = dto.BuyerAddressLine1;
     BuyerAddressLine2   = dto.BuyerAddressLine2;
     BuyerTaxId          = dto.BuyerTaxId;
     BuyerName           = dto.BuyerName;
     BuyerPhone          = dto.BuyerPhone;
     IssuedBy            = dto.IssuedBy;
 }
Exemple #4
0
        private InvoiceSettingsDTO CreateMockUserInvoiceSettingsDTO()
        {
            var mock = new InvoiceSettingsDTO
            {
                BuyerAddressLine1   = "BuyerAddressLine1",
                BuyerAddressLine2   = "BuyerAddressLine2",
                BuyerName           = "BuyerName",
                BuyerPhone          = "BuyerPhone",
                BuyerTaxId          = "BuyerTaxId",
                IssuedBy            = "IssuedBy",
                SellerAccountNumber = "SellerAccountNumber",
                SellerAddressLine1  = "SellerAddressLine1",
                SellerAddressLine2  = "SellerAddressLine2",
                SellerBankName      = "SellerBankName",
                SellerEmail         = "SellerEmail",
                SellerName          = "SellerName"
            };

            return(mock);
        }