Correct invoice line items
This commit is contained in:
parent
d2cef33679
commit
0e4856fbd0
|
|
@ -159,6 +159,10 @@ class _EntityDropdownState extends State<EntityDropdown> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onSuggestionSelected: (entityId) {
|
onSuggestionSelected: (entityId) {
|
||||||
|
if (kIsWeb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final entity = _entityMap[entityId];
|
final entity = _entityMap[entityId];
|
||||||
_textController.text = _entityMap[entityId].listDisplayName;
|
_textController.text = _entityMap[entityId].listDisplayName;
|
||||||
widget.onSelected(entity);
|
widget.onSelected(entity);
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,16 @@ class CreditEditItemsVM extends EntityEditItemsVM {
|
||||||
);
|
);
|
||||||
|
|
||||||
factory CreditEditItemsVM.fromStore(Store<AppState> store) {
|
factory CreditEditItemsVM.fromStore(Store<AppState> store) {
|
||||||
final AppState state = store.state;
|
|
||||||
final credit = state.creditUIState.editing;
|
|
||||||
|
|
||||||
return CreditEditItemsVM(
|
return CreditEditItemsVM(
|
||||||
state: state,
|
state: store.state,
|
||||||
company: state.company,
|
company: store.state.company,
|
||||||
invoice: credit,
|
invoice: store.state.creditUIState.editing,
|
||||||
invoiceItemIndex: state.creditUIState.editingItemIndex,
|
invoiceItemIndex: store.state.creditUIState.editingItemIndex,
|
||||||
onRemoveInvoiceItemPressed: (index) =>
|
onRemoveInvoiceItemPressed: (index) =>
|
||||||
store.dispatch(DeleteCreditItem(index)),
|
store.dispatch(DeleteCreditItem(index)),
|
||||||
onDoneInvoiceItemPressed: () => store.dispatch(EditCreditItem()),
|
onDoneInvoiceItemPressed: () => store.dispatch(EditCreditItem()),
|
||||||
onChangedInvoiceItem: (creditItem, index) {
|
onChangedInvoiceItem: (creditItem, index) {
|
||||||
|
final credit = store.state.creditUIState.editing;
|
||||||
if (index == credit.lineItems.length) {
|
if (index == credit.lineItems.length) {
|
||||||
store.dispatch(AddCreditItem(creditItem: creditItem));
|
store.dispatch(AddCreditItem(creditItem: creditItem));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onSuggestionSelected: (suggestion) {
|
onSuggestionSelected: (suggestion) {
|
||||||
|
if (kIsWeb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final item = lineItems[index];
|
final item = lineItems[index];
|
||||||
final product = productState.map[suggestion];
|
final product = productState.map[suggestion];
|
||||||
final updatedItem = item.rebuild((b) => b
|
final updatedItem = item.rebuild((b) => b
|
||||||
|
|
|
||||||
|
|
@ -82,14 +82,12 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
|
||||||
);
|
);
|
||||||
|
|
||||||
factory InvoiceEditItemsVM.fromStore(Store<AppState> store) {
|
factory InvoiceEditItemsVM.fromStore(Store<AppState> store) {
|
||||||
final AppState state = store.state;
|
|
||||||
final invoice = state.invoiceUIState.editing;
|
|
||||||
|
|
||||||
return InvoiceEditItemsVM(
|
return InvoiceEditItemsVM(
|
||||||
state: state,
|
state: store.state,
|
||||||
company: state.company,
|
company: store.state.company,
|
||||||
invoice: invoice,
|
invoice: store.state.invoiceUIState.editing,
|
||||||
invoiceItemIndex: state.invoiceUIState.editingItemIndex,
|
invoiceItemIndex: store.state.invoiceUIState.editingItemIndex,
|
||||||
addLineItem: () =>
|
addLineItem: () =>
|
||||||
store.dispatch(AddInvoiceItem(invoiceItem: InvoiceItemEntity())),
|
store.dispatch(AddInvoiceItem(invoiceItem: InvoiceItemEntity())),
|
||||||
deleteLineItem: null,
|
deleteLineItem: null,
|
||||||
|
|
@ -97,6 +95,7 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
|
||||||
store.dispatch(DeleteInvoiceItem(index)),
|
store.dispatch(DeleteInvoiceItem(index)),
|
||||||
onDoneInvoiceItemPressed: () => store.dispatch(EditInvoiceItem()),
|
onDoneInvoiceItemPressed: () => store.dispatch(EditInvoiceItem()),
|
||||||
onChangedInvoiceItem: (invoiceItem, index) {
|
onChangedInvoiceItem: (invoiceItem, index) {
|
||||||
|
final invoice = store.state.invoiceUIState.editing;
|
||||||
if (index == invoice.lineItems.length) {
|
if (index == invoice.lineItems.length) {
|
||||||
store.dispatch(AddInvoiceItem(invoiceItem: invoiceItem));
|
store.dispatch(AddInvoiceItem(invoiceItem: invoiceItem));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,16 @@ class QuoteEditItemsVM extends EntityEditItemsVM {
|
||||||
);
|
);
|
||||||
|
|
||||||
factory QuoteEditItemsVM.fromStore(Store<AppState> store) {
|
factory QuoteEditItemsVM.fromStore(Store<AppState> store) {
|
||||||
final AppState state = store.state;
|
|
||||||
final quote = state.quoteUIState.editing;
|
|
||||||
|
|
||||||
return QuoteEditItemsVM(
|
return QuoteEditItemsVM(
|
||||||
state: state,
|
state: store.state,
|
||||||
company: state.company,
|
company: store.state.company,
|
||||||
invoice: quote,
|
invoice: store.state.quoteUIState.editing,
|
||||||
invoiceItemIndex: state.quoteUIState.editingItemIndex,
|
invoiceItemIndex: store.state.quoteUIState.editingItemIndex,
|
||||||
onRemoveInvoiceItemPressed: (index) =>
|
onRemoveInvoiceItemPressed: (index) =>
|
||||||
store.dispatch(DeleteQuoteItem(index)),
|
store.dispatch(DeleteQuoteItem(index)),
|
||||||
onDoneInvoiceItemPressed: () => store.dispatch(EditQuoteItem()),
|
onDoneInvoiceItemPressed: () => store.dispatch(EditQuoteItem()),
|
||||||
onChangedInvoiceItem: (quoteItem, index) {
|
onChangedInvoiceItem: (quoteItem, index) {
|
||||||
|
final quote = store.state.quoteUIState.editing;
|
||||||
if (index == quote.lineItems.length) {
|
if (index == quote.lineItems.length) {
|
||||||
store.dispatch(AddQuoteItem(quoteItem: quoteItem));
|
store.dispatch(AddQuoteItem(quoteItem: quoteItem));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue