Skip to content

Commit 40c0565

Browse files
committed
Show shop unspecific price, if no price is available for selected shop and database
has pricingCategories set for shop
1 parent 81cd731 commit 40c0565

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.10.5]
5+
6+
### Fixed
7+
- Show shop unspecific price, if no price is available for selected shop and database
8+
has pricingCategories set for shop
9+
410
## [0.10.4]
511

612
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ allprojects {
2424
}
2525

2626
project.ext {
27-
sdkVersion='0.10.4'
27+
sdkVersion='0.10.5'
2828
versionCode=1
2929

3030
compileSdkVersion=28

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,14 @@ public Product productAtCursor(Cursor cursor) {
755755

756756
Shop shop = project.getCheckedInShop();
757757

758+
if(!queryPrice(builder, sku, shop)) {
759+
queryPrice(builder, sku, null);
760+
}
761+
762+
return builder.build();
763+
}
764+
765+
private boolean queryPrice(Product.Builder builder, String sku, Shop shop) {
758766
String id = shop != null ? shop.getId() : "";
759767
String priceQuery = "SELECT listPrice, discountedPrice, basePrice FROM prices ";
760768
String[] args;
@@ -775,9 +783,10 @@ public Product productAtCursor(Cursor cursor) {
775783
builder.setDiscountedPrice(priceCursor.getInt(1));
776784
builder.setBasePrice(priceCursor.getString(2));
777785
priceCursor.close();
786+
return true;
778787
}
779788

780-
return builder.build();
789+
return false;
781790
}
782791

783792
private Product.SaleRestriction decodeSaleRestriction(long encodedValue) {

0 commit comments

Comments
 (0)