Skip to content

Commit

Permalink
Merge pull request #379 from bullhorn/f/unbilled-revenue-distribution…
Browse files Browse the repository at this point in the history
…-associations

unbilled revenue distribution association and invoice statement property
  • Loading branch information
hubda authored May 16, 2022
2 parents 337fd8f + 269cc01 commit a08d408
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bullhorn</groupId>
<artifactId>sdk-rest</artifactId>
<version>1.4.39</version>
<version>1.4.40</version>
<packaging>jar</packaging>

<name>Bullhorn REST SDK</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.bullhornsdk.data.model.entity.association.paybill.BillingProfileAssociations;
import com.bullhornsdk.data.model.entity.association.paybill.InvoiceTermAssociations;
import com.bullhornsdk.data.model.entity.association.paybill.LocationAssociations;
import com.bullhornsdk.data.model.entity.association.paybill.UnbilledRevenueDistributionAssociations;
import com.bullhornsdk.data.model.entity.association.standard.*;
import com.bullhornsdk.data.model.entity.core.paybill.BillingProfile;
import com.bullhornsdk.data.model.entity.core.paybill.Location;
import com.bullhornsdk.data.model.entity.core.paybill.distribution.UnbilledRevenueDistribution;
import com.bullhornsdk.data.model.entity.core.paybill.invoice.InvoiceTerm;
import com.bullhornsdk.data.model.entity.core.standard.*;
import com.bullhornsdk.data.model.entity.core.type.AssociationEntity;
Expand Down Expand Up @@ -38,6 +40,7 @@ public class AssociationFactory {
private static final BillingProfileAssociations billingProfileAssociations = BillingProfileAssociations.getInstance();
private static final LocationAssociations locationAssociations = LocationAssociations.getInstance();
private static final InvoiceTermAssociations invoiceTermAssociations = InvoiceTermAssociations.getInstance();
private static final UnbilledRevenueDistributionAssociations unbilledRevenueDistributionAssociations = UnbilledRevenueDistributionAssociations.getInstance();

/**
* Returns the AssociationField for the passed in entity type (Candiate, ClientContact etc.), with the association name of the
Expand Down Expand Up @@ -138,6 +141,10 @@ private static <T extends AssociationEntity> EntityAssociations<T> getEntityAsso
return (EntityAssociations<T>) locationAssociations;
}

if (type == UnbilledRevenueDistribution.class) {
return (EntityAssociations<T>) unbilledRevenueDistributionAssociations;
}

return null;

}
Expand Down Expand Up @@ -309,4 +316,13 @@ public static WorkersCompensationAssociations workersCompensationAssociations()
return workersCompensationAssociations;
}

/**
* Returns the associations for UnbilledRevenueDistributionAssociations
*
* @return
*/
public static UnbilledRevenueDistributionAssociations unbilledRevenueDistributionAssociations() {
return unbilledRevenueDistributionAssociations;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.bullhornsdk.data.model.entity.association.paybill;

import com.bullhornsdk.data.model.entity.association.AssociationField;
import com.bullhornsdk.data.model.entity.association.EntityAssociations;
import com.bullhornsdk.data.model.entity.association.standard.StandardAssociationField;
import com.bullhornsdk.data.model.entity.core.paybill.distribution.UnbilledRevenueDistribution;
import com.bullhornsdk.data.model.entity.core.paybill.invoice.InvoiceTerm;
import com.bullhornsdk.data.model.entity.core.paybill.invoice.InvoiceTermVersion;
import com.bullhornsdk.data.model.entity.core.paybill.transaction.BillMasterTransaction;
import com.bullhornsdk.data.model.entity.core.standard.CorporateUser;
import com.bullhornsdk.data.model.entity.core.standard.JobOrder;
import com.bullhornsdk.data.model.entity.core.type.BullhornEntity;

import java.util.ArrayList;
import java.util.List;

/**
* Created by fayranne.lipton 4/10/2020
*/
public class UnbilledRevenueDistributionAssociations implements EntityAssociations<UnbilledRevenueDistribution> {

private final AssociationField<UnbilledRevenueDistribution, BillMasterTransaction> billMasterTransactions = instantiateAssociationField("billMasterTransactions", BillMasterTransaction.class);
private List<AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity>> allAssociations;

private static final UnbilledRevenueDistributionAssociations INSTANCE = new UnbilledRevenueDistributionAssociations();

private UnbilledRevenueDistributionAssociations() {
super();
}

public static UnbilledRevenueDistributionAssociations getInstance() {
return INSTANCE;
}

public AssociationField<UnbilledRevenueDistribution, BillMasterTransaction> billMasterTransactions() {
return billMasterTransactions;
}

private <E extends BullhornEntity> AssociationField<UnbilledRevenueDistribution, E> instantiateAssociationField(String associationName, Class<E> associationType) {
return new StandardAssociationField<UnbilledRevenueDistribution, E>(associationName, associationType);
}

@Override
public List<AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity>> allAssociations() {
if (allAssociations == null) {
allAssociations = new ArrayList<AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity>>();
allAssociations.add(billMasterTransactions());
}
return allAssociations;
}

@Override
public AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity> getAssociation(String associationName) {
for (AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity> associationField : allAssociations()) {
if (associationName.equalsIgnoreCase(associationField.getAssociationFieldName())) {
return associationField;
}
}

throw new IllegalArgumentException("There is no association on entity UnbilledRevenueDistribution called: " + associationName);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dateAdded", "dateLastModified", "debitAmount", "description",
"invoiceStatementLineDistributionTypeLookup", "unbilledRevenueDistributionBatch"
})
public class UnbilledRevenueDistribution extends AbstractEntity implements QueryEntity, UpdateEntity, CreateEntity, DateLastModifiedEntity {
public class UnbilledRevenueDistribution extends AbstractEntity implements QueryEntity, UpdateEntity, CreateEntity, DateLastModifiedEntity, AssociationEntity {

private Integer id;
private String accountingCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"invoiceStatementNumber", "invoiceStatementFinalizedDate", "invoiceStatementOrigin", "invoiceStatementTemplate", "invoiceStatementType", "invoiceTerm",
"isDeleted", "isCredited", "isFinalized", "isReinstated", "lineItems", "lineItemTotal", "owner", "paymentTerms",
"previousBalance", "purchaseOrderNumber", "rawInvoiceStatementNumber", "remitInstructions", "splitBys",
"status", "subtotal", "surcharges", "surchargeTotal", "taxAmount", "taxes", "taxTotal", "total"
"status", "subtotal", "surchargeAmount", "surcharges", "surchargeTotal", "taxAmount", "taxes", "taxTotal", "total"
})
public class InvoiceStatement extends AbstractEntity implements QueryEntity, UpdateEntity, CreateEntity, EditHistoryEntity, DateLastModifiedEntity, SoftDeleteEntity {

Expand Down Expand Up @@ -92,6 +92,7 @@ public class InvoiceStatement extends AbstractEntity implements QueryEntity, Upd
private OneToMany<InvoiceStatementSplitBy> splitBys;
private WorkflowOptionsLookup status;
private BigDecimal subtotal;
private BigDecimal surchargeAmount;
private BigDecimal surchargeTotal;
private OneToMany<InvoiceStatementSurcharge> surcharges;
private BigDecimal taxAmount;
Expand Down Expand Up @@ -551,6 +552,16 @@ public void setSubtotal(BigDecimal subtotal) {
this.subtotal = subtotal;
}

@JsonProperty("surchargeAmount")
public BigDecimal getSurchargeAmount() {
return surchargeAmount;
}

@JsonProperty("surchargeAmount")
public void setSurchargeAmount(BigDecimal surchargeAmount) {
this.surchargeAmount = surchargeAmount;
}

@JsonProperty("surcharges")
public OneToMany<InvoiceStatementSurcharge> getSurcharges() {
return surcharges;
Expand Down Expand Up @@ -662,7 +673,6 @@ public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -717,6 +727,7 @@ public boolean equals(Object o) {
Objects.equals(splitBys, that.splitBys) &&
Objects.equals(status, that.status) &&
Objects.equals(subtotal, that.subtotal) &&
Objects.equals(surchargeAmount, that.surchargeAmount) &&
Objects.equals(surchargeTotal, that.surchargeTotal) &&
Objects.equals(surcharges, that.surcharges) &&
Objects.equals(taxAmount, that.taxAmount) &&
Expand All @@ -727,7 +738,8 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(id, billingAddress, billingAttention, billingClientContact, billingCorporateUser, billingPeriodEndDate, billingProfile, billingScheduleID, clientCorporation, creditedByInvoiceStatement, creditOfInvoiceStatement, currencyUnit, dateAdded, dateLastModified, deliveryMethod, deliveryStatus, discounts, discountTotal, discountAmount, effectiveDate, dueDate, emailErrorReason, finalizedSubtotal, finalizedTotal, generalLedgerExportStatusLookup, invoiceStatementDate, invoiceStatementExports, invoiceStatementExportsBatches, invoiceStatementNumber, invoiceStatementFinalizedDate, invoiceStatementOrigin, invoiceStatementTemplate, invoiceStatementType, invoiceTerm, isDeleted, isCredited, isFinalized, isReinstated, lineItems, lineItemTotal, owner, paymentTerms, previousBalance, purchaseOrderNumber, rawInvoiceStatementNumber, remitInstructions, splitBys, status, subtotal, surchargeTotal, surcharges, taxAmount, taxTotal, taxes, total);

return Objects.hash(id, billingAddress, billingAttention, billingClientContact, billingCorporateUser, billingPeriodEndDate, billingProfile, billingScheduleID, clientCorporation, creditedByInvoiceStatement, creditOfInvoiceStatement, currencyUnit, dateAdded, dateLastModified, deliveryMethod, deliveryStatus, discounts, discountTotal, discountAmount, effectiveDate, dueDate, emailErrorReason, finalizedSubtotal, finalizedTotal, generalLedgerExportStatusLookup, invoiceStatementDate, invoiceStatementExports, invoiceStatementExportsBatches, invoiceStatementNumber, invoiceStatementFinalizedDate, invoiceStatementOrigin, invoiceStatementTemplate, invoiceStatementType, invoiceTerm, isDeleted, isCredited, isFinalized, isReinstated, lineItems, lineItemTotal, owner, paymentTerms, previousBalance, purchaseOrderNumber, rawInvoiceStatementNumber, remitInstructions, splitBys, status, subtotal, surchargeAmount, surchargeTotal, surcharges, taxAmount, taxTotal, taxes, total);
}

@Override
Expand Down Expand Up @@ -782,6 +794,7 @@ public String toString() {
", splitBys=" + splitBys +
", status=" + status +
", subtotal=" + subtotal +
", surchargeAmount=" + surchargeAmount +
", surchargeTotal=" + surchargeTotal +
", surcharges=" + surcharges +
", taxAmount=" + taxAmount +
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/com/bullhornsdk/data/TestEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public class TestEntities {

private Integer federalTaxFormId;

private Integer unbilledRevenueDistributionId;

public TestEntities() {
super();
this.appointmentId = 1;
Expand Down Expand Up @@ -245,6 +247,8 @@ public TestEntities() {

this.federalTaxFormId = 1;

this.unbilledRevenueDistributionId = 1;

}

public Integer getAppointmentId() {
Expand Down Expand Up @@ -711,6 +715,14 @@ public void setFederalTaxFormId(Integer federalTaxFormId) {
this.federalTaxFormId = federalTaxFormId;
}

public Integer getUnbilledRevenueDistributionId() {
return unbilledRevenueDistributionId;
}

public void setUnbilledRevenueDistributionId(Integer unbilledRevenueDistributionId) {
this.unbilledRevenueDistributionId = unbilledRevenueDistributionId;
}

@Override
public String toString() {
return "TestEntities{" +
Expand Down Expand Up @@ -738,6 +750,7 @@ public String toString() {
", housingComplexId=" + housingComplexId +
", jobOrderId=" + jobOrderId +
", jobBoardPostId=" + jobBoardPostId +
", jobShiftId=" + jobShiftId +
", jobSubmissionId=" + jobSubmissionId +
", jobSubmissionHistoryId=" + jobSubmissionHistoryId +
", leadId=" + leadId +
Expand Down Expand Up @@ -771,6 +784,7 @@ public String toString() {
", localTaxFormId=" + localTaxFormId +
", stateTaxFormId=" + stateTaxFormId +
", federalTaxFormId=" + federalTaxFormId +
", unbilledRevenueDistributionId=" + unbilledRevenueDistributionId +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.stream.Collectors;

import com.bullhornsdk.data.model.entity.association.EntityAssociations;
import com.bullhornsdk.data.model.entity.core.paybill.distribution.UnbilledRevenueDistribution;
import com.google.common.collect.Sets;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -144,6 +145,23 @@ public void testAssociateLead() throws IllegalAccessException, InvocationTargetE
}
}

@Test
public void testAssociateUnbilledRevenueDistribution() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
UnbilledRevenueDistribution entity = bullhornData.findEntity(UnbilledRevenueDistribution.class, testEntities.getUnbilledRevenueDistributionId(), getAssociationFieldSet(AssociationFactory.unbilledRevenueDistributionAssociations()));
for (AssociationField<UnbilledRevenueDistribution, ? extends BullhornEntity> association : AssociationFactory.unbilledRevenueDistributionAssociations().allAssociations()) {

Set<Integer> associationIds = new HashSet<Integer>();
OneToMany<? extends BullhornEntity> linkedIds = (OneToMany<? extends BullhornEntity>) PropertyUtils.getProperty(entity,
association.getAssociationFieldName());
if (linkedIds != null && !linkedIds.getData().isEmpty()) {

associationIds.add(linkedIds.getData().get(0).getId());
testAssociation(UnbilledRevenueDistribution.class, testEntities.getUnbilledRevenueDistributionId(), associationIds, association);

}
}
}

@Test
public void testAssociateNote() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Note entity = bullhornData.findEntity(Note.class, testEntities.getNoteId(), getAssociationFieldSet(AssociationFactory.noteAssociations()));
Expand Down

0 comments on commit a08d408

Please sign in to comment.