Line item taxes

This commit is contained in:
unknown 2018-07-06 10:05:22 +03:00
parent c5e60315d4
commit b55b54cb54
3 changed files with 62 additions and 50 deletions

View File

@ -23,8 +23,9 @@ class InvoiceItemListTile extends StatelessWidget {
final localization = AppLocalization.of(context);
String subtitle = '$qty x $cost';
if (invoiceItem.discount != 0) {
subtitle += ' | ${localization.discount} ';
subtitle += ' ${localization.discount} ';
if (invoice.isAmountDiscount) {
subtitle += formatNumber(invoiceItem.discount, context,
clientId: invoice.clientId);
@ -35,6 +36,16 @@ class InvoiceItemListTile extends StatelessWidget {
}
}
if (invoiceItem.taxRate1 != 0) {
final taxRate1 = formatNumber(invoiceItem.taxRate1, context, formatNumberType: FormatNumberType.percent);
subtitle += '$taxRate1 ${invoiceItem.taxName1}';
}
if (invoiceItem.taxRate2 != 0) {
final taxRate2 = formatNumber(invoiceItem.taxRate2, context, formatNumberType: FormatNumberType.percent);
subtitle += '$taxRate2 ${invoiceItem.taxName2}';
}
final List<String> parts = [];
if (invoiceItem.customValue1.isNotEmpty) {
parts.add(invoiceItem.customValue1);

View File

@ -35,8 +35,8 @@ class _TaxRateDropdownState extends State<TaxRateDropdown> {
final taxRates = widget.taxRates;
_selectedTaxRate = taxRates.firstWhere(
(taxRate) =>
taxRate.name == widget.initialTaxName &&
(taxRate) =>
taxRate.name == widget.initialTaxName &&
taxRate.rate == widget.initialTaxRate,
orElse: () => TaxRateEntity().rebuild((b) => b
..rate = widget.initialTaxRate
@ -64,56 +64,57 @@ class _TaxRateDropdownState extends State<TaxRateDropdown> {
Widget build(BuildContext context) {
final taxRates = widget.taxRates;
return StoreBuilder(builder: (BuildContext context, Store<AppState> store) {
final options = taxRates
.where(
(taxRate) => taxRate.archivedAt == null && !taxRate.isInclusive)
.map((taxRate) => PopupMenuItem<TaxRateEntity>(
value: taxRate,
child: Row(
children: <Widget>[
SizedBox(
width: 70.0,
child: Text(formatNumber(taxRate.rate, context,
formatNumberType: FormatNumberType.percent)),
),
Text(taxRate.name),
],
),
))
.toList();
if (taxRates.isEmpty) {
return Container();
}
options.insert(
0,
PopupMenuItem<TaxRateEntity>(
value: TaxRateEntity(),
child: Container(),
));
return PopupMenuButton<TaxRateEntity>(
padding: EdgeInsets.zero,
initialValue: _selectedTaxRate,
onSelected: (taxRate) {
if (taxRate.rate == 0) {
_textController.text = '';
} else {
_textController.text = _formatTaxRate(taxRate);
}
widget.onSelected(taxRate);
},
child: InkWell(
child: IgnorePointer(
child: TextFormField(
controller: _textController,
decoration: InputDecoration(
labelText: widget.labelText,
suffixIcon: const Icon(Icons.arrow_drop_down),
final options = taxRates
.where((taxRate) => taxRate.archivedAt == null && !taxRate.isInclusive)
.map((taxRate) => PopupMenuItem<TaxRateEntity>(
value: taxRate,
child: Row(
children: <Widget>[
SizedBox(
width: 70.0,
child: Text(formatNumber(taxRate.rate, context,
formatNumberType: FormatNumberType.percent)),
),
Text(taxRate.name),
],
),
))
.toList();
options.insert(
0,
PopupMenuItem<TaxRateEntity>(
value: TaxRateEntity(),
child: Container(),
));
return PopupMenuButton<TaxRateEntity>(
padding: EdgeInsets.zero,
initialValue: _selectedTaxRate,
onSelected: (taxRate) {
if (taxRate.rate == 0) {
_textController.text = '';
} else {
_textController.text = _formatTaxRate(taxRate);
}
widget.onSelected(taxRate);
},
child: InkWell(
child: IgnorePointer(
child: TextFormField(
controller: _textController,
decoration: InputDecoration(
labelText: widget.labelText,
suffixIcon: const Icon(Icons.arrow_drop_down),
),
),
),
itemBuilder: (BuildContext context) => options,
);
});
),
itemBuilder: (BuildContext context) => options,
);
}
}

View File

@ -23,7 +23,7 @@ class ProgressButton extends StatelessWidget {
*/
return Padding(
padding: EdgeInsets.only(left: 14.0, right: 14.0, top: 2.0),
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 2.0),
child: isLoading
? SizedBox(
width: 100.0,