Search in sources :

Example 1 with CurrencyId

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();
}
Also used : CurrencyCode(de.metas.currency.CurrencyCode) Amount(de.metas.currency.Amount) PaymentId(de.metas.payment.PaymentId) CurrencyId(de.metas.money.CurrencyId)

Example 2 with CurrencyId

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());
}
Also used : CurrencyCode(de.metas.currency.CurrencyCode) CurrencyId(de.metas.money.CurrencyId)

Example 3 with CurrencyId

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;
}
Also used : IProductBL(de.metas.product.IProductBL) ProductId(de.metas.product.ProductId) PurchaseCandidate(de.metas.purchasecandidate.PurchaseCandidate) CurrencyId(de.metas.money.CurrencyId) I_C_UOM(org.compiere.model.I_C_UOM) PurchaseProfitInfo(de.metas.purchasecandidate.grossprofit.PurchaseProfitInfo)

Example 4 with CurrencyId

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;
}
Also used : CurrencyCode(de.metas.currency.CurrencyCode) Amount(de.metas.currency.Amount) CurrencyId(de.metas.money.CurrencyId)

Example 5 with CurrencyId

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();
}
Also used : CurrencyCode(de.metas.currency.CurrencyCode) SqlDocumentFieldDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) BoardFieldLoader(de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) DocumentFieldValueLoader(de.metas.ui.web.window.descriptor.sql.DocumentFieldValueLoader) ToString(lombok.ToString) ITranslatableString(de.metas.i18n.ITranslatableString) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) BigDecimal(java.math.BigDecimal) CurrencyId(de.metas.money.CurrencyId)

Aggregations

CurrencyId (de.metas.money.CurrencyId)9 CurrencyCode (de.metas.currency.CurrencyCode)4 BigDecimal (java.math.BigDecimal)3 Amount (de.metas.currency.Amount)2 ITranslatableString (de.metas.i18n.ITranslatableString)1 Money (de.metas.money.Money)1 PaymentId (de.metas.payment.PaymentId)1 PricingSystemId (de.metas.pricing.PricingSystemId)1 PriceSpecificationType (de.metas.pricing.conditions.PriceSpecificationType)1 PricingConditionsBreak (de.metas.pricing.conditions.PricingConditionsBreak)1 IProductBL (de.metas.product.IProductBL)1 ProductId (de.metas.product.ProductId)1 PurchaseCandidate (de.metas.purchasecandidate.PurchaseCandidate)1 PurchaseProfitInfo (de.metas.purchasecandidate.grossprofit.PurchaseProfitInfo)1 BoardFieldLoader (de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader)1 PartialPriceChangeBuilder (de.metas.ui.web.order.pricingconditions.view.PricingConditionsRowChangeRequest.PartialPriceChange.PartialPriceChangeBuilder)1 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)1 JSONDocumentChangedEvent (de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent)1 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)1 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)1