public virtual void SetCardCurrencyData(PXCache cache, EPExpenseClaimDetails document, int?corpCardID)
        {
            if (corpCardID != null)
            {
                CashAccount cashAccount = CACorpCardsMaint.GetCardCashAccount(Base, corpCardID);

                cache.SetValueExt <EPExpenseClaimDetails.cardCuryID>(document, cashAccount.CuryID);
            }
            else
            {
                DefaultCardCurrencyInfo(cache, document);
            }
        }
        public virtual void VerifyClaimAndCorpCardCurrencies(int?corpCardID, EPExpenseClaim claim, Action substituteNewValue = null)
        {
            if (corpCardID != null && claim != null)
            {
                CashAccount cashAccount = CACorpCardsMaint.GetCardCashAccount(Base, corpCardID);

                if (cashAccount.CuryID != claim.CuryID)
                {
                    substituteNewValue?.Invoke();

                    throw new PXSetPropertyException(Messages.CardCurrencyAndTheClaimCurrencyMustBeEqual);
                }
            }
        }
示例#3
0
        public static string GetClaimCuryID(PXGraph graph, EPExpenseClaimDetails receipt)
        {
            if (receipt.CorpCardID != null)
            {
                return(CACorpCardsMaint.GetCardCashAccount(graph, receipt.CorpCardID).CuryID);
            }
            else
            {
                EPEmployee employee =
                    PXSelect <EPEmployee,
                              Where <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > >
                    .Select(graph, receipt.EmployeeID);

                return(employee.CuryID ?? ((Company)PXSelect <Company> .Select(graph)).BaseCuryID);
            }
        }
        public virtual void _(Events.FieldDefaulting <EPExpenseClaimDetails.corpCardID> e)
        {
            if (e.Row is EPExpenseClaimDetails row)
            {
                if (row.EmployeeID != null)
                {
                    if (row.PaidWith != EPExpenseClaimDetails.paidWith.PersonalAccount)
                    {
                        var firstCreditCard = GetFirstCreditCardForEmployeeAlphabeticallySorted(row.EmployeeID.Value);
                        var thereIsCreditCardForEmployee = firstCreditCard != null;
                        if (thereIsCreditCardForEmployee)
                        {
                            var lastUsedCreditCard = GetLastUsedCreditCardForEmployee(row.EmployeeID.Value);

                            var corpCardId = lastUsedCreditCard != null
                                                                ? lastUsedCreditCard.CorpCardID
                                                                : firstCreditCard.CorpCardID;

                            if (row.RefNbr != null)
                            {
                                EPExpenseClaim claim = PXParentAttribute.SelectParent <EPExpenseClaim>(e.Cache, row);

                                CashAccount cashAccount = CACorpCardsMaint.GetCardCashAccount(Base, corpCardId);

                                if (cashAccount.CuryID != claim.CuryID)
                                {
                                    corpCardId = null;
                                }
                            }

                            e.Cache.SetValueExt <EPExpenseClaimDetails.corpCardID>(row, corpCardId);
                        }
                    }
                }
            }
        }