Rewrite some of the grossUnitPrice stuff
This commit is contained in:
+129
-106
@@ -10745,17 +10745,6 @@ var $author$project$Entry$ItemEditor = function (a) {
|
||||
var $author$project$Entry$ReceiveSearchResults = function (a) {
|
||||
return {$: 'ReceiveSearchResults', a: a};
|
||||
};
|
||||
var $elm$core$Basics$pow = _Basics_pow;
|
||||
var $elm$core$Basics$round = _Basics_round;
|
||||
var $author$project$Entry$roundTo = F2(
|
||||
function (places, x) {
|
||||
return $elm$core$Basics$round(
|
||||
x * A2($elm$core$Basics$pow, 10, places)) / A2($elm$core$Basics$pow, 10, places);
|
||||
});
|
||||
var $author$project$Entry$calculateGarfieldPrice = F2(
|
||||
function (netUnitPrice, taxPercentage) {
|
||||
return A2($author$project$Entry$roundTo, 2, (netUnitPrice * (1 + taxPercentage)) + 0.01);
|
||||
});
|
||||
var $elm$http$Http$BadStatus_ = F2(
|
||||
function (a, b) {
|
||||
return {$: 'BadStatus_', a: a, b: b};
|
||||
@@ -10882,14 +10871,14 @@ var $elm$core$String$toFloat = _String_toFloat;
|
||||
var $author$project$NumberInput$fromFloat = function (x) {
|
||||
return A3(
|
||||
$author$project$NumberInput$Model,
|
||||
x,
|
||||
$elm$core$Maybe$Just(x),
|
||||
$elm$core$String$fromFloat(x),
|
||||
$elm$core$String$toFloat);
|
||||
};
|
||||
var $author$project$NumberInput$fromInt = function (x) {
|
||||
return A3(
|
||||
$author$project$NumberInput$Model,
|
||||
x,
|
||||
$elm$core$Maybe$Just(x),
|
||||
$elm$core$String$fromInt(x),
|
||||
$elm$core$String$toInt);
|
||||
};
|
||||
@@ -11132,15 +11121,12 @@ var $author$project$Entry$searchResultDecoder = A3(
|
||||
$elm$json$Json$Decode$succeed($author$project$Entry$SearchResult))))))))))));
|
||||
var $author$project$NumberInput$update = F2(
|
||||
function (str, model) {
|
||||
var _v0 = model.convert(str);
|
||||
if (_v0.$ === 'Nothing') {
|
||||
return model;
|
||||
} else {
|
||||
var value = _v0.a;
|
||||
return _Utils_update(
|
||||
model,
|
||||
{original: str, value: value});
|
||||
}
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
original: str,
|
||||
value: model.convert(str)
|
||||
});
|
||||
});
|
||||
var $author$project$Select$find = F2(
|
||||
function (pred, xs) {
|
||||
@@ -11172,15 +11158,45 @@ var $author$project$NumberInput$get = function ($) {
|
||||
var $author$project$Select$get = function ($) {
|
||||
return $.selected;
|
||||
};
|
||||
var $elm$core$Maybe$map = F2(
|
||||
function (f, maybe) {
|
||||
if (maybe.$ === 'Just') {
|
||||
var value = maybe.a;
|
||||
return $elm$core$Maybe$Just(
|
||||
f(value));
|
||||
} else {
|
||||
return $elm$core$Maybe$Nothing;
|
||||
}
|
||||
});
|
||||
var $elm$core$Basics$pow = _Basics_pow;
|
||||
var $elm$core$Basics$round = _Basics_round;
|
||||
var $author$project$Entry$roundTo = F2(
|
||||
function (places, x) {
|
||||
return $elm$core$Basics$round(
|
||||
x * A2($elm$core$Basics$pow, 10, places)) / A2($elm$core$Basics$pow, 10, places);
|
||||
});
|
||||
var $author$project$Entry$calculateGarfieldPrice = function (model) {
|
||||
return A2(
|
||||
$elm$core$Maybe$map,
|
||||
function (netUnitPrice) {
|
||||
return A2(
|
||||
$author$project$Entry$roundTo,
|
||||
2,
|
||||
(netUnitPrice * (1 + $author$project$Select$get(model.taxGroup).percentage)) + 0.01);
|
||||
},
|
||||
$author$project$NumberInput$get(model.netUnitPrice));
|
||||
};
|
||||
var $author$project$Entry$updateGrossUnitPrice = function (model) {
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
grossUnitPrice: $author$project$NumberInput$fromFloat(
|
||||
grossUnitPrice: A2(
|
||||
$elm$core$Maybe$withDefault,
|
||||
model.grossUnitPrice,
|
||||
A2(
|
||||
$author$project$Entry$calculateGarfieldPrice,
|
||||
$author$project$NumberInput$get(model.netUnitPrice),
|
||||
$author$project$Select$get(model.taxGroup).percentage))
|
||||
$elm$core$Maybe$map,
|
||||
$author$project$NumberInput$fromFloat,
|
||||
$author$project$Entry$calculateGarfieldPrice(model)))
|
||||
});
|
||||
};
|
||||
var $author$project$Entry$updateState = F3(
|
||||
@@ -11235,53 +11251,53 @@ var $author$project$Entry$updateState = F3(
|
||||
var taxGroup = _v2.a;
|
||||
return _Utils_Tuple2(
|
||||
$author$project$Entry$ItemEditor(
|
||||
{
|
||||
barcode: searchResult.barcode,
|
||||
grossUnitPrice: $author$project$NumberInput$fromFloat(
|
||||
A2($author$project$Entry$calculateGarfieldPrice, searchResult.netUnitPrice, taxGroup.percentage)),
|
||||
group: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
$author$project$Entry$updateGrossUnitPrice(
|
||||
{
|
||||
barcode: searchResult.barcode,
|
||||
grossUnitPrice: $author$project$NumberInput$fromFloat(0),
|
||||
group: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
function ($) {
|
||||
return $.id;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.id;
|
||||
return $.name;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.name;
|
||||
},
|
||||
{id: searchResult.groupId, name: searchResult.groupName},
|
||||
globals.groups),
|
||||
location: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
{id: searchResult.groupId, name: searchResult.groupName},
|
||||
globals.groups),
|
||||
location: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
function ($) {
|
||||
return $.id;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.id;
|
||||
return $.name;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.name;
|
||||
},
|
||||
{id: searchResult.locationId, name: searchResult.locationName},
|
||||
globals.locations),
|
||||
name: searchResult.name,
|
||||
netUnitPrice: $author$project$NumberInput$fromFloat(searchResult.netUnitPrice),
|
||||
salesUnits: $author$project$NumberInput$fromInt(searchResult.salesUnits),
|
||||
taxGroup: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
{id: searchResult.locationId, name: searchResult.locationName},
|
||||
globals.locations),
|
||||
name: searchResult.name,
|
||||
netUnitPrice: $author$project$NumberInput$fromFloat(searchResult.netUnitPrice),
|
||||
salesUnits: $author$project$NumberInput$fromInt(searchResult.salesUnits),
|
||||
taxGroup: A4(
|
||||
$author$project$Select$init,
|
||||
A2(
|
||||
$elm$core$Basics$composeR,
|
||||
function ($) {
|
||||
return $.id;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.id;
|
||||
return $.description;
|
||||
},
|
||||
$elm$core$String$fromInt),
|
||||
function ($) {
|
||||
return $.description;
|
||||
},
|
||||
taxGroup,
|
||||
globals.taxGroups)
|
||||
}),
|
||||
taxGroup,
|
||||
globals.taxGroups)
|
||||
})),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
default:
|
||||
@@ -11389,9 +11405,6 @@ var $author$project$Entry$update = F2(
|
||||
var $author$project$Entry$SetBarcode = function (a) {
|
||||
return {$: 'SetBarcode', a: a};
|
||||
};
|
||||
var $author$project$Entry$SetGrossUnitPrice = function (a) {
|
||||
return {$: 'SetGrossUnitPrice', a: a};
|
||||
};
|
||||
var $author$project$Entry$SetGroup = function (a) {
|
||||
return {$: 'SetGroup', a: a};
|
||||
};
|
||||
@@ -11553,6 +11566,51 @@ var $author$project$Select$view = F2(
|
||||
]),
|
||||
A2($elm$core$List$map, viewOption, model.options));
|
||||
});
|
||||
var $author$project$Entry$SetGrossUnitPrice = function (a) {
|
||||
return {$: 'SetGrossUnitPrice', a: a};
|
||||
};
|
||||
var $author$project$Entry$viewGrossUnitPriceInput = function (model) {
|
||||
var suggestedPriceStr = function () {
|
||||
var _v0 = $author$project$Entry$calculateGarfieldPrice(model);
|
||||
if (_v0.$ === 'Nothing') {
|
||||
return '?';
|
||||
} else {
|
||||
var suggestedPrice = _v0.a;
|
||||
return $elm$core$String$fromFloat(suggestedPrice);
|
||||
}
|
||||
}();
|
||||
return A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('form-input')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$label,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$for('gross-unit-price')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text('Stückpreis (Brutto), Vorschlag: ' + suggestedPriceStr)
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$input,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Events$onInput($author$project$Entry$SetGrossUnitPrice),
|
||||
$elm$html$Html$Attributes$value(
|
||||
$author$project$NumberInput$show(model.grossUnitPrice)),
|
||||
$elm$html$Html$Attributes$id('gross-unit-price'),
|
||||
$elm$html$Html$Attributes$type_('number'),
|
||||
$elm$html$Html$Attributes$step('0.01')
|
||||
]),
|
||||
_List_Nil)
|
||||
]));
|
||||
};
|
||||
var $author$project$Entry$GotoItemEditor = function (a) {
|
||||
return {$: 'GotoItemEditor', a: a};
|
||||
};
|
||||
@@ -11955,42 +12013,7 @@ var $author$project$Entry$view = function (_v0) {
|
||||
]),
|
||||
_List_Nil)
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('form-input')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$label,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$for('gross-unit-price')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
'Stückpreis (Brutto), Vorschlag: ' + $elm$core$String$fromFloat(
|
||||
A2(
|
||||
$author$project$Entry$calculateGarfieldPrice,
|
||||
$author$project$NumberInput$get(model.netUnitPrice),
|
||||
$author$project$Select$get(model.taxGroup).percentage)))
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$input,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Events$onInput($author$project$Entry$SetGrossUnitPrice),
|
||||
$elm$html$Html$Attributes$value(
|
||||
$author$project$NumberInput$show(model.grossUnitPrice)),
|
||||
$elm$html$Html$Attributes$id('gross-unit-price'),
|
||||
$elm$html$Html$Attributes$type_('number'),
|
||||
$elm$html$Html$Attributes$step('0.01')
|
||||
]),
|
||||
_List_Nil)
|
||||
]))
|
||||
$author$project$Entry$viewGrossUnitPriceInput(model)
|
||||
]))
|
||||
]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user