Skip to content

Commit

Permalink
transaction update for date creation and shopID
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Jan 5, 2024
1 parent 5005a73 commit 2f0a4b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>memoryfilesystem</artifactId>
<version>2.7.0</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.panda-lang</groupId>
Expand Down Expand Up @@ -409,7 +409,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.18</version>
<version>5.0.0-beta.19</version>
<exclusions>
<exclusion>
<groupId>club.minnced</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ public Long saveOrUpdateTransaction(Transaction t) {

logger.debug("saving transaction ");

try (var c = pool.getConnection(); PreparedStatement pst = c.prepareStatement("INSERT INTO transactions (dateTransaction, message, stocksItem, statut,transporter,shippingPrice,transporterShippingCode, currency,datePayment,dateSend,paymentProvider, fk_idcontact,sourceShopId, sourceShopName,typeTransaction,reduction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",Statement.RETURN_GENERATED_KEYS)) {
try (var c = pool.getConnection(); PreparedStatement pst = c.prepareStatement("INSERT INTO transactions (dateTransaction, message, stocksItem, statut,transporter,shippingPrice,transporterShippingCode, currency,datePayment,dateSend,paymentProvider, fk_idcontact,sourceShopId, sourceShopName,typeTransaction,reduction,sourceShopId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",Statement.RETURN_GENERATED_KEYS)) {
pst.setTimestamp(1, new Timestamp(t.getDateCreation().getTime()));
pst.setString(2, t.getMessage());
storeTransactionItems(pst,3, t.getItems());
Expand Down Expand Up @@ -1075,7 +1075,7 @@ public Long saveOrUpdateTransaction(Transaction t) {
pst.setString(14, t.getSourceShopName());
pst.setString(15, t.getTypeTransaction().name());
pst.setDouble(16, t.getReduction());

pst.setString(17, t.getSourceShopId());
executeUpdate(pst);
t.setId(getGeneratedKey(pst));

Expand All @@ -1092,7 +1092,7 @@ public Long saveOrUpdateTransaction(Transaction t) {

logger.debug("update transaction {}",t.getId());

try (var c = pool.getConnection(); PreparedStatement pst = c.prepareStatement("UPDATE transactions SET statut = ?, transporter=?, shippingPrice=?, transporterShippingCode=?,stocksItem=?,datePayment=?,dateSend=?,paymentProvider=?, sourceShopId=?, sourceShopName=?, reduction=?, typeTransaction=? ,fk_idcontact=? WHERE id = ?",Statement.RETURN_GENERATED_KEYS)) {
try (var c = pool.getConnection(); PreparedStatement pst = c.prepareStatement("UPDATE transactions SET statut = ?, transporter=?, shippingPrice=?, transporterShippingCode=?,stocksItem=?,datePayment=?,dateSend=?,paymentProvider=?, sourceShopId=?, sourceShopName=?, reduction=?, typeTransaction=? ,fk_idcontact=?,dateTransaction=? WHERE id = ?",Statement.RETURN_GENERATED_KEYS)) {
pst.setString(1, t.getStatut().name());
pst.setString(2, t.getTransporter());
pst.setDouble(3, t.getShippingPrice());
Expand Down Expand Up @@ -1123,7 +1123,13 @@ public Long saveOrUpdateTransaction(Transaction t) {

pst.setInt(13, t.getContact().getId());

pst.setLong(14, t.getId());

if(t.getDateCreation()!=null)
pst.setTimestamp(14, new Timestamp(t.getDateCreation().getTime()));
else
pst.setTimestamp(14, null);

pst.setLong(15, t.getId());



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TransactionsTableModel extends GenericTableModel<Transaction> {
public TransactionsTableModel() {

setWritable(true);
columns = new String[] { "ID","DATE","CONTACT","ITEMS", "SHIPPING","Reduction","TOTAL", "DATE PAYMENT","PAYMENT METHOD","DATE SEND","TRACKING NUMBER","MESSAGE","STATUT","DIRECTION","Source" };
columns = new String[] { "ID","DATE","CONTACT","ITEMS", "SHIPPING","Reduction","TOTAL", "DATE PAYMENT","PAYMENT METHOD","DATE SEND","TRACKING NUMBER","MESSAGE","STATUT","DIRECTION","Source","EXT TRANSACTION ID" };
}


Expand All @@ -42,6 +42,7 @@ public synchronized void setValueAt(Object aValue, int row, int column) {
case 12 : getItemAt(row).setStatut(EnumTransactionStatus.valueOf(aValue.toString()));break;
case 13 : getItemAt(row).setTypeTransaction(EnumTransactionDirection.valueOf(aValue.toString()));break;
case 14 : getItemAt(row).setSourceShopName(String.valueOf(aValue).trim());break;
case 15 : getItemAt(row).setSourceShopId(String.valueOf(aValue).trim());break;
default:break;
}
fireTableCellUpdated(row, column);
Expand All @@ -68,6 +69,7 @@ public Object getValueAt(int row, int column) {
case 12 : return it.getStatut();
case 13 : return it.getTypeTransaction();
case 14 : return it.getSourceShopName();
case 15 : return it.getSourceShopId();
default : return 0;
}
}
Expand Down

0 comments on commit 2f0a4b4

Please sign in to comment.