Skip to content

Commit

Permalink
Another hopeful fix for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiczedler committed May 16, 2020
1 parent 5788622 commit 86194ca
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions app/src/main/java/xyz/zedler/patrick/grocy/model/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Product implements Parcelable {
private int quIdStock; // quantity unit

@SerializedName("qu_factor_purchase_to_stock")
private double quFactorPurchaseToStock; // quantity unit
private String quFactorPurchaseToStock; // quantity unit

@SerializedName("enable_tare_weight_handling")
private int enableTareWeightHandling;
Expand All @@ -59,7 +59,7 @@ public class Product implements Parcelable {
private String barcode;

@SerializedName("min_stock_amount")
private double minStockAmount;
private String minStockAmount;

@SerializedName("default_best_before_days")
private int defaultBestBeforeDays;
Expand All @@ -83,7 +83,7 @@ public class Product implements Parcelable {
private int allowPartialUnitsInStock;

@SerializedName("tare_weight")
private double tareWeight;
private String tareWeight;

@SerializedName("not_check_stock_fulfillment_for_recipes")
private int notCheckStockFulfillmentForRecipes;
Expand All @@ -92,7 +92,7 @@ public class Product implements Parcelable {
private String parentProductId; /// STRING: null for empty

@SerializedName("calories")
private double calories;
private String calories;

@SerializedName("cumulate_min_stock_amount_of_sub_products")
private int cumulateMinStockAmountOfSubProducts;
Expand All @@ -107,22 +107,22 @@ public Product(Parcel parcel) {
locationId = parcel.readInt();
quIdPurchase = parcel.readInt();
quIdStock = parcel.readInt();
quFactorPurchaseToStock = parcel.readDouble();
quFactorPurchaseToStock = parcel.readString();
enableTareWeightHandling = parcel.readInt();
pictureFileName = parcel.readString();
barcode = parcel.readString();
minStockAmount = parcel.readDouble();
minStockAmount = parcel.readString();
defaultBestBeforeDays = parcel.readInt();
defaultBestBeforeDaysAfterOpen = parcel.readInt();
defaultBestBeforeDaysAfterFreezing = parcel.readInt();
defaultBestBeforeDaysAfterThawing = parcel.readInt();
rowCreatedTimestamp = parcel.readString();
productGroupId = parcel.readString();
allowPartialUnitsInStock = parcel.readInt();
tareWeight = parcel.readDouble();
tareWeight = parcel.readString();
notCheckStockFulfillmentForRecipes = parcel.readInt();
parentProductId = parcel.readString();
calories = parcel.readInt();
calories = parcel.readString();
cumulateMinStockAmountOfSubProducts = parcel.readInt();
storeId = parcel.readString();
}
Expand All @@ -135,22 +135,22 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(locationId);
dest.writeInt(quIdPurchase);
dest.writeInt(quIdStock);
dest.writeDouble(quFactorPurchaseToStock);
dest.writeString(quFactorPurchaseToStock);
dest.writeInt(enableTareWeightHandling);
dest.writeString(pictureFileName);
dest.writeString(barcode);
dest.writeDouble(minStockAmount);
dest.writeString(minStockAmount);
dest.writeInt(defaultBestBeforeDays);
dest.writeInt(defaultBestBeforeDaysAfterOpen);
dest.writeInt(defaultBestBeforeDaysAfterFreezing);
dest.writeInt(defaultBestBeforeDaysAfterThawing);
dest.writeString(rowCreatedTimestamp);
dest.writeString(productGroupId);
dest.writeInt(allowPartialUnitsInStock);
dest.writeDouble(tareWeight);
dest.writeString(tareWeight);
dest.writeInt(notCheckStockFulfillmentForRecipes);
dest.writeString(parentProductId);
dest.writeDouble(calories);
dest.writeString(calories);
dest.writeInt(cumulateMinStockAmountOfSubProducts);
dest.writeString(storeId);
}
Expand Down Expand Up @@ -197,7 +197,11 @@ public int getQuIdPurchase() {
}

public double getQuFactorPurchaseToStock() {
return quFactorPurchaseToStock;
if(quFactorPurchaseToStock == null || quFactorPurchaseToStock.isEmpty()) {
return 1;
} else {
return Double.parseDouble(quFactorPurchaseToStock);
}
}

public int getEnableTareWeightHandling() {
Expand All @@ -209,7 +213,11 @@ public String getBarcode() {
}

public double getMinStockAmount() {
return minStockAmount;
if(minStockAmount == null || minStockAmount.isEmpty()) {
return 0;
} else {
return Double.parseDouble(minStockAmount);
}
}

public int getDefaultBestBeforeDays() {
Expand Down Expand Up @@ -241,7 +249,11 @@ public int getAllowPartialUnitsInStock() {
}

public double getTareWeight() {
return tareWeight;
if(tareWeight == null || tareWeight.isEmpty()) {
return 0;
} else {
return Double.parseDouble(tareWeight);
}
}

public int getNotCheckStockFulfillmentForRecipes() {
Expand All @@ -253,7 +265,11 @@ public String getParentProductId() {
}

public double getCalories() {
return calories;
if(calories == null || calories.isEmpty()) {
return 0;
} else {
return Double.parseDouble(calories);
}
}

public int getCumulateMinStockAmountOfSubProducts() {
Expand Down

0 comments on commit 86194ca

Please sign in to comment.