public async Task <DashboardResponse> Get() { var lastMonth = DateTime.Today.AddMonths(-1); var today = DateTime.Today; var expenses = await _expensesProvider.GetExpenses(lastMonth.Month, lastMonth.Year); var invoices = await _invoicesProvider.GetInvoice(lastMonth.Month, lastMonth.Year); // Przychód netto bez odliczeń var grossIncome = invoices.Sum(x => x.NetSum); // Koszt uzyskania przychodu var incomeCosts = expenses.Sum(x => x.NetAmount); // Pit do zapłaty var payablePit = (grossIncome - incomeCosts) * PitPercent / 100; var vat = invoices.Sum(x => x.VatSum); // Vat do zapłaty var payableVat = vat - expenses.Sum(x => x.VatAmount); var dashboardResponse = new DashboardResponse { GrossIncome = grossIncome, PayablePit = payablePit > 0 ? payablePit : 0, PayableVat = payableVat > 0 ? payableVat : 0, StartOfSettlingPeriod = new DateTime(lastMonth.Year, lastMonth.Month, 1), EndOfSettlingPeriod = new DateTime(lastMonth.Year, lastMonth.Month, DateTime.DaysInMonth(lastMonth.Year, lastMonth.Month)), VatSettlementDate = new DateTime(today.Year, today.Month, 25), PitSettlementDate = new DateTime(today.Year, today.Month, 20) }; return(dashboardResponse); }
public Task <List <ExpenseResponse> > GetExpenses([FromQuery] int month, [FromQuery] int year) { return(_expensesProvider.GetExpenses(month, year)); }