lib/rules/new-developer.go

252 lines
7.2 KiB
Go
Raw Permalink Normal View History

2021-01-13 02:41:43 +00:00
package rules
import (
"time"
"code.tnxs.net/taxnexus/lib/api/crm/crm_models"
"code.tnxs.net/taxnexus/lib/api/ops/ops_models"
"code.tnxs.net/taxnexus/lib/app"
"go.temporal.io/sdk/workflow"
)
2021-01-13 05:09:16 +00:00
// NewDeveloperWrapper wraps a contact, account, payment method and a user identifier (app.User)
type NewDeveloperWrapper struct {
2021-01-19 17:45:58 +00:00
AccountName string
BillingStreet string
BillingCity string
BillingState string
BillingPostalCode string
Company string
Description string
Email string
FirstName string
LastName string
MobilePhone string
Name string
Phone string
Title string
Website string
APIKey string
SagaID string
SagaType string
2021-01-13 02:41:43 +00:00
}
2021-01-14 06:36:35 +00:00
// NewDeveloperWorkflow is a Temporal workflow
func NewDeveloperWorkflow(
ctx workflow.Context,
2021-01-19 02:48:56 +00:00
w *NewDeveloperWrapper,
2021-01-14 06:36:35 +00:00
) error {
2021-01-13 02:41:43 +00:00
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
StartToCloseTimeout: time.Minute,
})
err := workflow.ExecuteActivity(ctx,
StoreContactActivity,
&app.ContactChannelWrapper{
2021-01-19 17:45:58 +00:00
Obj: crm_models.Contact{
AccountID: "",
AssistantName: "",
AssistantPhone: "",
BirthDate: "",
Department: "",
Description: w.Description,
DoNotCall: false,
Email: w.Email,
EmailBounceDate: "",
EmailBouncedReason: "",
EnrollmentStatus: "",
Fax: "",
FirstName: w.FirstName,
HasOptedOutOfEmail: false,
HasOptedOutOfFax: false,
HomePhone: "",
IsEmailBounced: false,
IsProvisioned: false,
LastName: w.LastName,
LeadSource: "",
Level: "",
LinkedIn: "",
MailingAddress: &crm_models.Address{},
MailingLists: "",
MobilePhone: w.MobilePhone,
Name: w.Name,
OtherAddress: &crm_models.Address{},
OtherPhone: "",
OwnerID: "",
PersonalEmail: "",
Phone: w.Phone,
PhotoURL: "",
RecruitingStatus: "",
Ref: "",
ReportsToID: "",
Salutation: "",
Status: "",
TenantID: "",
Title: w.Title,
Type: "",
},
2021-01-19 02:48:56 +00:00
APIKey: w.APIKey,
SagaID: w.SagaID,
SagaType: w.SagaType,
2021-01-13 02:41:43 +00:00
}).Get(ctx, nil)
if err != nil {
return err
}
err = workflow.ExecuteActivity(ctx,
StoreAccountActivity,
&app.AccountChannelWrapper{
2021-01-19 17:45:58 +00:00
Obj: crm_models.Account{
AccountNumber: "",
AccountSource: "",
Active: false,
AdministrativeLevel: "",
Amount: 0,
AmountInvoiced: 0,
AmountPaid: 0,
AnnualRevenue: 0,
Balance: 0,
BillingAddress: &crm_models.Address{City: w.BillingCity, Street: w.BillingStreet, State: w.BillingState, PostalCode: w.BillingPostalCode},
BillingContactID: "",
BillingPreference: "",
BusinessAddress: &crm_models.Address{},
CannabisCustomer: false,
ChannelProgramLevelName: "",
ChannelProgramName: "",
ClientEndDate: "",
ClientStartDate: "",
CompanyID: "",
CoordinateID: "",
CustomerID: "",
CustomerPriority: "",
DBA: "",
DUNSNumber: "",
DandBCompanyID: "",
DefaultAddress: &crm_models.Address{},
DefaultBackendID: "",
DefaultDeliveryContactID: "",
DefaultEndUserID: "",
Description: w.Description,
EIN: "",
Email: w.Email,
EnrollmentStatus: "",
Fax: "",
ISPCustomer: false,
Industry: "",
IsCustomerPortal: false,
IsPartner: false,
MSPCustomer: false,
NAICSCode: "",
NAICSDesc: "",
Name: w.AccountName,
NumberOfEmployees: 0,
NumberOfLocations: 0,
OpenCharges: 0,
OrderContactID: "",
OrderEmail: "",
OwnerID: "",
Ownership: "",
ParentFK: "",
ParentID: "",
Phone: "",
PlaceID: "",
PreparerID: "",
Rating: "",
RatingEngineID: "",
Ref: "",
RevenueBase: 0,
RevenueNet: 0,
RevenueNotTaxable: 0,
SIC: "",
SICDesc: "",
ShippingAddress: &crm_models.Address{},
ShippingCensusTract: "",
ShippingConactID: "",
ShippingCounty: "",
Site: "",
Status: "",
TaxExemption: "",
TaxOnTax: 0,
TelecomCustomer: false,
TenantID: "",
TickerSymbol: "",
TradeStyle: "",
Type: "",
UnappliedPayments: 0,
UnitBase: 0,
UpsellOpportunity: "",
WHMCSClientID: 0,
Website: "",
XeroContactID: "",
YearStarted: "",
},
2021-01-19 02:48:56 +00:00
APIKey: w.APIKey,
SagaID: w.SagaID,
SagaType: w.SagaType,
2021-01-13 02:41:43 +00:00
}).Get(ctx, nil)
if err != nil {
return err
}
err = workflow.ExecuteActivity(ctx,
StorePaymentMethodActivity,
&app.PaymentMethodChannelWrapper{
2021-01-19 17:45:58 +00:00
Obj: ops_models.PaymentMethod{
AccountID: "todo fix this",
AchAccountType: "",
AchBankAccount: "",
AchRouting: "",
Active: false,
Autopay: false,
BankName: "",
BillingContactID: "",
CCnumber: "",
CCtype: "",
CompanyID: "",
ContractID: "",
CreatedByID: "",
CreatedDate: "",
Default: false,
ExpirationDate: "",
ExpirationMonth: "",
ExpirationYear: "",
Gateway: "",
GatewayKey: "",
LastModifiedByID: "",
LastModifiedDate: "",
Nickname: "",
RecordType: "",
Ref: "",
TenantID: "",
},
2021-01-19 02:48:56 +00:00
APIKey: w.APIKey,
SagaID: w.SagaID,
SagaType: w.SagaType,
2021-01-13 02:41:43 +00:00
}).Get(ctx, nil)
if err != nil {
return err
}
err = workflow.ExecuteActivity(ctx,
NotifyContactActivity,
&app.ContactChannelWrapper{
2021-01-19 17:45:58 +00:00
Obj: crm_models.Contact{
Description: w.Description,
Email: w.Email,
FirstName: w.FirstName,
LastName: w.LastName,
MobilePhone: w.MobilePhone,
Name: w.Name,
Phone: w.Phone,
Title: w.Title,
},
2021-01-19 02:48:56 +00:00
APIKey: w.APIKey,
SagaID: w.SagaID,
SagaType: w.SagaType,
2021-01-13 02:41:43 +00:00
}).Get(ctx, nil)
if err != nil {
return err
}
2021-01-19 02:48:56 +00:00
err = workflow.ExecuteActivity(ctx, NotifyLeadActivity, w).Get(ctx, nil)
2021-01-13 02:41:43 +00:00
if err != nil {
return err
}
return nil
}