Settings
This commit is contained in:
parent
3a585d97bf
commit
ff87752ec0
|
|
@ -58,7 +58,7 @@ abstract class ProductEntity extends Object
|
|||
notes: '',
|
||||
cost: 0,
|
||||
price: 0,
|
||||
quantity: 1,
|
||||
quantity: (state?.company?.defaultQuantity ?? true) ? 1 : 0,
|
||||
taxName1: '',
|
||||
taxRate1: 0,
|
||||
taxName2: '',
|
||||
|
|
|
|||
|
|
@ -273,7 +273,9 @@ void handleExpenseAction(
|
|||
break;
|
||||
case EntityAction.newInvoice:
|
||||
final item = convertExpenseToInvoiceItem(
|
||||
expense: expense, categoryMap: company.expenseCategoryMap);
|
||||
expense: expense,
|
||||
categoryMap: company.expenseCategoryMap,
|
||||
company: company);
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: InvoiceEntity(state: state).rebuild((b) => b
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ import 'package:built_collection/built_collection.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart';
|
||||
|
||||
InvoiceItemEntity convertExpenseToInvoiceItem(
|
||||
{@required ExpenseEntity expense,
|
||||
@required BuiltMap<String, ExpenseCategoryEntity> categoryMap}) {
|
||||
InvoiceItemEntity convertExpenseToInvoiceItem({
|
||||
@required ExpenseEntity expense,
|
||||
@required BuiltMap<String, ExpenseCategoryEntity> categoryMap,
|
||||
@required CompanyEntity company,
|
||||
}) {
|
||||
return InvoiceItemEntity().rebuild((b) => b
|
||||
..expenseId = expense.id
|
||||
..productKey = categoryMap[expense.categoryId]?.name ?? ''
|
||||
..notes = expense.publicNotes
|
||||
..quantity = 1
|
||||
..quantity =
|
||||
company.defaultQuantity || !company.enableProductQuantity ? 1 : null
|
||||
..cost = expense.convertedAmount
|
||||
..taxName1 = expense.taxName1
|
||||
..taxRate1 = expense.taxRate1
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ void handleProductAction(
|
|||
switch (action) {
|
||||
case EntityAction.newInvoice:
|
||||
final item =
|
||||
convertProductToInvoiceItem(context: context, product: product);
|
||||
convertProductToInvoiceItem(company: state.company, product: product);
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: InvoiceEntity(state: state)
|
||||
|
|
|
|||
|
|
@ -4,13 +4,17 @@ import 'package:built_collection/built_collection.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart';
|
||||
|
||||
InvoiceItemEntity convertProductToInvoiceItem(
|
||||
{BuildContext context, ProductEntity product}) {
|
||||
InvoiceItemEntity convertProductToInvoiceItem({
|
||||
@required ProductEntity product,
|
||||
@required CompanyEntity company,
|
||||
}) {
|
||||
return InvoiceItemEntity().rebuild((b) => b
|
||||
..productKey = product.productKey
|
||||
..notes = product.notes
|
||||
..cost = product.price
|
||||
..quantity = product.quantity
|
||||
..quantity = company.enableProductQuantity
|
||||
? product.quantity
|
||||
: company.defaultQuantity ? 1 : null
|
||||
..customValue1 = product.customValue1
|
||||
..customValue2 = product.customValue2
|
||||
..taxName1 = product.taxName1
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class EntityHeader extends StatelessWidget {
|
|||
child: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Flex(
|
||||
direction: value.length > 12 || secondValue.length > 12
|
||||
direction: value.length > 12 || (secondValue ?? '').length > 12
|
||||
? Axis.vertical
|
||||
: Axis.horizontal,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
|
|
|
|||
|
|
@ -52,8 +52,9 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
void _addBlankItem() {
|
||||
widget.onItemsSelected([InvoiceItemEntity(quantity: 1)]);
|
||||
void _addBlankItem(CompanyEntity company) {
|
||||
widget.onItemsSelected(
|
||||
[InvoiceItemEntity(quantity: company.defaultQuantity ? 1 : null)]);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +68,11 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
final product = entity as ProductEntity;
|
||||
if (state.company.fillProducts ?? true) {
|
||||
items.add(
|
||||
convertProductToInvoiceItem(product: product, context: context));
|
||||
convertProductToInvoiceItem(product: product, company: company));
|
||||
} else {
|
||||
items.add(
|
||||
InvoiceItemEntity(productKey: product.productKey, quantity: 1));
|
||||
items.add(InvoiceItemEntity(
|
||||
productKey: product.productKey,
|
||||
quantity: company.defaultQuantity ? 1 : null));
|
||||
}
|
||||
} else if (entity.entityType == EntityType.task) {
|
||||
final task = entity as TaskEntity;
|
||||
|
|
@ -78,7 +80,9 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
} else if (entity.entityType == EntityType.expense) {
|
||||
final expense = entity as ExpenseEntity;
|
||||
items.add(convertExpenseToInvoiceItem(
|
||||
expense: expense, categoryMap: company.expenseCategoryMap));
|
||||
expense: expense,
|
||||
categoryMap: company.expenseCategoryMap,
|
||||
company: company));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -172,7 +176,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
: IconButton(
|
||||
icon: Icon(Icons.add_circle_outline),
|
||||
tooltip: localization.createNew,
|
||||
onPressed: () => _addBlankItem(),
|
||||
onPressed: () => _addBlankItem(company),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue