public virtual void ClearFieldsIfNeeded(PXCache cache, EPExpenseClaimDetails row)
        {
            var corpCardIsEnabled = row.PaidWith != EPExpenseClaimDetails.paidWith.PersonalAccount;

            if (!corpCardIsEnabled)
            {
                cache.SetValueExt <EPExpenseClaimDetails.corpCardID>(row, null);
            }

            var taxIsEnabled = row.PaidWith != EPExpenseClaimDetails.paidWith.CardPersonalExpense;

            if (!taxIsEnabled)
            {
                cache.SetValueExt <EPExpenseClaimDetails.taxZoneID>(row, null);
                cache.SetValueExt <EPExpenseClaimDetails.taxCategoryID>(row, null);
            }

            if (row.PaidWith == EPExpenseClaimDetails.paidWith.CardPersonalExpense)
            {
                PMProject prj = PXSelect <PMProject, Where <PMProject.nonProject, Equal <True> > > .SelectSingleBound(Base, null, null);

                cache.SetValueExt <EPExpenseClaimDetails.contractID>(row, prj.ContractCD);
                cache.SetValueExt <EPExpenseClaimDetails.taskID>(row, null);
                cache.SetValueExt <EPExpenseClaimDetails.costCodeID>(row, null);
                cache.SetValueExt <EPExpenseClaimDetails.curyTipAmt>(row, 0);
            }
        }
        public virtual void VerifyEmployeeAndClaimCurrenciesForCash(
            EPExpenseClaimDetails receipt,
            string receiptPaidWith,
            EPExpenseClaim claim,
            Action substituteNewValue = null)
        {
            if (claim == null)
            {
                return;
            }

            if (receiptPaidWith == EPExpenseClaimDetails.paidWith.PersonalAccount)
            {
                EPEmployee employee =
                    PXSelect <EPEmployee,
                              Where <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > >
                    .Select(Base, receipt.EmployeeID);

                if (employee.AllowOverrideCury != true && employee.CuryID != null && employee.CuryID != claim.CuryID)
                {
                    substituteNewValue?.Invoke();

                    throw new PXSetPropertyException(Messages.ReceiptCannotBeAddedToClaimBecauseClaimCuryDiffersFromEmployeeCury);
                }
            }
        }
Beispiel #3
0
 public static void RemoveReceipt(PXCache cache, EPExpenseClaimDetails receipt)
 {
     receipt        = cache.CreateCopy(receipt) as EPExpenseClaimDetails;
     receipt.RefNbr = null;
     RefNbrUpdated(cache, null, receipt);
     cache.Update(receipt);
 }
Beispiel #4
0
        protected virtual IEnumerable customers()
        {
            BillingFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }
            bool found = false;

            foreach (CustomersList item in Customers.Cache.Inserted)
            {
                found = true;
                yield return(item);
            }
            if (found)
            {
                yield break;
            }

            PXSelectBase <EPExpenseClaimDetails> sel = new PXSelectJoinGroupBy <EPExpenseClaimDetails, InnerJoin <Customer, On <EPExpenseClaimDetails.customerID, Equal <Customer.bAccountID> >,
                                                                                                                  LeftJoin <Contract, On <EPExpenseClaimDetails.contractID, Equal <Contract.contractID> > > >,
                                                                                Where <EPExpenseClaimDetails.released, Equal <boolTrue>,
                                                                                       And <EPExpenseClaimDetails.billable, Equal <boolTrue>,
                                                                                            And <EPExpenseClaimDetails.billed, Equal <boolFalse>,
                                                                                                 And <EPExpenseClaimDetails.expenseDate, LessEqual <Current <BillingFilter.endDate> > > > > >,
                                                                                Aggregate <GroupBy <EPExpenseClaimDetails.customerID,
                                                                                                    GroupBy <EPExpenseClaimDetails.customerLocationID> > > >(this);

            if (filter.CustomerClassID != null)
            {
                sel.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >();
            }
            if (filter.CustomerID != null)
            {
                sel.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >();
            }

            foreach (PXResult <EPExpenseClaimDetails, Customer, Contract> res in sel.Select())
            {
                CustomersList         retitem      = new CustomersList();
                Customer              customer     = res;
                EPExpenseClaimDetails claimdetaisl = res;
                Contract              contract     = (Contract)res;

                if (contract.BaseType == PMProject.ProjectBaseType.Project)
                {
                    continue;
                }


                retitem.CustomerID      = customer.BAccountID;
                retitem.LocationID      = claimdetaisl.CustomerLocationID;
                retitem.CustomerClassID = customer.CustomerClassID;

                retitem.Selected = false;

                yield return(Customers.Insert(retitem));
            }
        }
 public virtual void SetClaimCuryWhenNotInClaim(EPExpenseClaimDetails document, string claimRefNbr, int?corpCardID)
 {
     if (claimRefNbr == null)
     {
         document.ClaimCuryInfoID = corpCardID != null ? document.CardCuryInfoID : null;
     }
 }
Beispiel #6
0
        protected virtual void InsertARTran(ARInvoiceEntry arGraph, EPExpenseClaimDetails row, bool copyNotes, bool copyFiles)
        {
            ARTran tran = (ARTran)arGraph.Transactions.Cache.CreateInstance();

            tran.InventoryID = row.InventoryID;
            tran.TranDesc    = row.TranDesc;
            tran.TranCost    = row.ExtCost;
            tran.Qty         = row.Qty;
            tran.UOM         = row.UOM;
            tran.CuryTranAmt = row.CuryTranAmt;
            tran.AccountID   = row.SalesAccountID;
            tran.SubID       = row.SalesSubID;
            tran.Date        = row.ExpenseDate;
            tran             = arGraph.Transactions.Insert(tran);

            if (copyNotes)
            {
                string note = PXNoteAttribute.GetNote(Caches[typeof(EPExpenseClaimDetails)], row);
                if (note != null)
                {
                    PXNoteAttribute.SetNote(arGraph.Transactions.Cache, tran, note);
                }
            }
            if (copyFiles)
            {
                Guid[] files = PXNoteAttribute.GetFileNotes(Caches[typeof(EPExpenseClaimDetails)], row);
                if (files != null && files.Length > 0)
                {
                    PXNoteAttribute.SetFileNotes(arGraph.Transactions.Cache, tran, files);
                }
            }
        }
Beispiel #7
0
        protected virtual void InsertARTran(ARInvoiceEntry arGraph, EPExpenseClaimDetails row, decimal signOperation)
        {
            CurrencyInfo curyInfo = PXSelect <CurrencyInfo> .Search <CurrencyInfo.curyInfoID>(arGraph, row.CuryInfoID);

            decimal curyamount;

            if (arGraph.currencyinfo.Current != null && curyInfo != null && arGraph.currencyinfo.Current.CuryID == curyInfo.CuryID)
            {
                curyamount = row.CuryTranAmt.GetValueOrDefault(0);
            }
            else
            {
                CM.PXCurrencyAttribute.CuryConvCury(arGraph.Document.Cache, arGraph.currencyinfo, row.TranAmt.GetValueOrDefault(), out curyamount);
            }

            ARTran tran = arGraph.Transactions.Insert();

            tran.InventoryID   = row.InventoryID;
            tran.TranDesc      = row.TranDesc;
            tran.Qty           = row.Qty * signOperation;
            tran.UOM           = row.UOM;
            tran.AccountID     = row.SalesAccountID;
            tran.SubID         = row.SalesSubID;
            tran.Date          = row.ExpenseDate;
            tran.CuryTranAmt   = curyamount * signOperation;
            tran.CuryUnitPrice = (curyamount / (row.Qty.GetValueOrDefault(1m) != 0m ? row.Qty.GetValueOrDefault(1m) : 1m)) * signOperation;
            tran.CuryExtPrice  = curyamount * signOperation;
            tran = arGraph.Transactions.Update(tran);

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], row, arGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.ar>());
        }
Beispiel #8
0
        protected virtual void EPExpenseClaimDetails_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            EPExpenseClaimDetails line = (EPExpenseClaimDetails)e.Row;

            if (EPEmployee.Current != null)
            {
                InventoryItem item = PXSelectorAttribute.Select <InventoryItem.inventoryID>(cache, line) as InventoryItem;

                if (item == null)
                {
                    if (line.ExpenseDate == null)
                    {
                        line.ExpenseDate = ExpenseClaim.Current.DocDate;
                    }

                    line.ExpenseAccountID = EPEmployee.Current.ExpenseAcctID;
                    line.SalesAccountID   = EPEmployee.Current.SalesAcctID;
                }
                else
                {
                    line.ExpenseAccountID = item.COGSAcctID;
                    if (line.Billable == true)
                    {
                        line.SalesAccountID = item.SalesAcctID;
                    }
                }

                cache.SetDefaultExt <EPExpenseClaimDetails.expenseSubID>(line);
                cache.SetDefaultExt <EPExpenseClaimDetails.salesSubID>(line);
            }
        }
        public virtual void _(Events.FieldVerifying <EPExpenseClaimDetails.refNbr> e)
        {
            EPExpenseClaimDetails receipt = (EPExpenseClaimDetails)e.Row;
            string newClaimRefNbr         = (string)e.NewValue;

            object pendingCorpCard = e.Cache.GetValuePending <EPExpenseClaimDetails.corpCardID>(receipt);
            int?   corpCardID      = null;

            if (pendingCorpCard == PXCache.NotSetValue)
            {
                corpCardID = receipt.CorpCardID;
            }
            else
            {
                if (pendingCorpCard is string corpCardCD)
                {
                    corpCardID = CACorpCard.PKCD.Find(e.Cache.Graph, corpCardCD)?.CorpCardID;
                }
                else
                {
                    corpCardID = (int?)pendingCorpCard;
                }
            }

            EPExpenseClaim newClaim = GetParentClaim(newClaimRefNbr);

            VerifyClaimAndCorpCardCurrencies(corpCardID, newClaim);
            VerifyEmployeeAndClaimCurrenciesForCash(receipt, receipt.PaidWith, newClaim);
        }
Beispiel #10
0
        public override void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (row.LegacyReceipt == true)
            {
                if (!object.Equals(GetTaxCategory(sender, e.OldRow), GetTaxCategory(sender, e.Row)) ||
                    !object.Equals(GetCuryTranAmt(sender, e.OldRow), GetCuryTranAmt(sender, e.Row)) ||
                    !object.Equals(GetTaxZoneLocal(sender, e.OldRow), GetTaxZoneLocal(sender, e.Row)) ||
                    !object.Equals(GetRefNbr(sender, e.OldRow), GetRefNbr(sender, e.Row)) ||
                    !object.Equals(GetTaxID(sender, e.OldRow), GetTaxID(sender, e.Row)))
                {
                    EPClaimReceiptController.DeleteLegacyTaxRows(sender.Graph, row.RefNbr);

                    PXCache cache = sender.Graph.Caches[_ChildType];
                    Preload(sender);

                    List <object> details = this.ChildSelect(cache, e.Row);
                    ReDefaultTaxes(cache, details);

                    _ParentRow = e.Row;
                    CalcTaxes(cache, null);
                    _ParentRow        = null;
                    row.LegacyReceipt = false;
                }
            }
            base.RowUpdated(sender, e);
        }
        protected virtual PMTran InsertPMTran(RegisterEntry pmGraph, PXResult <EPExpenseClaimDetails, Contract, Account> res)
        {
            EPExpenseClaimDetails detail = res;
            Contract contract            = res;
            Account  account             = res;

            if (account.AccountGroupID == null && contract.BaseType == CTPRType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            bool released = contract.BaseType == CTPRType.Contract;             //contract trans are created as released

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID   = account.AccountGroupID;
            tran.BAccountID       = detail.CustomerID;
            tran.LocationID       = detail.CustomerLocationID;
            tran.ProjectID        = detail.ContractID;
            tran.TaskID           = detail.TaskID;
            tran.CostCodeID       = detail.CostCodeID;
            tran.InventoryID      = detail.InventoryID;
            tran.Qty              = detail.Qty;
            tran.Billable         = true;
            tran.BillableQty      = detail.Qty;
            tran.UOM              = detail.UOM;
            tran.TranCuryID       = detail.CuryID;
            tran.BaseCuryInfoID   = detail.CuryInfoID;
            tran.TranCuryAmount   = detail.ClaimCuryTranAmt;
            tran.Amount           = detail.ClaimTranAmt;
            tran.TranCuryUnitRate = detail.CuryUnitCost;
            tran.UnitRate         = detail.UnitCost;

            //TODO: Review the following code (exists only to support MA302 case when UnitCost is not entered):
            if (detail.CuryUnitCost == 0m && detail.Qty != 0)
            {
                tran.TranCuryUnitRate = detail.ClaimCuryTranAmt / detail.Qty;
                tran.UnitRate         = detail.ClaimTranAmt / detail.Qty;
            }
            tran.AccountID  = detail.ExpenseAccountID;
            tran.SubID      = detail.ExpenseSubID;
            tran.StartDate  = detail.ExpenseDate;
            tran.EndDate    = detail.ExpenseDate;
            tran.Date       = detail.ExpenseDate;
            tran.ResourceID = detail.EmployeeID;
            tran.Released   = released;

            tran = pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = released;
            if (released)
            {
                pmGraph.Document.Current.Status = PMRegister.status.Released;
            }

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], detail, pmGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.pm>());

            return(tran);
        }
        public EPExpenseClaim GetParentClaim(string claimRefNbr)
        {
            EPExpenseClaimDetails receiptStub = new EPExpenseClaimDetails()
            {
                RefNbr = claimRefNbr
            };

            return(PXParentAttribute.SelectParent <EPExpenseClaim>(Receipts.Cache, receiptStub));
        }
        protected virtual void _(Events.RowUpdated <CurrencyInfo> e)
        {
            EPExpenseClaimDetails receipt = Receipts.Current;

            if (receipt != null)
            {
                RecalcAmountInClaimCury(receipt);
            }
        }
        protected virtual void _(Events.FieldUpdated <EPExpenseClaimDetails.corpCardID> e)
        {
            EPExpenseClaimDetails document = (EPExpenseClaimDetails)e.Row;
            int?newCorpCardID = (int?)e.NewValue;

            SetCardCurrencyData(e.Cache, document, newCorpCardID);
            SetClaimCuryWhenNotInClaim(document, document.RefNbr, newCorpCardID);
            RecalcAmountInClaimCury(document);
        }
Beispiel #15
0
        public static void AmtFieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (e.Row != null)
            {
                RecalcAmountInClaimCury(cache, row);
            }
        }
Beispiel #16
0
        protected virtual void EPExpenseClaimDetails_Selected_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (row != null && row.RefNbr != null && (bool)e.NewValue == true)
            {
                sender.RaiseExceptionHandling <EPExpenseClaimDetails.selected>(row, e.NewValue, new PXSetPropertyException(Messages.ReceiptIsClaimed, PXErrorLevel.RowWarning));
            }
        }
Beispiel #17
0
        protected virtual void EPExpenseClaimDetails_RowDeleting(PXCache cache, PXRowDeletingEventArgs e)
        {
            EPExpenseClaimDetails detail = e.Row as EPExpenseClaimDetails;

            if (detail != null)
            {
                FindImplementation <ExpenseClaimMaintReceiptExt>().RemoveReceipt(Details.Cache, detail);
                e.Cancel = true;
            }
        }
Beispiel #18
0
        protected virtual void EPExpenseClaimDetails_RowDeleting(PXCache cache, PXRowDeletingEventArgs e)
        {
            EPExpenseClaimDetails detail = e.Row as EPExpenseClaimDetails;

            if (detail != null)
            {
                EPClaimReceiptController.RemoveReceipt(Details.Cache, detail);
                e.Cancel = true;
            }
        }
Beispiel #19
0
        protected virtual void editDetail()
        {
            EPExpenseClaimDetails row = ClaimDetails.Current;

            if (row == null)
            {
                return;
            }
            PXRedirectHelper.TryRedirect(this, row, PXRedirectHelper.WindowMode.InlineWindow);
        }
Beispiel #20
0
        protected virtual void InsertPMTran(RegisterEntry pmGraph, EPExpenseClaimDetails row, EPExpenseClaim doc, bool copyNotes, bool copyFiles)
        {
            PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(pmGraph, row.ContractID);

            Account account = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.ExpenseAccountID);

            if (account.AccountGroupID == null && project.BaseType == PMProject.ProjectBaseType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID = account.AccountGroupID;
            tran.BAccountID     = row.CustomerID;
            tran.LocationID     = row.CustomerLocationID;
            tran.ProjectID      = row.ContractID;
            tran.TaskID         = row.TaskID;
            tran.InventoryID    = row.InventoryID;
            tran.Qty            = row.Qty;
            tran.Billable       = true;
            tran.BillableQty    = row.Qty;
            tran.UOM            = row.UOM;
            tran.UnitRate       = row.UnitCost;
            tran.Amount         = row.TranAmt;
            tran.AccountID      = row.ExpenseAccountID;
            tran.SubID          = row.ExpenseSubID;
            tran.StartDate      = row.ExpenseDate;
            tran.EndDate        = row.ExpenseDate;
            tran.Date           = row.ExpenseDate;
            tran.ResourceID     = doc.EmployeeID;
            tran.Released       = project.BaseType == PMProject.ContractBaseType.Contract;      //contract trans are created as released

            pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = project.BaseType == PMProject.ContractBaseType.Contract;

            if (copyNotes)
            {
                string note = PXNoteAttribute.GetNote(Caches[typeof(EPExpenseClaimDetails)], row);
                if (note != null)
                {
                    PXNoteAttribute.SetNote(pmGraph.Transactions.Cache, tran, note);
                }
            }
            if (copyFiles)
            {
                Guid[] files = PXNoteAttribute.GetFileNotes(Caches[typeof(EPExpenseClaimDetails)], row);
                if (files != null && files.Length > 0)
                {
                    PXNoteAttribute.SetFileNotes(pmGraph.Transactions.Cache, tran, files);
                }
            }
        }
        public virtual void DefaultCardCurrencyInfo(PXCache cache, EPExpenseClaimDetails document)
        {
            if (document.CardCuryInfoID != null)
            {
                CurrencyInfo cardCuryInfo = CurrencyInfoAttribute.SetDefaults <EPExpenseClaimDetails.cardCuryInfoID>(cache, document);

                if (cardCuryInfo != null)
                {
                    document.CardCuryID = cardCuryInfo.CuryID;
                }
            }
        }
Beispiel #22
0
        protected virtual void EPExpenseClaimDetails_TaskID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            EPExpenseClaimDetails row = e.Row as EPExpenseClaimDetails;

            if (row == null)
            {
                return;
            }

            sender.SetDefaultExt <EPExpenseClaimDetails.expenseSubID>(e.Row);
            sender.SetDefaultExt <EPExpenseClaimDetails.salesSubID>(e.Row);
        }
Beispiel #23
0
 protected virtual void addNew()
 {
     using (new PXPreserveScope())
     {
         ExpenseClaimDetailEntry graph = (ExpenseClaimDetailEntry)PXGraph.CreateInstance(typeof(ExpenseClaimDetailEntry));
         graph.Clear(PXClearOption.ClearAll);
         EPExpenseClaimDetails claimDetails = (EPExpenseClaimDetails)graph.ClaimDetails.Cache.CreateInstance();
         graph.ClaimDetails.Insert(claimDetails);
         graph.ClaimDetails.Cache.IsDirty = false;
         PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.InlineWindow);
     }
 }
        public virtual void _(Events.FieldVerifying <EPExpenseClaimDetails.curyEmployeePart> e)
        {
            EPExpenseClaimDetails receipt = (EPExpenseClaimDetails)e.Row;
            decimal?newValue = (decimal?)e.NewValue;

            if (newValue != null)
            {
                string paidWith = (string)BqlHelper.GetValuePendingOrRow <EPExpenseClaimDetails.paidWith>(e.Cache, receipt);

                VerifyEmployeePartIsZeroForCorpCardReceipt(paidWith, newValue);
            }
        }
        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 VerifyExpenseRefNbrIsNotEmpty(EPExpenseClaimDetails receipt)
        {
            EPSetup setup = EPSetup.Select();

            if (setup.RequireRefNbrInExpenseReceipts == true)
            {
                if (string.IsNullOrEmpty(receipt.ExpenseRefNbr))
                {
                    var fieldName = typeof(EPExpenseClaimDetails.expenseRefNbr).Name;
                    throw new PXRowPersistingException(fieldName, receipt.ExpenseRefNbr, ErrorMessages.FieldIsEmpty, fieldName);
                }
            }
        }
Beispiel #27
0
        protected virtual PMTran InsertPMTran(RegisterEntry pmGraph, PXResult <EPExpenseClaimDetails, Contract, Account> res)
        {
            EPExpenseClaimDetails detail = res;
            Contract contract            = res;
            Account  account             = res;

            if (account.AccountGroupID == null && contract.BaseType == PMProject.ProjectBaseType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            bool released = contract.BaseType == Contract.ContractBaseType.Contract;             //contract trans are created as released

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID = account.AccountGroupID;
            tran.BAccountID     = detail.CustomerID;
            tran.LocationID     = detail.CustomerLocationID;
            tran.ProjectID      = detail.ContractID;
            tran.TaskID         = detail.TaskID;
            tran.InventoryID    = detail.InventoryID;
            tran.Qty            = detail.Qty;
            tran.Billable       = true;
            tran.BillableQty    = detail.Qty;
            tran.UOM            = detail.UOM;
            if (detail.CuryInfoID == detail.ClaimCuryInfoID && detail.EmployeePart == 0m)
            {
                tran.UnitRate = detail.UnitCost;
            }
            else
            {
                tran.UnitRate = detail.ClaimTranAmt / detail.Qty;
            }
            tran.Amount     = detail.ClaimTranAmt;
            tran.AccountID  = detail.ExpenseAccountID;
            tran.SubID      = detail.ExpenseSubID;
            tran.StartDate  = detail.ExpenseDate;
            tran.EndDate    = detail.ExpenseDate;
            tran.Date       = detail.ExpenseDate;
            tran.ResourceID = detail.EmployeeID;
            tran.Released   = released;

            tran = pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = released;

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], detail, pmGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.pm>());

            return(tran);
        }
Beispiel #28
0
        protected virtual void EPExpenseClaimDetails_ContractID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            EPExpenseClaimDetails row     = e.Row as EPExpenseClaimDetails;
            PMProject             project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(this, row.ContractID);

            if (project.CustomerID != null && row.CustomerID != null && row.CustomerID != project.CustomerID)
            {
                cache.RaiseExceptionHandling <EPExpenseClaimDetails.contractID>(e.Row, null,
                                                                                new PXSetPropertyException(Messages.CustomerDoesNotMatchProject, PXErrorLevel.Warning));
            }

            cache.SetDefaultExt <EPExpenseClaimDetails.expenseSubID>(e.Row);
            cache.SetDefaultExt <EPExpenseClaimDetails.salesSubID>(e.Row);
        }
        public virtual void RemoveReceipt(PXCache cache, EPExpenseClaimDetails receipt, bool skipReceiptCacheUpdate = false)
        {
            receipt = cache.CreateCopy(receipt) as EPExpenseClaimDetails;
            string oldRefNbr = receipt.RefNbr;

            receipt.RefNbr = null;

            RefNbrUpdated(cache, null, receipt, oldRefNbr);

            if (!skipReceiptCacheUpdate)
            {
                cache.Update(receipt);
            }
        }
        public virtual void SumClaimValues(EPExpenseClaim claim, EPExpenseClaimDetails receipt, EPExpenseClaimDetails oldReceipt)
        {
            EPExpenseClaim newClaim = (EPExpenseClaim)Claim.Cache.CreateCopy(claim);

            SumCalc sumCalculator = new SumCalc();

            newClaim.CuryDocBal          += (decimal?)sumCalculator.Calculate <EPExpenseClaimDetails.claimCuryTranAmtWithTaxes>(Receipts.Cache, receipt, oldReceipt);
            newClaim.CuryTaxTotal        += (decimal?)sumCalculator.Calculate <EPExpenseClaimDetails.claimCuryTaxTotal>(Receipts.Cache, receipt, oldReceipt);
            newClaim.CuryTaxRoundDiff    += (decimal?)sumCalculator.Calculate <EPExpenseClaimDetails.claimCuryTaxRoundDiff>(Receipts.Cache, receipt, oldReceipt);
            newClaim.CuryVatExemptTotal  += (decimal?)sumCalculator.Calculate <EPExpenseClaimDetails.claimCuryVatExemptTotal>(Receipts.Cache, receipt, oldReceipt);
            newClaim.CuryVatTaxableTotal += (decimal?)sumCalculator.Calculate <EPExpenseClaimDetails.claimCuryVatTaxableTotal>(Receipts.Cache, receipt, oldReceipt);

            Claim.Update(newClaim);
        }