Expense changes
This commit is contained in:
parent
ed3ba13fa9
commit
b4251c674e
|
|
@ -552,14 +552,25 @@ abstract class ExpenseEntity extends Object
|
|||
@override
|
||||
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
|
||||
|
||||
double get calculatetaxRate1 =>
|
||||
calculateTaxByAmount == true ? taxAmount1 / amount : taxRate1;
|
||||
double get calculatetaxRate1 {
|
||||
if (calculateTaxByAmount == true) {
|
||||
if (usesInclusiveTaxes) {
|
||||
return taxAmount1 / (amount - taxAmount1) * 100;
|
||||
} else {
|
||||
return taxAmount1 / amount * 100;
|
||||
}
|
||||
} else {
|
||||
return taxRate1;
|
||||
}
|
||||
}
|
||||
|
||||
double get calculatetaxRate2 =>
|
||||
calculateTaxByAmount == true ? taxAmount2 / amount : taxRate2;
|
||||
double get calculatetaxRate2 => calculateTaxByAmount == true
|
||||
? taxAmount2 / (amount - taxAmount2) * 100
|
||||
: taxRate2;
|
||||
|
||||
double get calculatetaxRate3 =>
|
||||
calculateTaxByAmount == true ? taxAmount3 / amount : taxRate3;
|
||||
double get calculatetaxRate3 => calculateTaxByAmount == true
|
||||
? taxAmount3 / (amount - taxAmount3) * 100
|
||||
: taxRate3;
|
||||
|
||||
double get taxAmount {
|
||||
var total = 0.0;
|
||||
|
|
@ -609,9 +620,9 @@ abstract class ExpenseEntity extends Object
|
|||
|
||||
double get convertedExchangeRate => exchangeRate == 0 ? 1 : exchangeRate;
|
||||
|
||||
double get convertedAmount => round(grossAmount * convertedExchangeRate, 2);
|
||||
double get convertedAmount => grossAmount * convertedExchangeRate;
|
||||
|
||||
double get convertedNetAmount => round(netAmount * convertedExchangeRate, 2);
|
||||
double get convertedNetAmount => netAmount * convertedExchangeRate;
|
||||
|
||||
double get convertedAmountWithTax =>
|
||||
round(grossAmount * convertedExchangeRate, 2);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ InvoiceItemEntity convertExpenseToInvoiceItem({
|
|||
..notes = expense.publicNotes
|
||||
..quantity =
|
||||
company.defaultQuantity || !company.enableProductQuantity ? 1 : null
|
||||
..cost = expense.convertedNetAmount
|
||||
..cost = company.settings.enableInclusiveTaxes
|
||||
? expense.convertedAmount
|
||||
: expense.convertedNetAmount
|
||||
..taxName1 = expense.taxName1
|
||||
..taxRate1 = expense.calculatetaxRate1
|
||||
..taxName2 = expense.taxName2
|
||||
|
|
|
|||
|
|
@ -15,10 +15,26 @@ InvoiceItemEntity convertTaskToInvoiceItem(
|
|||
final client = state.clientState.get(task.clientId);
|
||||
final group = state.groupState.get(client.groupId);
|
||||
|
||||
var notes = task.description;
|
||||
|
||||
if (state.company.invoiceTaskTimelog) {
|
||||
notes += '\n';
|
||||
task
|
||||
.getTaskTimes(sort: true)
|
||||
.where((time) => time.startDate != null && time.endDate != null)
|
||||
.forEach((time) {
|
||||
final start =
|
||||
formatDate(time.startDate.toIso8601String(), context, showTime: true);
|
||||
final end = formatDate(time.endDate.toIso8601String(), context,
|
||||
showTime: true, showDate: false, showSeconds: false);
|
||||
notes += '\n$start - $end';
|
||||
});
|
||||
}
|
||||
|
||||
return InvoiceItemEntity().rebuild((b) => b
|
||||
..taskId = task.id
|
||||
..typeId = InvoiceItemEntity.TYPE_TASK
|
||||
..notes = task.description
|
||||
..notes = notes
|
||||
..cost = taskRateSelector(
|
||||
company: state.company,
|
||||
project: project,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,25 @@ class ExpenseOverview extends StatelessWidget {
|
|||
|
||||
List<Widget> _buildDetailsList() {
|
||||
String tax = '';
|
||||
if (expense.calculateTaxByAmount) {
|
||||
if (expense.taxName1.isNotEmpty) {
|
||||
tax += formatNumber(expense.taxAmount1, context) +
|
||||
' ' +
|
||||
expense.taxName1;
|
||||
}
|
||||
if (expense.taxName2.isNotEmpty) {
|
||||
tax += ' ' +
|
||||
formatNumber(expense.taxAmount2, context) +
|
||||
' ' +
|
||||
expense.taxName2;
|
||||
}
|
||||
if (expense.taxName3.isNotEmpty) {
|
||||
tax += ' ' +
|
||||
formatNumber(expense.taxAmount3, context) +
|
||||
' ' +
|
||||
expense.taxName3;
|
||||
}
|
||||
} else {
|
||||
if (expense.taxName1.isNotEmpty) {
|
||||
tax += formatNumber(expense.taxRate1, context,
|
||||
formatNumberType: FormatNumberType.percent) +
|
||||
|
|
@ -72,6 +91,7 @@ class ExpenseOverview extends StatelessWidget {
|
|||
' ' +
|
||||
expense.taxName3;
|
||||
}
|
||||
}
|
||||
|
||||
final fields = <String, String>{
|
||||
localization.date: formatDate(expense.date, context),
|
||||
|
|
|
|||
Loading…
Reference in New Issue