@@ -185,17 +185,23 @@ private void handleProductAvailable(Product product, boolean wasOnlineProduct, S
185185 } else {
186186 int scale = decimal .scale ();
187187 Unit fractionalUnit = unit .getFractionalUnit (scale );
188- if (fractionalUnit != null ) {
189- BigDecimal converted = Unit .convert (decimal , unit , fractionalUnit );
190- scannedCode .setEmbeddedData (converted .intValue ());
191- scannedCode .setEmbeddedUnit (fractionalUnit );
188+ if (fractionalUnit == null ) {
189+ fractionalUnit = unit ;
190+
191+ if (scale > 0 ) {
192+ decimal = decimal .multiply (new BigDecimal (Math .pow (10 , scale )));
193+ }
192194 }
195+
196+ BigDecimal converted = Unit .convert (decimal , unit , fractionalUnit );
197+ scannedCode .setEmbeddedData (converted .intValue ());
198+ scannedCode .setEmbeddedUnit (fractionalUnit );
193199 }
194200 }
195201 }
196202
197203 if (product .getBundleProducts ().length > 0 ){
198- showBundleDialog (product );
204+ showBundleDialog (product , scannedCode );
199205 } else {
200206 if (product .getSaleStop ()) {
201207 if (onSaleStopListener != null ) {
@@ -230,18 +236,15 @@ private void handleProductAvailable(Product product, boolean wasOnlineProduct, S
230236 }
231237 }
232238
233- private void showBundleDialog (Product product ) {
239+ private void showBundleDialog (Product product , final ScannedCode scannedCode ) {
234240 SelectBundleDialog .show (context , product , new SelectBundleDialog .Callback () {
235241 @ Override
236242 public void onProductSelected (Product product ) {
237243 Telemetry .event (Telemetry .Event .SelectedBundleProduct , product );
238244
239245 Product .Code [] codes = product .getScannableCodes ();
240- if (codes .length > 0 ) {
241- List <ScannedCode > scannedCodes = ScannedCode .parse (SnabbleUI .getProject (), codes [0 ].lookupCode );
242- if (scannedCodes != null && scannedCodes .size () > 0 ) {
243- showProduct (product , scannedCodes .get (0 ));
244- }
246+ if (codes .length > 0 ) {
247+ showProduct (product , scannedCode );
245248 }
246249 }
247250
0 commit comments