Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Jul 1, 2020
1 parent ee6f14b commit 985645d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@Value
@Builder
public class InvoiceProcessingFeeFromPaymentRequest
public class InvoiceProcessingFeeWithPrecalculatedAmountRequest
{
@NonNull
OrgId orgId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.List;
import java.util.Optional;

// TODO tbp: add unit test to see that getting stuff (and entering duplicates work)
/* package */ class InvoiceProcessingServiceCompanyConfigMap
{
private final ImmutableListMultimap<BPartnerId, InvoiceProcessingServiceCompanyConfig> bpartnersToConfigsSorted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public InvoiceProcessingServiceCompanyService(
this.moneyService = moneyService;
}

public Optional<InvoiceProcessingFeeCalculation> createFeeCalculationForPayment(@NonNull final InvoiceProcessingFeeFromPaymentRequest request)
public Optional<InvoiceProcessingFeeCalculation> createFeeCalculationForPayment(@NonNull final InvoiceProcessingFeeWithPrecalculatedAmountRequest request)
{
final BPartnerId serviceCompanyBPartnerId = request.getServiceCompanyBPartnerId();
final InvoiceId invoiceId = request.getInvoiceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ public void standardCase()
.evaluationDate(LocalDate.parse("2020-04-30").atStartOfDay(ZoneId.of("UTC-8")))
.customerId(BPartnerId.ofRepoId(2))
.invoiceId(InvoiceId.ofRepoId(3))
// .invoiceGrandTotal(Amount.of(100, CurrencyCode.EUR))
//
.serviceCompanyBPartnerId(serviceCompanyBPartnerAndLocationId.getBpartnerId())
.serviceInvoiceDocTypeId(serviceInvoiceDocTypeId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public PaymentAndInvoiceRowsRepo(

public PaymentAndInvoiceRows getByBPartnerId(@NonNull final BPartnerId bPartnerId)
{
final ZonedDateTime evaluationDate = SystemTime.asZonedDateTime(); // todo. somehow we should pass Payment date here. I don't think that's possible. Have to talk to mark.
final ZonedDateTime evaluationDate = SystemTime.asZonedDateTime();

final List<PaymentToAllocate> paymentsToAllocate = paymentAllocationRepo.retrievePaymentsToAllocate(PaymentToAllocateQuery.builder()
.bpartnerId(bPartnerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import de.metas.currency.Amount;
import de.metas.currency.CurrencyCode;
import de.metas.invoice.invoiceProcessingServiceCompany.InvoiceProcessingFeeCalculation;
import de.metas.invoice.invoiceProcessingServiceCompany.InvoiceProcessingFeeFromPaymentRequest;
import de.metas.invoice.invoiceProcessingServiceCompany.InvoiceProcessingFeeWithPrecalculatedAmountRequest;
import de.metas.invoice.invoiceProcessingServiceCompany.InvoiceProcessingServiceCompanyService;
import de.metas.lang.SOTrx;
import de.metas.money.CurrencyId;
Expand Down Expand Up @@ -171,7 +171,7 @@ static PayableDocument toPayableDocument(
final ZonedDateTime paymentDate = TimeUtil.asZonedDateTime(singlePaymentDocument.getDateTrx());

final Optional<InvoiceProcessingFeeCalculation> calculatedFeeOptional = invoiceProcessingServiceCompanyService.createFeeCalculationForPayment(
InvoiceProcessingFeeFromPaymentRequest.builder()
InvoiceProcessingFeeWithPrecalculatedAmountRequest.builder()
.orgId(row.getOrgId())
.paymentDate(paymentDate)
.customerId(row.getBPartnerId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void assertInvoiceAllocatedAmt(final InvoiceId invoiceId, final String e
private PaymentRow createPaymentRow(
@NonNull final PaymentDirection direction,
@NonNull final Amount payAmt,
@Nullable final BPartnerId bpId,
@Nullable final BPartnerId bpartnerIdOverride,
@Nullable final LocalDate paymentDateTrxOverride)
{
final I_C_Payment paymentRecord = newInstance(I_C_Payment.class);
Expand All @@ -172,7 +172,7 @@ private PaymentRow createPaymentRow(
.clientAndOrgId(ClientAndOrgId.ofClientAndOrg(ClientId.METASFRESH, orgId))
.documentNo("paymentNo_" + paymentId.getRepoId())
.dateTrx(CoalesceUtil.coalesce(paymentDateTrxOverride, paymentDateTrx))
.bpartner(IntegerLookupValue.of(CoalesceUtil.coalesce(bpId, bpartnerId).getRepoId(), "BPartner"))
.bpartner(IntegerLookupValue.of(CoalesceUtil.coalesce(bpartnerIdOverride, bpartnerId).getRepoId(), "BPartner"))
.payAmt(payAmt)
.openAmt(payAmt)
.paymentDirection(direction)
Expand Down Expand Up @@ -322,7 +322,7 @@ public void paymentDateInValidFrom()
final LocalDate paymentDate = LocalDate.of(2020, Month.FEBRUARY, 11);

final InvoiceRow invoiceRow = invoiceRow().docBaseType(InvoiceDocBaseType.CustomerInvoice).openAmt(euro(100)).serviceFeeAmt("10").build();
final PaymentRow paymentRow = paymentRow().direction(PaymentDirection.INBOUND).payAmt(euro(100)).bpId(feeCompanyBPid2).paymentDateTrxOverride(paymentDate).build();
final PaymentRow paymentRow = paymentRow().direction(PaymentDirection.INBOUND).payAmt(euro(100)).bpartnerIdOverride(feeCompanyBPid2).paymentDateTrxOverride(paymentDate).build();

final List<PaymentDocument> paymentDocuments = Collections.singletonList(PaymentsViewAllocateCommand.toPaymentDocument(paymentRow, moneyService));

Expand All @@ -344,7 +344,7 @@ public void paymentDateBeforeValidFrom()
final LocalDate paymentDate = LocalDate.of(1999, Month.JANUARY, 1);

final InvoiceRow invoiceRow = invoiceRow().docBaseType(InvoiceDocBaseType.CustomerInvoice).openAmt(euro(100)).serviceFeeAmt("10").build();
final PaymentRow paymentRow = paymentRow().direction(PaymentDirection.INBOUND).payAmt(euro(100)).bpId(feeCompanyBPid1).paymentDateTrxOverride(paymentDate).build();
final PaymentRow paymentRow = paymentRow().direction(PaymentDirection.INBOUND).payAmt(euro(100)).bpartnerIdOverride(feeCompanyBPid1).paymentDateTrxOverride(paymentDate).build();

final List<PaymentDocument> paymentDocuments = Collections.singletonList(PaymentsViewAllocateCommand.toPaymentDocument(paymentRow, moneyService));

Expand Down

0 comments on commit 985645d

Please sign in to comment.