use of de.metas.money.CurrencyId in project metasfresh-webui-api by metasfresh.
the class BankStatementLineAndPaymentsToReconcileRepository method toPaymentToReconcileRow.
private PaymentToReconcileRow toPaymentToReconcileRow(@NonNull final I_C_Payment record, @NonNull final ImmutableSetMultimap<PaymentId, String> invoiceDocumentNosByPaymentId) {
final CurrencyId currencyId = CurrencyId.ofRepoId(record.getC_Currency_ID());
final CurrencyCode currencyCode = currencyRepository.getCurrencyCodeById(currencyId);
final Amount payAmt = Amount.of(record.getPayAmt(), currencyCode);
final PaymentId paymentId = PaymentId.ofRepoId(record.getC_Payment_ID());
String invoiceDocumentNos = joinInvoiceDocumentNos(invoiceDocumentNosByPaymentId.get(paymentId));
return PaymentToReconcileRow.builder().paymentId(paymentId).inboundPayment(record.isReceipt()).documentNo(record.getDocumentNo()).dateTrx(TimeUtil.asLocalDate(record.getDateTrx())).bpartner(bpartnerLookup.findById(record.getC_BPartner_ID())).invoiceDocumentNos(invoiceDocumentNos).payAmt(payAmt).reconciled(record.isReconciled()).build();
}
use of de.metas.money.CurrencyId in project metasfresh-webui-api by metasfresh.
the class PaymentAndInvoiceRowsRepo method prepareInvoiceToAllocateQuery.
private InvoiceToAllocateQueryBuilder prepareInvoiceToAllocateQuery(final PaymentToAllocate paymentToAllocate) {
final CurrencyCode currencyCode = paymentToAllocate.getOpenAmt().getCurrencyCode();
final CurrencyId currencyId = currenciesRepo.getCurrencyIdByCurrencyCode(currencyCode);
return InvoiceToAllocateQuery.builder().bpartnerId(paymentToAllocate.getBpartnerId()).currencyId(currencyId).clientAndOrgId(paymentToAllocate.getClientAndOrgId());
}
use of de.metas.money.CurrencyId in project metasfresh-webui-api by metasfresh.
the class PurchaseRowsLoaderTest method createPurchaseCandidate.
private static PurchaseCandidate createPurchaseCandidate(final I_C_OrderLine orderLine, final VendorProductInfo vendorProductInfo) {
final CurrencyId currencyId = CurrencyId.ofRepoId(orderLine.getC_Currency_ID());
final PurchaseProfitInfo profitInfo = PurchaseRowTestTools.createProfitInfo(currencyId);
final ProductId productId = ProductId.ofRepoId(orderLine.getM_Product_ID());
final I_C_UOM productStockingUOM = Services.get(IProductBL.class).getStockUOM(productId);
final PurchaseCandidate purchaseCandidate = PurchaseCandidate.builder().groupReference(DemandGroupReference.EMPTY).orgId(OrgId.ofRepoId(20)).purchaseDatePromised(TimeUtil.asZonedDateTime(orderLine.getDatePromised())).productId(productId).attributeSetInstanceId(AttributeSetInstanceId.ofRepoId(orderLine.getM_AttributeSetInstance_ID())).qtyToPurchase(Quantity.of(orderLine.getQtyOrdered(), productStockingUOM)).salesOrderAndLineIdOrNull(OrderAndLineId.ofRepoIds(orderLine.getC_Order_ID(), orderLine.getC_OrderLine_ID())).vendorId(vendorProductInfo.getVendorId()).vendorProductNo(vendorProductInfo.getVendorProductNo()).aggregatePOs(vendorProductInfo.isAggregatePOs()).warehouseId(WarehouseId.ofRepoId(30)).profitInfoOrNull(profitInfo).build();
return purchaseCandidate;
}
use of de.metas.money.CurrencyId in project metasfresh-webui-api by metasfresh.
the class BankStatementLineAndPaymentsToReconcileRepository method extractStatementLineAmt.
private Amount extractStatementLineAmt(final I_C_BankStatementLine record) {
final CurrencyId currencyId = CurrencyId.ofRepoId(record.getC_Currency_ID());
final CurrencyCode currencyCode = currencyRepository.getCurrencyCodeById(currencyId);
final Amount statementLineAmt = Amount.of(record.getStmtAmt(), currencyCode);
return statementLineAmt;
}
use of de.metas.money.CurrencyId in project metasfresh-webui-api by metasfresh.
the class BoardDescriptorRepository method createBoardCardFieldDescriptor.
private final BoardCardFieldDescriptor createBoardCardFieldDescriptor(final I_WEBUI_Board_CardField cardFieldPO, final DocumentEntityDescriptor documentEntityDescriptor) {
// TODO: might be not so performant, we just need the ColumnName
final String fieldName = cardFieldPO.getAD_Column().getColumnName();
final DocumentFieldDescriptor documentField = documentEntityDescriptor.getField(fieldName);
final SqlDocumentFieldDataBindingDescriptor fieldBinding = documentField.getDataBindingNotNull(SqlDocumentFieldDataBindingDescriptor.class);
final DocumentFieldWidgetType widgetType = documentField.getWidgetType();
final boolean isDisplayColumnAvailable = fieldBinding.getSqlSelectDisplayValue() != null;
final ImmutableSet<String> sqlSelectValues;
final BoardFieldLoader fieldLoader;
if (widgetType == DocumentFieldWidgetType.Amount && documentEntityDescriptor.hasField(WindowConstants.FIELDNAME_C_Currency_ID)) {
sqlSelectValues = ImmutableSet.of(fieldBinding.getSqlSelectValue().toSqlStringWithColumnNameAlias(), WindowConstants.FIELDNAME_C_Currency_ID);
fieldLoader = (rs, adLanguage) -> {
final BigDecimal valueBD = rs.getBigDecimal(fieldBinding.getColumnName());
if (valueBD == null) {
return null;
}
final CurrencyId currencyId = CurrencyId.ofRepoIdOrNull(rs.getInt(WindowConstants.FIELDNAME_C_Currency_ID));
if (currencyId == null) {
return valueBD;
}
final CurrencyCode currencyCode = currenciesRepo.getCurrencyCodeById(currencyId);
return Amount.of(valueBD, currencyCode);
};
} else {
sqlSelectValues = ImmutableSet.of(fieldBinding.getSqlSelectValue().toSqlStringWithColumnNameAlias());
final DocumentFieldValueLoader documentFieldValueLoader = fieldBinding.getDocumentFieldValueLoader();
final LookupDescriptor lookupDescriptor = documentField.getLookupDescriptor().orElse(null);
fieldLoader = (rs, adLanguage) -> documentFieldValueLoader.retrieveFieldValue(rs, isDisplayColumnAvailable, adLanguage, lookupDescriptor);
}
return BoardCardFieldDescriptor.builder().caption(documentField.getCaption()).fieldName(fieldBinding.getColumnName()).widgetType(widgetType).sqlSelectValues(sqlSelectValues).usingDisplayColumn(isDisplayColumnAvailable).sqlSelectDisplayValue(fieldBinding.getSqlSelectDisplayValue()).sqlOrderBy(fieldBinding.getSqlOrderBy()).fieldLoader(fieldLoader).build();
}
Aggregations