Skip to content

Commit

Permalink
updates stock with money value
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 2, 2024
1 parent 90c3c10 commit eadf756
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import org.magic.api.beans.MTGEdition;
import org.magic.api.beans.MTGGrading;
import org.magic.api.beans.enums.EnumCondition;
import org.magic.api.beans.technical.MoneyValue;
import org.magic.api.interfaces.MTGStockItem;
import org.magic.api.interfaces.extra.MTGProduct;
import org.magic.services.MTGControler;

public abstract class AbstractStockItem<T extends MTGProduct> implements MTGStockItem {

Expand All @@ -20,7 +22,7 @@ public abstract class AbstractStockItem<T extends MTGProduct> implements MTGStoc
protected String comment="";
protected String language="English";
protected boolean updated=false;
protected Double price=0.0;
@Deprecated protected Double price=0.0;
protected MTGGrading grade;
protected MTGEdition edition;
protected T product;
Expand Down Expand Up @@ -141,6 +143,12 @@ public void setGrade(MTGGrading grade) {
this.grade = grade;
}


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


@Override
public MTGGrading getGrade() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/magic/api/interfaces/MTGStockItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.magic.api.beans.MTGCollection;
import org.magic.api.beans.MTGGrading;
import org.magic.api.beans.enums.EnumCondition;
import org.magic.api.beans.technical.MoneyValue;
import org.magic.api.interfaces.extra.MTGProduct;
import org.magic.api.interfaces.extra.MTGSerializable;

Expand All @@ -15,10 +16,15 @@ public interface MTGStockItem extends MTGSerializable, Comparable<MTGStockItem>

public MTGGrading getGrade();

@Deprecated
public Double getPrice();

@Deprecated
public void setPrice(Double price);


public MoneyValue getValue();

public Long getId();

public void setId(Integer id);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/magic/gui/models/CardStockTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.magic.api.beans.MTGGrading;
import org.magic.api.beans.enums.EnumCondition;
import org.magic.api.beans.enums.EnumRarity;
import org.magic.api.beans.technical.MoneyValue;
import org.magic.gui.abstracts.GenericTableModel;
import org.magic.services.tools.UITools;

Expand Down Expand Up @@ -95,7 +96,7 @@ public Class<?> getColumnClass(int columnIndex) {
return Boolean.class;

case 14:
return Double.class;
return MoneyValue.class;
case 15:
return MTGGrading.class;
case 16:
Expand Down Expand Up @@ -153,7 +154,7 @@ public Object getValueAt(int row, int column) {
case 13:
return items.get(row).isDigital();
case 14:
return UITools.roundDouble(items.get(row).getPrice());
return items.get(row).getValue();
case 15:
return items.get(row).getGrade();
case 16:
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/magic/gui/models/SealedStockTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.magic.api.beans.enums.EnumCondition;
import org.magic.api.beans.enums.EnumExtra;
import org.magic.api.beans.enums.EnumItems;
import org.magic.api.beans.technical.MoneyValue;
import org.magic.gui.abstracts.GenericTableModel;
import org.magic.services.tools.UITools;

Expand All @@ -30,7 +31,7 @@ public Class<?> getColumnClass(int columnIndex) {
case 5: return EnumCondition.class;
case 6: return Integer.class;
case 7: return MTGCollection.class;
case 8: return Double.class;
case 8: return MoneyValue.class;
default: return super.getColumnClass(columnIndex);
}
}
Expand All @@ -52,7 +53,7 @@ public Object getValueAt(int row, int column) {
case 5: return it.getCondition();
case 6 : return it.getQte();
case 7 : return it.getMagicCollection();
case 8 : return it.getPrice();
case 8 : return it.getValue();
case 9 : return it.getTiersAppIds();
default : return super.getValueAt(row, column);
}
Expand Down

0 comments on commit eadf756

Please sign in to comment.