Skip to content

Commit

Permalink
OpportunityForecastAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Ciecior committed Dec 30, 2020
1 parent 747110f commit 6961181
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@

0.5.0.6
---
- Modified Documents API to retrieve documents from Tickets, Opportunities, and Companies.
- Modified Documents API to retrieve documents from Tickets, Opportunities, and Companies.

0.5.0.7
---
- Modified the OpportunityForecast API to correct the fields.
- NOTE: The GET /sales/opportunities/{}/forecast endpoint doesn't return a list, it returns a dict. The RestApi.get() method doesn't deal with this properly. ConnectWise needs to fix their endpoint.
32 changes: 21 additions & 11 deletions sales/opportunity_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
class OpportunityForecast(CWModel):

def __init__(self, json_dict=None):
self.id = None # (Integer)
self.name = None # (String(50))
self.revenue = None # (Number)
self.cost = None # (Number)
self.type = None # *(Enum)
self.status = None # (OpportunityStatusReference)
self.includedFlag = None # (Boolean)
self.recurring = None # (ProductRecurring)
self.percent = None # (Number)
self.margin = None # (Number)
self.opportunityId = None # (Integer)
self.id = None # (Integer)
self.forecastItems = None # ([ForecastItem])
self.productRevenue = None # (ProductRevenueReference)
self.serviceRevenue = None # (ServiceRevenueReference)
self.agreementRevenue = None # (AgreementRevenueReference)
self.timeRevenue = None # (TimeRevenueReference)
self.expenseRevenue = None # (ExpenseRevenueReference)
self.forecastRevenueTotals = None # (ForecastRevenueReference)
self.inclusiveRevenueTotals = None # (InclusiveRevenueReference)
self.recurringTotal = None # (Number)
self.wonRevenue = None # (WonRevenueReference)
self.lostRevenue = None # (LostRevenueReference)
self.openRevenue = None # (OpenRevenueReference)
self.otherRevenue1 = None # (Other1RevenueReference)
self.otherRevenue2 = None # (Other2RevenueReference)
self.salesTaxRevenue = None # (Number)
self.forecastTotalWithTaxes = None # (Number)
self.expectedProbability = None # (Number)
self.taxCode = None # (TaxCodeReference)
self.billingTerms = None # (BillingTermsReference)
self.currency = None # (CurrencyRefernce)
self._info = None # (Metadata)

# initialize object with json dict
Expand Down
32 changes: 32 additions & 0 deletions sales/opportunity_forecast_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ..cw_controller import CWController
# Class for /sales/opportunities
from . import opportunity_forecast


class OpportunityForecastAPI(CWController):
def __init__(self, parent, **kwargs):
self.module_url = 'sales'
self.module = 'opportunities/{}/forecast'.format(parent)
self._class = opportunity_forecast.OpportunityForecast
super().__init__(**kwargs) # instance gets passed to parent object

def get_opportunity_forecasts(self):
return super()._get()

def create_opportunity_forecast(self, a_opportunity_forecast):
return super()._create(a_opportunity_forecast)

def get_opportunity_forecasts_count(self):
return super()._get_count()

def get_opportunity_forecast_by_id(self, opportunity_forecast_id):
return super()._get_by_id(opportunity_forecast_id)

def delete_opportunity_forecast_by_id(self, opportunity_forecast_id):
super()._delete_by_id(opportunity_forecast_id)

def replace_opportunity_forecast(self, opportunity_forecast_id):
return super()._replace(opportunity_forecast_id)

def update_opportunity_forecast(self, opportunity_forecast_id, key, value):
return super()._update(opportunity_forecast_id, key, value)

0 comments on commit 6961181

Please sign in to comment.