protected virtual void ContractTemplate_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { ContractTemplate row = e.Row as ContractTemplate; if (row != null) { ContractBillingSchedule schedule = new ContractBillingSchedule(); schedule.ContractID = row.ContractID; Billing.Insert(schedule); PXStringState state = SLAMapping.Cache.GetStateExt <ContractSLAMapping.severity>(null) as PXStringState; if (state != null && state.AllowedValues != null && state.AllowedValues.Length > 0) { foreach (string severity in state.AllowedValues) { ContractSLAMapping sla = new ContractSLAMapping(); sla.ContractID = row.ContractID; sla.Severity = severity; SLAMapping.Insert(sla); } } Billing.Cache.IsDirty = false; SLAMapping.Cache.IsDirty = false; } }
protected ContractProcessing(int?contractID) { if (contractID > 0) { this.graph = PXGraph.CreateInstance <ARInvoiceEntry>(); graph.FieldVerifying.AddHandler <ARInvoice.projectID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); this.contract = PXSelect <Contract, Where <Contract.contractID, Equal <Required <Contract.contractID> > > > .Select(graph, contractID); this.commonsetup = PXSelect <CommonSetup> .Select(graph); this.template = PXSelect <Contract, Where <Contract.contractID, Equal <Required <Contract.contractID> > > > .Select(graph, contract.TemplateID); this.schedule = PXSelect <ContractBillingSchedule> .Search <ContractBillingSchedule.contractID>(graph, contract.ContractID); if (contract.CustomerID != null) { if (schedule != null && schedule.AccountID != null) { customer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <ContractBillingSchedule.accountID> > > > .Select(graph, schedule.AccountID); if (schedule.LocationID != null) { location = PXSelect <Location, Where <Location.bAccountID, Equal <Required <ContractBillingSchedule.accountID> >, And <Location.locationID, Equal <Required <ContractBillingSchedule.locationID> > > > > .Select(graph, customer.BAccountID, schedule.LocationID); } else { location = PXSelect <Location, Where <Location.bAccountID, Equal <Required <Customer.bAccountID> >, And <Location.locationID, Equal <Required <Customer.defLocationID> > > > > .Select(graph, customer.BAccountID, customer.DefLocationID); } } else { customer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(graph, contract.CustomerID); if (contract.LocationID != null) { location = PXSelect <Location, Where <Location.bAccountID, Equal <Required <ContractBillingSchedule.accountID> >, And <Location.locationID, Equal <Required <ContractBillingSchedule.locationID> > > > > .Select(graph, customer.BAccountID, contract.LocationID); } else { location = PXSelect <Location, Where <Location.bAccountID, Equal <Required <Customer.bAccountID> >, And <Location.locationID, Equal <Required <Customer.defLocationID> > > > > .Select(graph, customer.BAccountID, customer.DefLocationID); } } } SetupGraph(); } }
public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars) { int? contractID = (int?)pars[typeof(ContractID)]; string priceOption = (string)pars[typeof(ItemPriceType)]; string itemType = (string)pars[typeof(ItemType)]; int? contractItemID = (int?)pars[typeof(ContractItemID)]; int? itemID = (int?)pars[typeof(ItemID)]; decimal? fixedPrice = (decimal?)pars[typeof(FixedPrice)]; decimal? setupPrice = (decimal?)pars[typeof(SetupPrice)]; decimal? qty = (decimal?)pars[typeof(Qty)]; DateTime?date = (DateTime?)pars[typeof(PriceDate)]; // TODO: modify this part. // - PXResult <Contract, ContractBillingSchedule> customerContract = (PXResult <Contract, ContractBillingSchedule>) PXSelectJoin < Contract, LeftJoin <ContractBillingSchedule, On <ContractBillingSchedule.contractID, Equal <Contract.contractID> > >, Where < Contract.contractID, Equal <Required <Contract.contractID> > > > .Select(cache.Graph, contractID); if (customerContract == null) { return(null); } Contract contract = customerContract; ContractBillingSchedule billingSchedule = customerContract; return(GetItemPrice(cache, contract.CuryID, billingSchedule.AccountID ?? contract.CustomerID, billingSchedule.LocationID ?? contract.LocationID, contract.Status, contractItemID, itemID, itemType, priceOption, fixedPrice, setupPrice, qty, date)); }
protected virtual void BillingFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { BillingFilter filter = (BillingFilter)e.Row; Items.SetProcessDelegate( delegate(Contract item) { CTBillEngine engine = PXGraph.CreateInstance <CTBillEngine>(); ContractBillingSchedule schedule = PXSelect <ContractBillingSchedule, Where <ContractBillingSchedule.contractID, Equal <Required <Contract.contractID> > > > .Select(engine, item.ContractID); if (schedule.Type == BillingType.OnDemand) { engine.Bill(item.ContractID, filter.InvoiceDate); } else { engine.Bill(item.ContractID); } }); }
protected virtual IEnumerable items() { ExpiringContractFilter filter = Filter.Current; if (filter == null) { yield break; } bool found = false; foreach (ContractsList item in Items.Cache.Inserted) { found = true; yield return(item); } if (found) { yield break; } PXSelectBase <Contract> select = new PXSelectJoin <Contract , InnerJoin <ContractBillingSchedule, On <Contract.contractID, Equal <ContractBillingSchedule.contractID> > , InnerJoin <Customer, On <Customer.bAccountID, Equal <Contract.customerID> > > >, Where <Contract.isTemplate, Equal <boolFalse>, And <Contract.baseType, Equal <Contract.ContractBaseType>, And <Contract.expireDate, LessEqual <Current <ExpiringContractFilter.endDate> >, And <Contract.type, NotEqual <ContractType.ContractUnlimited>, And <Contract.autoRenew, Equal <boolTrue>, And <Where <Contract.status, Equal <ContractStatus.ContractStatusActivated>, Or <Contract.status, Equal <ContractStatus.ContractStatusExpired> > > > > > > > > >(this); if (!string.IsNullOrEmpty(filter.CustomerClassID)) { select.WhereAnd <Where <Customer.customerClassID, Equal <Current <ExpiringContractFilter.customerClassID> > > >(); } if (filter.TemplateID != null) { select.WhereAnd <Where <Contract.templateID, Equal <Current <ExpiringContractFilter.templateID> > > >(); } /* * Expiring Contracts has a hierarchical structure and we need to show only the latest expiring node hidding * all of its original contracts */ foreach (PXResult <Contract, ContractBillingSchedule, Customer> resultSet in select.Select()) { Contract contract = (Contract)resultSet; ContractBillingSchedule schedule = (ContractBillingSchedule)resultSet; Customer customer = (Customer)resultSet; bool skipItem = false; if (contract.Type == ContractType.Expiring) { Contract child = PXSelect <Contract, Where <Contract.originalContractID, Equal <Required <Contract.originalContractID> > > > .Select(this, contract.ContractID); skipItem = child != null; } if (!skipItem) { ContractsList result = new ContractsList(); result.ContractID = contract.ContractID; result.Description = contract.Description; result.Type = contract.Type; result.ExpireDate = contract.ExpireDate; result.CustomerID = contract.CustomerID; result.CustomerName = customer.AcctName; result.LastDate = schedule.LastDate; result.NextDate = schedule.NextDate; result.ExpireDate = contract.ExpireDate; result.TemplateID = contract.TemplateID; result.Status = contract.Status; result.StartDate = contract.StartDate; yield return(Items.Insert(result)); } } Items.Cache.IsDirty = false; }
protected virtual IEnumerable items() { RenewalContractFilter filter = Filter.Current; if (filter == null) { yield break; } bool found = false; foreach (ContractsList item in Items.Cache.Inserted) { found = true; yield return(item); } if (found) { yield break; } PXSelectBase <Contract> select = new PXSelectJoin <Contract, InnerJoin <ContractBillingSchedule, On <Contract.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <Customer.bAccountID, Equal <Contract.customerID> > > >, Where <Contract.isTemplate, NotEqual <True>, And <Contract.baseType, Equal <Contract.ContractBaseType>, And <Contract.type, NotEqual <Contract.type.unlimited>, And <Contract.autoRenew, Equal <True>, And <Where <Contract.status, Equal <Contract.status.active>, Or <Contract.status, Equal <Contract.status.expired> > > > > > > > >(this); if (!string.IsNullOrEmpty(filter.CustomerClassID)) { select.WhereAnd <Where <Customer.customerClassID, Equal <Current <RenewalContractFilter.customerClassID> > > >(); } if (filter.TemplateID != null) { select.WhereAnd <Where <Contract.templateID, Equal <Current <RenewalContractFilter.templateID> > > >(); } /* * Expiring Contracts has a hierarchical structure and we need to show only the latest expiring node hidding * all of its original contracts */ foreach (PXResult <Contract, ContractBillingSchedule, Customer> resultSet in select.Select()) { Contract contract = resultSet; ContractBillingSchedule schedule = resultSet; Customer customer = resultSet; bool skipItem = false; if (contract.Type == Contract.type.Expiring || contract.Type == Contract.type.Renewable) { Contract child = PXSelect <Contract, Where <Contract.originalContractID, Equal <Required <Contract.originalContractID> > > > .Select(this, contract.ContractID); skipItem = child != null; } if (!skipItem && contract.ExpireDate != null && ((DateTime)contract.ExpireDate).AddDays(-(contract.AutoRenewDays ?? 0)) <= filter.RenewalDate) { yield return(Items.Insert(new ContractsList { ContractID = contract.ContractID, Description = contract.Description, Type = contract.Type, ExpireDate = contract.ExpireDate, CustomerID = contract.CustomerID, CustomerName = customer.AcctName, LastDate = schedule.LastDate, NextDate = schedule.NextDate, TemplateID = contract.TemplateID, Status = contract.Status, StartDate = contract.StartDate })); } } Items.Cache.IsDirty = false; }