コード例 #1
0
        private static void CAAdj_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var adj = (CAAdj)e.Row;

            if (adj.AdjTranType != CATranType.CATransferExp)
            {
                return;
            }

            CAExpense expense = PXSelect <CAExpense, Where <CAExpense.adjRefNbr, Equal <Required <CAAdj.adjRefNbr> > > > .Select(sender.Graph, adj.AdjRefNbr);

            expense.EntryTypeID  = adj.EntryTypeID;
            expense.DrCr         = adj.DrCr;
            expense.CuryTranAmt  = adj.CuryTranAmt;
            expense.TranAmt      = adj.TranAmt;
            expense.TranDate     = adj.TranDate;
            expense.TranPeriodID = adj.TranPeriodID;
            expense.TranDesc     = adj.TranDesc;
            expense.ExtRefNbr    = adj.ExtRefNbr;

            sender.Graph.Caches[typeof(CAExpense)].Update(expense);

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete &&
                sender.Graph.Accessinfo.ScreenID == CA_30_40_00 &&
                adj.AdjTranType == CATranType.CATransferExp)
            {
                e.Cancel = true;
                throw new PXException(Messages.TransferDocCanNotBeDel);
            }
        }
コード例 #2
0
        protected virtual void CAExpense_CashAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CAExpense   expense     = e.Row as CAExpense;
            CashAccount cashaccount = (CashAccount)PXSelectorAttribute.Select <CAExpense.cashAccountID>(sender, e.Row);

            UpdateCuryInfoExpense(sender, expense);

            if (cashaccount?.Reconcile != true)
            {
                expense.Cleared   = true;
                expense.ClearDate = expense.TranDate;
            }
            else
            {
                expense.Cleared   = false;
                expense.ClearDate = null;
            }

            CurrencyInfo currinfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CAExpense.curyInfoID> >,
                                                                   And <CurrencyInfo.curyID, Equal <Required <CAExpense.curyID> > > > > .Select(this, expense.CuryInfoID, expense.CuryID);

            if (currinfo != null)
            {
                CurrencyInfoAttribute.SetEffectiveDate <CAExpense.tranDate, CAExpense.curyInfoID>(sender, e);
            }
        }
コード例 #3
0
        protected virtual void CAExpense_TranDate_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CAExpense expense = e.Row as CAExpense;

            CurrencyInfo currinfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CAExpense.curyInfoID> >, And <CurrencyInfo.curyID, Equal <Required <CAExpense.curyID> > > > > .Select(this, expense.CuryInfoID, expense.CuryID);

            if (currinfo != null)
            {
                CurrencyInfoAttribute.SetEffectiveDate <CAExpense.tranDate, CAExpense.curyInfoID>(sender, e);
            }
        }
コード例 #4
0
        protected virtual void CAExpense_CashAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CAExpense   expense     = e.Row as CAExpense;
            CashAccount cashaccount = (CashAccount)PXSelectorAttribute.Select <CAExpense.cashAccountID>(sender, e.Row);

            if (cashaccount?.Reconcile != true)
            {
                expense.Cleared   = true;
                expense.ClearDate = expense.TranDate;
            }
            else
            {
                expense.Cleared   = false;
                expense.ClearDate = null;
            }
        }
コード例 #5
0
        private CATransfer ReverseTransfer()
        {
            CATransfer currentTransfer = Transfer.Current;

            IEnumerable <CAExpense> currentExpenses = PXSelect <CAExpense, Where <CAExpense.refNbr, Equal <Required <CAExpense.refNbr> > > >
                                                      .Select(this, currentTransfer.RefNbr)
                                                      .RowCast <CAExpense>();

            var reverseTransfer = (CATransfer)Transfer.Cache.CreateCopy(currentTransfer);

            inFinPeriod.Cache.Current = inFinPeriod.View.SelectSingleBound(new object[] { reverseTransfer });
            FinPeriodUtils.VerifyAndSetFirstOpenedFinPeriod <CATransfer.inPeriodID, CATransfer.inBranchID>(Transfer.Cache, reverseTransfer, inFinPeriod);
            outFinPeriod.Cache.Current = outFinPeriod.View.SelectSingleBound(new object[] { reverseTransfer });
            FinPeriodUtils.VerifyAndSetFirstOpenedFinPeriod <CATransfer.outPeriodID, CATransfer.outBranchID>(Transfer.Cache, reverseTransfer, outFinPeriod);

            Transfer.Cache.Clear();
            Expenses.Cache.Clear();

            SwapInOutFields(currentTransfer, reverseTransfer);
            SetOtherFields(reverseTransfer);

            reverseTransfer = Transfer.Insert(reverseTransfer);

            Expenses.Cache.SetDefaultExt <CATransfer.hold>(reverseTransfer);
            reverseTransfer.InDate = currentTransfer.OutDate;

            reverseTransfer = Transfer.Update(reverseTransfer);

            #region Reverse Expenses
            foreach (CAExpense expense in currentExpenses)
            {
                CAExpense reversedExpense = Expenses.ReverseCharge(expense, true);
                reversedExpense.FinPeriodID  = reverseTransfer.OutPeriodID;
                reversedExpense.TranPeriodID = reverseTransfer.OutTranPeriodID;
                reversedExpense = Expenses.Insert(reversedExpense);

                FinPeriodUtils.CopyPeriods <CAExpense, CAExpense.finPeriodID, CAExpense.tranPeriodID>(Expenses.Cache, expense, reversedExpense);
            }
            #endregion

            RemoveLinkOnAdj();

            FinPeriodUtils.CopyPeriods <CATransfer, CATransfer.inPeriodID, CATransfer.inTranPeriodID>(Transfer.Cache, currentTransfer, reverseTransfer);
            FinPeriodUtils.CopyPeriods <CATransfer, CATransfer.outPeriodID, CATransfer.outTranPeriodID>(Transfer.Cache, currentTransfer, reverseTransfer);

            return(reverseTransfer);
        }
コード例 #6
0
        private static void CASplit_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var split = (CASplit)e.Row;

            if (split.AdjTranType != CATranType.CATransferExp)
            {
                return;
            }

            CAExpense expense = PXSelect <CAExpense, Where <CAExpense.adjRefNbr, Equal <Required <CAAdj.adjRefNbr> > > > .Select(sender.Graph, split.AdjRefNbr);

            expense.AccountID   = split.AccountID;
            expense.SubID       = split.SubID;
            expense.CuryTranAmt = split.CuryTranAmt;

            sender.Graph.Caches[typeof(CAExpense)].Update(expense);
        }
        public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row)
        {
            CAExpense parentDoc = (CAExpense)orig_Row;

            if ((parentDoc.Released == true) && (catran_Row.TranID != null))
            {
                return(null);
            }

            catran_Row.OrigModule   = BatchModule.CA;
            catran_Row.OrigTranType = parentDoc.DocType;
            catran_Row.OrigRefNbr   = parentDoc.RefNbr;

            catran_Row.CashAccountID = parentDoc.CashAccountID;
            catran_Row.ExtRefNbr     = parentDoc.ExtRefNbr;
            catran_Row.CuryID        = parentDoc.CuryID;
            catran_Row.CuryInfoID    = parentDoc.CuryInfoID;
            catran_Row.CuryTranAmt   = parentDoc.CuryTranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.TranAmt       = parentDoc.TranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.DrCr          = parentDoc.DrCr;
            catran_Row.TranDate      = parentDoc.TranDate;
            catran_Row.TranDesc      = parentDoc.TranDesc;
            catran_Row.ReferenceID   = null;
            catran_Row.Released      = parentDoc.Released;
            catran_Row.Hold          = false;
            catran_Row.FinPeriodID   = parentDoc.FinPeriodID;
            catran_Row.TranPeriodID  = parentDoc.TranPeriodID;
            catran_Row.Cleared       = parentDoc.Cleared;
            catran_Row.ClearDate     = parentDoc.ClearDate;

            PXSelectBase <CashAccount> selectStatement = new PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > >(sender.Graph);
            CashAccount cashacc = (CashAccount)selectStatement.View.SelectSingle(catran_Row.CashAccountID);

            if (cashacc != null && cashacc.Reconcile == false && (catran_Row.Cleared != true || catran_Row.TranDate == null))
            {
                catran_Row.Cleared   = true;
                catran_Row.ClearDate = catran_Row.TranDate;
            }

            return(catran_Row);
        }
コード例 #8
0
        private void UpdateCuryInfoExpense(PXCache sender, CAExpense row)
        {
            if (row.CashAccountID == null)
            {
                return;
            }

            CashAccount  cashaccount = (CashAccount)PXSelectorAttribute.Select <CAExpense.cashAccountID>(sender, row);
            CurrencyInfo currinfo    = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CAExpense.curyInfoID> >,
                                                                      And <CurrencyInfo.curyID, Equal <Required <CAExpense.curyID> > > > > .Select(this, row.CuryInfoID, row.CuryID);

            if (currinfo == null)
            {
                return;
            }

            if (currinfo.CuryID != cashaccount.CuryID)
            {
                currinfo.CuryID = cashaccount.CuryID;
                CuryInfo.Update(currinfo);
            }

            if (cashaccount?.CuryRateTypeID != null)
            {
                currinfo.CuryRateTypeID = cashaccount.CuryRateTypeID;
            }
            else
            {
                CMSetup cmsetup = PXSelect <CMSetup> .Select(this);

                if (!string.IsNullOrEmpty(cmsetup?.CARateTypeDflt))
                {
                    currinfo.CuryRateTypeID = cmsetup.CARateTypeDflt;
                }
            }
            CuryInfo.Update(currinfo);

            sender.SetDefaultExt <CAExpense.curyID>(row);
        }