Skip to content

Commit

Permalink
remove getPrice from stockIem interface for getValue instead
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 2, 2024
1 parent eadf756 commit cc2e012
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class AbstractStockItem<T extends MTGProduct> implements MTGStoc
protected String comment="";
protected String language="English";
protected boolean updated=false;
@Deprecated protected Double price=0.0;
protected Double price=0.0;
protected MTGGrading grade;
protected MTGEdition edition;
protected T product;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void setGrade(MTGGrading grade) {

@Override
public MoneyValue getValue() {
return new MoneyValue(getPrice(), MTGControler.getInstance().getCurrencyService().getCurrentCurrency());
return new MoneyValue(price, MTGControler.getInstance().getCurrencyService().getCurrentCurrency());
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/magic/api/beans/shop/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public EnumTransactionStatus getStatut() {

public double totalItems()
{
return getItems().stream().mapToDouble(e->e.getQte()*e.getPrice()).sum();
return getItems().stream().mapToDouble(e->e.getQte()*e.getValue().doubleValue()).sum();
}

public double total()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ public Map<String, Object> build(MTGStockItem st) {
productInfo.put("name", st.getProduct().getName());

productInfo.put("type", "simple");
productInfo.put("regular_price", String.valueOf(st.getPrice()));
productInfo.put("price", String.valueOf(st.getPrice()));
productInfo.put("regular_price", String.valueOf(st.getValue().doubleValue()));
productInfo.put("price", String.valueOf(st.getValue().doubleValue()));

if(getBoolean(CATEGORY_EDITION_MAPPING))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public void saveOrUpdateStock(List<MTGStockItem> stocks) throws IOException {
var art = new Article();
art.setIdArticle(it.getId().intValue());
art.setIdProduct(it.getProduct().getProductId().intValue());
art.setPrice(it.getPrice());
art.setPrice(it.getValue().doubleValue());
art.setCondition(aliases.getConditionFor(this,it.getCondition()));
art.setFoil(it.isFoil());
art.setSigned(it.isSigned());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected void saveOrUpdateStock(List<MTGStockItem> it) throws IOException {
var objVariant = new JsonObject();
obj.add(VARIANT, objVariant);

objVariant.addProperty(PRICE, c.getPrice());
objVariant.addProperty(PRICE, c.getValue().doubleValue());
objVariant.addProperty(OPTION+getString(FOIL_OPTION_NUMBER), c.isFoil());

try {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/magic/api/interfaces/MTGStockItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public interface MTGStockItem extends MTGSerializable, Comparable<MTGStockItem>

@Deprecated
public void setPrice(Double price);


public MoneyValue getValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Category getCategoryById(Integer id) throws IOException {
public List<MTGStockItem> listStock(String search) throws IOException {
var list= loadStock(search);
itemsBkcp.clear();
list.forEach(item->itemsBkcp.put(item, new SimpleEntry<>(item.getQte(), item.getPrice()) ));
list.forEach(item->itemsBkcp.put(item, new SimpleEntry<>(item.getQte(), item.getValue().doubleValue()) ));
return list;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private Map<Object, Double> groupOrdersBy() {
if(count)
ret.put(val, ret.get(val)==null? 1 : ret.get(val)+1);
else
ret.put(val, ret.get(val)==null? UITools.roundDouble(o.getQte()*o.getPrice()) : UITools.roundDouble(ret.get(val)+(o.getQte()*o.getPrice())));
ret.put(val, ret.get(val)==null? UITools.roundDouble(o.getQte()*o.getValue().doubleValue()) : UITools.roundDouble(ret.get(val)+(o.getQte()*o.getValue().doubleValue())));


} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.magic.gui.components.deck;

import static org.magic.services.tools.MTG.capitalize;
import static org.magic.services.tools.MTG.listEnabledPlugins;

import java.awt.BorderLayout;
import java.awt.Dimension;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/magic/gui/models/StockItemTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import org.magic.api.beans.MTGEdition;
import org.magic.api.beans.enums.EnumCondition;
import org.magic.api.beans.enums.EnumItems;
import org.magic.api.beans.technical.MoneyValue;
import org.magic.api.interfaces.MTGStockItem;
import org.magic.api.interfaces.extra.MTGProduct;
import org.magic.gui.abstracts.GenericTableModel;
import org.magic.services.tools.UITools;

public class StockItemTableModel extends GenericTableModel<MTGStockItem> {

Expand Down Expand Up @@ -80,7 +80,7 @@ public Class<?> getColumnClass(int columnIndex) {
case 9:
return Integer.class;
case 10:
return Double.class;
return MoneyValue.class;
case 11:
return String.class;
case 12:
Expand Down Expand Up @@ -127,7 +127,7 @@ public Object getValueAt(int row, int column) {
case 9:
return items.get(row).getQte();
case 10:
return UITools.roundDouble(items.get(row).getPrice());
return items.get(row).getValue();
case 11:
return items.get(row).getComment();
case 12:
Expand Down

0 comments on commit cc2e012

Please sign in to comment.