Beispiel #1
0
        protected virtual void DRScheduleDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            DRScheduleDetail row = e.Row as DRScheduleDetail;

            if (row != null)
            {
                Delete.SetEnabled(false);
                row.DocumentType = DRScheduleDocumentType.BuildDocumentType(row.Module, row.DocType);

                release.SetVisible(row.IsCustom == true);
                release.SetEnabled(false);

                row.DefTotal = SumOpenAndProjectedTransactions(row);
                PXUIFieldAttribute.SetEnabled <DRScheduleDetail.componentID>(sender, row, row.ComponentID != DRScheduleDetail.EmptyComponentID);
                if (row.Status == DRScheduleStatus.Draft)
                {
                    release.SetEnabled(true);
                    Delete.SetEnabled(true);
                }



                Transactions.Cache.AllowInsert = row.Status != DRScheduleStatus.Closed;
                Transactions.Cache.AllowUpdate = row.Status != DRScheduleStatus.Closed;
                Transactions.Cache.AllowDelete = row.Status != DRScheduleStatus.Closed;
            }
        }
Beispiel #2
0
        protected virtual void DRScheduleDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            DR.DRScheduleDetail row = e.Row as DR.DRScheduleDetail;

            if (row != null)
            {
                row.DocumentType = DRScheduleDocumentType.BuildDocumentType(row.Module, row.DocType);
            }
        }
        public virtual IEnumerable records()
        {
            SchedulesFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <SchedulesInqResult> select = new PXSelectJoin <SchedulesInqResult,
                                                                             InnerJoin <DRSchedule, On <DRSchedule.scheduleID, Equal <SchedulesInqResult.scheduleID> >,
                                                                                        InnerJoin <DRDeferredCode, On <DRDeferredCode.deferredCodeID, Equal <SchedulesInqResult.defCode> >,
                                                                                                   LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <SchedulesInqResult.componentID> > > > >,
                                                                             Where <DRDeferredCode.accountType, Equal <Current <SchedulesFilter.accountType> > > >(this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <SchedulesInqResult.defCode, Equal <Current <SchedulesFilter.deferredCode> > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defAcctID, Equal <Current <SchedulesFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defSubID, Equal <Current <SchedulesFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.bAccountID, Equal <Current <SchedulesFilter.bAccountID> > > >();
                }

                if (filter.ComponentID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.componentID, Equal <Current <SchedulesFilter.componentID> > > >();
                }


                foreach (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> record in select.Select())
                {
                    SchedulesInqResult sd   = (SchedulesInqResult)record;
                    InventoryItem      item = (InventoryItem)record;

                    sd.ComponentCD  = item.InventoryCD;
                    sd.DocumentType = DRScheduleDocumentType.BuildDocumentType(sd.Module, sd.DocType);

                    yield return(sd);
                }
            }
            else
            {
                yield break;
            }
        }
Beispiel #4
0
        protected virtual void DRSchedule_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            DRSchedule row = e.Row as DRSchedule;

            if (row != null)
            {
                row.DocumentType = DRScheduleDocumentType.BuildDocumentType(row.Module, row.DocType);

                if (row.Module == BatchModule.AR)
                {
                    row.BAccountType = CR.BAccountType.CustomerType;

                    ARTran tran = PXSelect <ARTran, Where <ARTran.tranType, Equal <Current <DRSchedule.docType> >,
                                                           And <ARTran.refNbr, Equal <Current <DRSchedule.refNbr> >,
                                                                And <ARTran.lineNbr, Equal <Current <DRSchedule.lineNbr> > > > > > .Select(this);

                    if (tran != null)
                    {
                        row.OrigLineAmt = tran.TranAmt;
                    }
                }
                else
                {
                    row.BAccountType = CR.BAccountType.VendorType;

                    APTran tran = PXSelect <APTran, Where <APTran.tranType, Equal <Current <DRSchedule.docType> >,
                                                           And <APTran.refNbr, Equal <Current <DRSchedule.refNbr> >,
                                                                And <APTran.lineNbr, Equal <Current <DRSchedule.lineNbr> > > > > > .Select(this);

                    if (tran != null)
                    {
                        row.OrigLineAmt = tran.TranAmt;
                    }
                }

                release.SetVisible(row.IsCustom == true);
                release.SetEnabled(row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.documentType>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.finPeriodID>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.refNbr>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.lineNbr>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.docDate>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.bAccountID>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.bAccountLocID>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.projectID>(sender, row, row.IsCustom == true);
                PXUIFieldAttribute.SetEnabled <DRSchedule.taskID>(sender, row, row.IsCustom == true);

                PXUIFieldAttribute.SetVisible <DRSchedule.origLineAmt>(sender, row, row.IsCustom != true);

                Components.Cache.AllowInsert = row.IsDraft == true;
                Components.Cache.AllowUpdate = row.IsDraft == true;
                Components.Cache.AllowDelete = row.IsDraft == true;
            }
        }
Beispiel #5
0
        public virtual IEnumerable records()
        {
            var ret = new List <SchedulesInqResult>();

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            SchedulesFilter filter = this.Filter.Current;

            BqlCommand cmd = ComposeBQLCommandForRecords(filter);

            if (cmd == null)
            {
                return(ret);
            }

            PXView view = new PXView(this, true, cmd);

            foreach (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> record in
                     view.Select(
                         PXView.Currents,
                         null,
                         PXView.Searches,
                         PXView.SortColumns,
                         PXView.Descendings,
                         PXView.Filters,
                         ref startRow,
                         PXView.MaximumRows,
                         ref totalRows))
            {
                SchedulesInqResult schedulesInqResult = (SchedulesInqResult)record;
                InventoryItem      inventoryItem      = (InventoryItem)record;

                schedulesInqResult.ComponentCD  = inventoryItem.InventoryCD;
                schedulesInqResult.DocumentType = DRScheduleDocumentType.BuildDocumentType(schedulesInqResult.Module, schedulesInqResult.DocType);

                ret.Add(schedulesInqResult);
            }

            PXView.StartRow = 0;

            return(ret);
        }
        protected virtual void DRSchedule_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            DRSchedule row = e.Row as DRSchedule;

            if (row != null)
            {
                row.DocumentType = DRScheduleDocumentType.BuildDocumentType(row.Module, row.DocType);

                if (row.Module == BatchModule.AR)
                {
                    row.BAccountType = CR.BAccountType.CustomerType;

                    ARTran tran = PXSelect <ARTran, Where <ARTran.tranType, Equal <Current <DRSchedule.docType> >,
                                                           And <ARTran.refNbr, Equal <Current <DRSchedule.refNbr> >,
                                                                And <ARTran.lineNbr, Equal <Current <DRSchedule.lineNbr> > > > > > .Select(this);

                    if (tran != null)
                    {
                        row.OrigLineAmt = tran.TranAmt;
                    }
                }
                else
                {
                    row.BAccountType = CR.BAccountType.VendorType;

                    APTran tran = PXSelect <APTran, Where <APTran.tranType, Equal <Current <DRSchedule.docType> >,
                                                           And <APTran.refNbr, Equal <Current <DRSchedule.refNbr> >,
                                                                And <APTran.lineNbr, Equal <Current <DRSchedule.lineNbr> > > > > > .Select(this);

                    if (tran != null)
                    {
                        row.OrigLineAmt = tran.TranAmt;
                    }
                }

                PXUIFieldAttribute.SetVisible <DRSchedule.origLineAmt>(sender, row, row.IsCustom != true);
            }
        }
        protected virtual IEnumerable items()
        {
            ScheduleRecognitionFilter filter = Filter.Current;

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

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


            PXSelectBase <DRScheduleTran> select = new PXSelectJoin <DRScheduleTran,
                                                                     InnerJoin <DRScheduleDetail, On <DRScheduleTran.scheduleID, Equal <DRScheduleDetail.scheduleID>, And <DRScheduleTran.componentID, Equal <DRScheduleDetail.componentID> > >,
                                                                                InnerJoin <DRSchedule, On <DRScheduleTran.scheduleID, Equal <DRSchedule.scheduleID> >,
                                                                                           LeftJoin <InventoryItem, On <DRScheduleTran.componentID, Equal <InventoryItem.inventoryID> > > > >,
                                                                     Where <DRScheduleTran.recDate, LessEqual <Current <ScheduleRecognitionFilter.recDate> >,
                                                                            And <DRScheduleTran.status, Equal <DRScheduleTranStatus.OpenStatus>,
                                                                                 And <DRScheduleDetail.status, NotEqual <DRScheduleStatus.DraftStatus> > > >,
                                                                     OrderBy <Asc <DRScheduleTran.scheduleID, Asc <DRScheduleTran.componentID, Asc <DRScheduleTran.recDate, Asc <DRScheduleTran.lineNbr> > > > > >(this);

            if (!string.IsNullOrEmpty(filter.DeferredCode))
            {
                select.WhereAnd <Where <DRScheduleDetail.defCode, Equal <Current <ScheduleRecognitionFilter.deferredCode> > > >();
            }

            if (filter.BranchID != null)
            {
                select.WhereAnd <Where <DRScheduleDetail.branchID, Equal <Current <ScheduleRecognitionFilter.branchID> > > >();
            }

            Dictionary <string, string> added = new Dictionary <string, string>();

            foreach (PXResult <DRScheduleTran, DRScheduleDetail, DRSchedule, InventoryItem> resultSet in select.Select())
            {
                DRScheduleTran   tran           = (DRScheduleTran)resultSet;
                DRSchedule       schedule       = (DRSchedule)resultSet;
                DRScheduleDetail scheduleDetail = (DRScheduleDetail)resultSet;
                InventoryItem    item           = (InventoryItem)resultSet;

                string key = string.Format("{0}.{1}", tran.ScheduleID, tran.ComponentID);

                bool doInsert = false;

                if (added.ContainsKey(key))
                {
                    string addedFinPeriod = added[key];

                    if (tran.FinPeriodID == addedFinPeriod)
                    {
                        doInsert = true;
                    }
                }
                else
                {
                    doInsert = true;
                    added.Add(key, tran.FinPeriodID);
                }

                if (doInsert)
                {
                    ScheduledTran result = new ScheduledTran();
                    result.BranchID    = tran.BranchID;
                    result.AccountID   = tran.AccountID;
                    result.Amount      = tran.Amount;
                    result.ComponentID = tran.ComponentID;
                    result.DefCode     = scheduleDetail.DefCode;
                    result.FinPeriodID = tran.FinPeriodID;
                    result.LineNbr     = tran.LineNbr;
                    result.RecDate     = tran.RecDate;
                    result.ScheduleID  = tran.ScheduleID;
                    result.ScheduleNbr = schedule.ScheduleNbr;
                    result.SubID       = tran.SubID;
                    result.ComponentCD = item.InventoryCD;
                    result.DocType     = DRScheduleDocumentType.BuildDocumentType(scheduleDetail.Module, scheduleDetail.DocType);

                    Items.Cache.SetStatus(result, PXEntryStatus.Inserted);
                    yield return(result);                   // Items.Insert(result);
                }
            }


            //Virtual Records (CashReceipt):

            PXSelectBase <ARInvoice> s = null;

            if (!string.IsNullOrEmpty(filter.DeferredCode))
            {
                s = new PXSelectJoinGroupBy <ARInvoice,
                                             InnerJoin <ARTran, On <ARTran.tranType, Equal <ARInvoice.docType>,
                                                                    And <ARTran.refNbr, Equal <ARInvoice.refNbr> > >,
                                                        InnerJoin <DRDeferredCode, On <ARTran.deferredCode, Equal <DRDeferredCode.deferredCodeID>,
                                                                                       And <DRDeferredCode.method, Equal <DeferredMethodType.cashReceipt>,
                                                                                            And <DRDeferredCode.deferredCodeID, Equal <Current <ScheduleRecognitionFilter.deferredCode> > > > >,
                                                                   InnerJoin <DRSchedule, On <ARTran.tranType, Equal <DRSchedule.docType>,
                                                                                              And <ARTran.refNbr, Equal <DRSchedule.refNbr>,
                                                                                                   And <ARTran.lineNbr, Equal <DRSchedule.lineNbr> > > >,
                                                                              InnerJoin <DRScheduleDetail, On <DRSchedule.scheduleID, Equal <DRScheduleDetail.scheduleID> > > > > >,
                                             Where <ARInvoice.released, Equal <True>,
                                                    And <DRScheduleDetail.isOpen, Equal <True> > >,
                                             Aggregate <GroupBy <ARInvoice.docType, GroupBy <ARInvoice.refNbr> > > >(this);
            }
            else
            {
                s = new PXSelectJoinGroupBy <ARInvoice,
                                             InnerJoin <ARTran, On <ARTran.tranType, Equal <ARInvoice.docType>,
                                                                    And <ARTran.refNbr, Equal <ARInvoice.refNbr> > >,
                                                        InnerJoin <DRDeferredCode, On <ARTran.deferredCode, Equal <DRDeferredCode.deferredCodeID>,
                                                                                       And <DRDeferredCode.method, Equal <DeferredMethodType.cashReceipt> > >,
                                                                   InnerJoin <DRSchedule, On <ARTran.tranType, Equal <DRSchedule.docType>,
                                                                                              And <ARTran.refNbr, Equal <DRSchedule.refNbr>,
                                                                                                   And <ARTran.lineNbr, Equal <DRSchedule.lineNbr> > > >,
                                                                              InnerJoin <DRScheduleDetail, On <DRSchedule.scheduleID, Equal <DRScheduleDetail.scheduleID> > > > > >,
                                             Where <ARInvoice.released, Equal <True>,
                                                    And <DRScheduleDetail.isOpen, Equal <True> > >,
                                             Aggregate <GroupBy <ARInvoice.docType, GroupBy <ARInvoice.refNbr> > > >(this);
            }


            foreach (ARInvoice inv in s.Select())
            {
                PXSelectBase <ARTran> trs =
                    new PXSelectJoin <ARTran,
                                      InnerJoin <DRDeferredCode, On <ARTran.deferredCode, Equal <DRDeferredCode.deferredCodeID>,
                                                                     And <DRDeferredCode.method, Equal <DeferredMethodType.cashReceipt> > > >,
                                      Where <ARTran.tranType, Equal <Required <ARTran.tranType> >,
                                             And <ARTran.refNbr, Equal <Required <ARTran.refNbr> > > > >(this);

                foreach (PXResult <ARTran, DRDeferredCode> res in trs.Select(inv.DocType, inv.RefNbr))
                {
                    List <ScheduledTran> virtualRecords       = new List <ScheduledTran>();
                    List <ScheduledTran> virtualVoidedRecords = new List <ScheduledTran>();

                    ARTran         tr = (ARTran)res;
                    DRDeferredCode dc = (DRDeferredCode)res;

                    decimal trPart = 0;
                    if (inv.LineTotal.Value != 0)
                    {
                        trPart = tr.TranAmt.Value / inv.LineTotal.Value;
                    }
                    decimal trPartRest = tr.TranAmt.Value;

                    InventoryItem invItem = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, tr.InventoryID);

                    //NOTE: Multiple Components are not supported in CashReceipt Deferred Revenue Recognition.
                    DRSchedule       schedule       = GetScheduleByFID(BatchModule.AR, inv.DocType, inv.RefNbr, tr.LineNbr);
                    DRScheduleDetail scheduleDetail = GetScheduleDetailbyID(schedule.ScheduleID, tr.InventoryID != null ? tr.InventoryID : DRScheduleDetail.EmptyComponentID);
                    int lineNbr = scheduleDetail.LineCntr ?? 0;


                    PXSelectBase <ARAdjust> ads =
                        new PXSelectJoin <ARAdjust,
                                          LeftJoin <DRScheduleTran, On <ARAdjust.adjgDocType, Equal <DRScheduleTran.adjgDocType>,
                                                                        And <ARAdjust.adjgRefNbr, Equal <DRScheduleTran.adjgRefNbr> > > >,
                                          Where <ARAdjust.adjdDocType, Equal <Required <ARAdjust.adjdDocType> >,
                                                 And <ARAdjust.adjdRefNbr, Equal <Required <ARAdjust.adjdRefNbr> >,
                                                      And <DRScheduleTran.scheduleID, IsNull,
                                                           And <ARAdjust.adjgDocType, NotEqual <ARDocType.creditMemo> > > > >,
                                          OrderBy <Asc <ARAdjust.adjgDocDate> > >(this);

                    foreach (ARAdjust ad in ads.Select(inv.DocType, inv.RefNbr))
                    {
                        lineNbr++;
                        decimal amtRaw = Math.Min(trPart * ad.AdjAmt.Value, trPartRest);
                        trPartRest -= amtRaw;
                        decimal amt = PXDBCurrencyAttribute.BaseRound(this, amtRaw);

                        ScheduledTran result = new ScheduledTran();

                        result.BranchID    = ad.AdjgBranchID;
                        result.Amount      = amt;
                        result.ComponentID = tr.InventoryID;
                        result.DefCode     = tr.DeferredCode;
                        result.FinPeriodID = FinPeriodRepository.GetPeriodIDFromDate(ad.AdjgDocDate, PXAccess.GetParentOrganizationID(ad.AdjgBranchID));
                        result.LineNbr     = lineNbr;
                        result.Module      = schedule.Module;
                        result.RecDate     = ad.AdjgDocDate;
                        result.ScheduleID  = schedule.ScheduleID;
                        result.ScheduleNbr = schedule.ScheduleNbr;
                        result.DocType     = schedule.DocType;
                        result.AdjgDocType = ad.AdjgDocType;
                        result.AdjgRefNbr  = ad.AdjgRefNbr;
                        result.AdjNbr      = ad.AdjNbr;
                        result.IsVirtual   = true;
                        result.AccountID   = scheduleDetail.AccountID;
                        result.SubID       = scheduleDetail.SubID;
                        result.ComponentCD = invItem == null ? "" : invItem.InventoryCD;

                        if (ad.Voided == true)
                        {
                            if (ad.AdjgDocType == ARDocType.VoidPayment && virtualVoidedRecords.Count > 0)
                            {
                                ScheduledTran tran = virtualVoidedRecords.Where <ScheduledTran>(v => (v.AdjgDocType == ARDocType.Payment && v.AdjgRefNbr == ad.AdjgRefNbr && v.AdjNbr == ad.AdjNbr)).First <ScheduledTran>();
                                if (tran != null)
                                {
                                    virtualVoidedRecords.Remove(tran);
                                }
                            }
                            else
                            {
                                virtualVoidedRecords.Add(result);
                            }
                        }
                        else
                        {
                            virtualRecords.Add(result);
                        }
                    }

                    foreach (ScheduledTran v in virtualRecords)
                    {
                        Items.Cache.SetStatus(v, PXEntryStatus.Inserted);
                        yield return(v);                       // Items.Insert(v);
                    }

                    foreach (ScheduledTran v in virtualVoidedRecords)
                    {
                        Items.Cache.SetStatus(v, PXEntryStatus.Inserted);
                        yield return(v);                       // Items.Insert(v);
                    }
                }
            }


            Items.Cache.IsDirty = false;
        }
Beispiel #8
0
        public virtual IEnumerable records()
        {
            var ret = new List <SchedulesInqResult>();

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            SchedulesFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <SchedulesInqResult> select = new PXSelectJoin <SchedulesInqResult,
                                                                             InnerJoin <DRSchedule, On <DRSchedule.scheduleID, Equal <SchedulesInqResult.scheduleID> >,
                                                                                        InnerJoin <DRDeferredCode, On <DRDeferredCode.deferredCodeID, Equal <SchedulesInqResult.defCode> >,
                                                                                                   LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <SchedulesInqResult.componentID> > > > >,
                                                                             Where <DRDeferredCode.accountType, Equal <Current <SchedulesFilter.accountType> > > >(this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <SchedulesInqResult.defCode, Equal <Current <SchedulesFilter.deferredCode> > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defAcctID, Equal <Current <SchedulesFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defSubID, Equal <Current <SchedulesFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.bAccountID, Equal <Current <SchedulesFilter.bAccountID> > > >();
                }

                if (filter.ComponentID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.componentID, Equal <Current <SchedulesFilter.componentID> > > >();
                }

                foreach (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> record in
                         select.View.Select(
                             PXView.Currents,
                             null,
                             PXView.Searches,
                             PXView.SortColumns,
                             PXView.Descendings,
                             PXView.Filters,
                             ref startRow,
                             PXView.MaximumRows,
                             ref totalRows))
                {
                    SchedulesInqResult schedulesInqResult = (SchedulesInqResult)record;
                    InventoryItem      inventoryItem      = (InventoryItem)record;

                    schedulesInqResult.ComponentCD  = inventoryItem.InventoryCD;
                    schedulesInqResult.DocumentType = DRScheduleDocumentType.BuildDocumentType(schedulesInqResult.Module, schedulesInqResult.DocType);

                    ret.Add(schedulesInqResult);
                }
            }

            PXView.StartRow = 0;

            return(ret);
        }