Skip to content

Commit

Permalink
#286 InvoicedTasks: added contributorCommission DB column
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Apr 13, 2021
1 parent e38dfe3 commit 3f834ea
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 29 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/selfxdsd/storage/SelfInvoicedTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id$
* @since 0.0.4
* @todo #280:60min Implement the DB Column contributorsCommission and rename
* the existing commission to projectCommission in the InvoicedTasks table.
*/
public final class SelfInvoicedTasks implements InvoicedTasks {

Expand Down Expand Up @@ -139,6 +137,7 @@ public InvoicedTask register(
SLF_INVOICEDTASKS_XDSD.INVOICED,
SLF_INVOICEDTASKS_XDSD.ESTIMATION_MINUTES,
SLF_INVOICEDTASKS_XDSD.COMMISSION,
SLF_INVOICEDTASKS_XDSD.CONTRIBUTORCOMMISSION,
SLF_INVOICEDTASKS_XDSD.ISPULLREQUEST
).values(
invoice.invoiceId(),
Expand All @@ -153,6 +152,7 @@ public InvoicedTask register(
LocalDateTime.now(),
finished.estimation(),
projectCommission.toBigIntegerExact(),
contributorCommission.toBigIntegerExact(),
finished.isPullRequest()
).returningResult(
SLF_INVOICEDTASKS_XDSD.ID,
Expand Down Expand Up @@ -200,7 +200,10 @@ private InvoicedTask invoicedTaskFromRecord(
BigDecimal.valueOf(
rec.getValue(SLF_INVOICEDTASKS_XDSD.COMMISSION).longValue()
),
null,
BigDecimal.valueOf(
rec.getValue(SLF_INVOICEDTASKS_XDSD.CONTRIBUTORCOMMISSION)
.longValue()
),
new StoredTask(
invoice.contract(),
rec.getValue(SLF_INVOICEDTASKS_XDSD.ISSUEID),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/selfxdsd/storage/SelfPms.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public ProjectManager register(
SLF_PMS_XDSD.PROVIDER,
SLF_PMS_XDSD.ACCESS_TOKEN,
SLF_PMS_XDSD.COMMISSION.cast(Double.class).as("commission"),
SLF_PMS_XDSD.COMMISSION.cast(Double.class)
SLF_PMS_XDSD.CONTRIBUTORCOMMISSION.cast(Double.class)
.as("contributorCommission")
)
.values(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void registersTask() {
toInvoice.contract().invoices().active(),
toInvoice,
BigDecimal.valueOf(100),
null
BigDecimal.valueOf(30)
);

MatcherAssert.assertThat(invoiced.task(), Matchers.is(toInvoice));
Expand All @@ -141,6 +141,10 @@ public void registersTask() {
invoiced.projectCommission(),
Matchers.equalTo(BigDecimal.valueOf(100))
);
MatcherAssert.assertThat(
invoiced.contributorCommission(),
Matchers.equalTo(BigDecimal.valueOf(30))
);
MatcherAssert.assertThat(
invoiced.totalAmount(),
Matchers.equalTo(BigDecimal.valueOf(15100))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void getByIdReturnsFound() {
);
MatcherAssert.assertThat(
found.commission(),
Matchers.equalTo(BigDecimal.valueOf(100))
Matchers.equalTo(BigDecimal.valueOf(130))
);
MatcherAssert.assertThat(
found.vat(),
Expand Down Expand Up @@ -132,7 +132,7 @@ public void getByPaymentReturnsFound() {
);
MatcherAssert.assertThat(
found.commission(),
Matchers.equalTo(BigDecimal.valueOf(100))
Matchers.equalTo(BigDecimal.valueOf(130))
);
MatcherAssert.assertThat(
found.vat(),
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/createDb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ CREATE TABLE `self_xdsd`.`slf_invoicedtasks_xdsd` (
`role` VARCHAR(32) NOT NULL,
`value` DECIMAL(20,0) NOT NULL,
`commission` DECIMAL(20,0) NOT NULL,
`contributorCommission` DECIMAL(20,0) NOT NULL,
`issueId` VARCHAR(50) NOT NULL,
`assigned` DATETIME NOT NULL,
`deadline` DATETIME NOT NULL,
Expand Down
16 changes: 10 additions & 6 deletions src/test/resources/insertTestData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ INSERT INTO `self_xdsd`.`slf_invoicedtasks_xdsd`
role,
value,
commission,
contributorCommission,
issueId,
assigned,
deadline,
Expand All @@ -261,6 +262,7 @@ VALUES
'DEV',
15000,
50,
30,
'200',
'2020-06-01',
'2020-06-11',
Expand All @@ -276,6 +278,7 @@ INSERT INTO `self_xdsd`.`slf_invoicedtasks_xdsd`
role,
value,
commission,
contributorCommission,
issueId,
assigned,
deadline,
Expand All @@ -290,6 +293,7 @@ VALUES
'REV',
8000,
50,
30,
'201',
'2020-06-01',
'2020-06-11',
Expand All @@ -299,14 +303,14 @@ VALUES
);

INSERT INTO `self_xdsd`.`slf_invoicedtasks_xdsd`
(invoiceId, repo_fullname, username, provider, role, value, commission, issueId, assigned, deadline, invoiced, estimation_minutes, isPullRequest)
(invoiceId, repo_fullname, username, provider, role, value, commission, contributorCommission, issueId, assigned, deadline, invoiced, estimation_minutes, isPullRequest)
VALUES
(3, 'vlad/test', 'maria', 'github', 'PO', 10000, 50, '100', '2020-06-01', '2020-06-11', NOW(), 60, 0);
(3, 'vlad/test', 'maria', 'github', 'PO', 10000, 50, 30, '100', '2020-06-01', '2020-06-11', NOW(), 60, 0);

INSERT INTO `self_xdsd`.`slf_invoicedtasks_xdsd`
(invoiceId, repo_fullname, username, provider, role, value, commission, issueId, assigned, deadline, invoiced, estimation_minutes, isPullRequest)
(invoiceId, repo_fullname, username, provider, role, value, commission, contributorCommission, issueId, assigned, deadline, invoiced, estimation_minutes, isPullRequest)
VALUES
(4, 'vlad/test', 'alexandra', 'github', 'DEV', 10000, 100, '899', '2020-06-01', '2020-06-11', NOW(), 60, 0);
(4, 'vlad/test', 'alexandra', 'github', 'DEV', 10000, 100, 30, '899', '2020-06-01', '2020-06-11', NOW(), 60, 0);


INSERT INTO `self_xdsd`.`slf_wallets_xdsd`
Expand Down Expand Up @@ -376,8 +380,8 @@ VALUES ('maria', 'github', 'stripe', 'acct_001');

INSERT INTO `self_xdsd`.`slf_platforminvoices_xdsd`
(`id`, `createdAt`, `billedTo`, `commission`, `vat`, `transactionId`, `payment_timestamp`, `eurToRon`)
VALUES (1, '2021-01-09', 'mihai', 100, 19, 'transaction123', '2021-01-09', 487);
VALUES (1, '2021-01-09', 'mihai', 130, 19, 'transaction123', '2021-01-09', 487);

INSERT INTO `self_xdsd`.`slf_platforminvoices_xdsd`
(`id`, `createdAt`, `billedTo`, `commission`, `vat`, `transactionId`, `payment_timestamp`, `invoiceId`, `eurToRon`)
VALUES (2, '2021-01-09', 'vlad', 100, 19, 'transactionIdHere', '2021-01-09', 4, 487);
VALUES (2, '2021-01-09', 'vlad', 130, 19, 'transactionIdHere', '2021-01-09', 4, 487);

1 comment on commit 3f834ea

@zoeself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil I've closed the Issues [#286] since their to-dos disappeared from the code.

The to-dos may have been removed in an earlier commit, but I've found it just now.

Please sign in to comment.