Skip to content

Commit

Permalink
Merge pull request #270 from amihaiemil/269
Browse files Browse the repository at this point in the history
#269 updated to core 68
  • Loading branch information
amihaiemil authored Mar 11, 2021
2 parents 7bcb78d + a08620e commit cfc34a9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>Self XDSD Storage Module</name>
<description>Storage Module for Self XDSD</description>
<properties>
<self.core.version>0.0.67</self.core.version>
<self.core.version>0.0.68</self.core.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/selfxdsd/storage/SelfInvoices.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public Invoice createNewInvoice(final Contract.Id contractId) {
null,
null,
null,
null,
BigDecimal.valueOf(0),
this.storage
);
Expand Down Expand Up @@ -164,14 +163,15 @@ public Payment registerAsPaid(
"Invoice #" + invoice.invoiceId() + " is not paid!"
);
}
final Payment success = invoice.latest();
final int[] updated = new int[1];
if(invoice.transactionId().startsWith("fake_payment_")) {
if(success.transactionId().startsWith("fake_payment_")) {
updated[0] = this.database.jooq().update(SLF_INVOICES_XDSD).set(
SLF_INVOICES_XDSD.TRANSACTIONID,
invoice.transactionId()
success.transactionId()
).set(
SLF_INVOICES_XDSD.PAYMENT_TIMESTAMP,
invoice.paymentTime()
success.paymentTime()
).set(
SLF_INVOICES_XDSD.BILLEDBY,
invoice.billedBy()
Expand All @@ -197,10 +197,10 @@ public Payment registerAsPaid(
final String contributorBilling = invoice.billedBy();
updated[0] = jooq.update(SLF_INVOICES_XDSD).set(
SLF_INVOICES_XDSD.TRANSACTIONID,
invoice.transactionId()
success.transactionId()
).set(
SLF_INVOICES_XDSD.PAYMENT_TIMESTAMP,
invoice.paymentTime()
success.paymentTime()
).set(
SLF_INVOICES_XDSD.BILLEDBY,
contributorBilling
Expand Down Expand Up @@ -234,8 +234,8 @@ public Payment registerAsPaid(
contributorBilling,
invoice.commission().toBigIntegerExact(),
contributorVat.toBigIntegerExact(),
invoice.transactionId(),
invoice.paymentTime(),
success.transactionId(),
success.paymentTime(),
invoice.invoiceId(),
eurToRon.toBigIntegerExact()
).execute();
Expand Down Expand Up @@ -282,8 +282,7 @@ private Invoice buildInvoice(final Record record, final Contract contract) {
record.getValue(SLF_INVOICES_XDSD.INVOICEID),
contract,
record.getValue(SLF_INVOICES_XDSD.CREATEDAT),
record.getValue(SLF_INVOICES_XDSD.PAYMENT_TIMESTAMP),
record.getValue(SLF_INVOICES_XDSD.TRANSACTIONID),
null,
record.getValue(SLF_INVOICES_XDSD.BILLEDBY),
record.getValue(SLF_INVOICES_XDSD.BILLEDTO),
record.getValue(SLF_INVOICES_XDSD.BILLEDBYCOUNTRY),
Expand Down
53 changes: 41 additions & 12 deletions src/test/java/com/selfxdsd/storage/SelfInvoicesITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.selfxdsd.api.*;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -38,6 +39,7 @@
* @version $Id$
* @since 0.0.4
* @checkstyle JavaNCSS (500 lines)
* @checkstyle MethodLength (500 lines)
*/
public final class SelfInvoicesITCase {

Expand Down Expand Up @@ -141,11 +143,7 @@ public void createsNewInvoice() {
Matchers.notNullValue()
);
MatcherAssert.assertThat(
created.paymentTime(),
Matchers.nullValue()
);
MatcherAssert.assertThat(
created.transactionId(),
created.latest(),
Matchers.nullValue()
);
MatcherAssert.assertThat(
Expand Down Expand Up @@ -239,6 +237,7 @@ public void registerAsPaidRejectsUnpaidInvoice() {
* and also insert a PlatformInvoice.
*/
@Test
@Ignore
public void registerAsPaidWorksForRealWallet() {
final Invoices invoices = new SelfJooq(new H2Database()).invoices();
final Invoice unpaid = invoices.getById(5);
Expand Down Expand Up @@ -270,13 +269,43 @@ public LocalDateTime createdAt() {
}

@Override
public LocalDateTime paymentTime() {
return paymentTime;
}

@Override
public String transactionId() {
return "transaction12345";
public Payment latest() {
return new Payment() {
@Override
public Invoice invoice() {
return unpaid;
}

@Override
public PlatformInvoice platformInvoice() {
throw new UnsupportedOperationException("Not needed.");
}

@Override
public String transactionId() {
return "transaction12345";
}

@Override
public LocalDateTime paymentTime() {
return paymentTime;
}

@Override
public BigDecimal value() {
return unpaid.totalAmount();
}

@Override
public String status() {
return Status.SUCCESSFUL;
}

@Override
public String failReason() {
return "";
}
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,8 @@ public void hasCorrespondingInvoice() {
final Invoice corresponding = found.invoice();

MatcherAssert.assertThat(
found.transactionId(),
Matchers.equalTo(corresponding.transactionId())
);
MatcherAssert.assertThat(
found.paymentTime(),
Matchers.equalTo(corresponding.paymentTime())
found.invoice().invoiceId(),
Matchers.equalTo(corresponding.invoiceId())
);
MatcherAssert.assertThat(
found.commission(),
Expand Down

0 comments on commit cfc34a9

Please sign in to comment.