-
Notifications
You must be signed in to change notification settings - Fork 12
/
contract.go
79 lines (70 loc) · 2.87 KB
/
contract.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package entity
import (
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-module/utils"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-neo4j-repository/enum"
"time"
)
type ContractInternalFields struct {
StatusRenewalRequestedAt *time.Time
RolloutRenewalRequestedAt *time.Time
NextPreviewInvoiceRequestedAt *time.Time
}
type ContractEntity struct {
DataLoaderKey
Id string
Name string `neo4jDb:"property:name;lookupName:NAME;supportCaseSensitive:true"`
CreatedAt time.Time
UpdatedAt time.Time
ServiceStartedAt *time.Time // DateTime
SignedAt *time.Time // DateTime
EndedAt *time.Time `neo4jDb:"property:endedAt;lookupName:ENDED_AT;supportCaseSensitive:false"` // DateTime
ContractStatus enum.ContractStatus
Source DataSource
SourceOfTruth DataSource
AppSource string
ContractUrl string
InvoicingStartDate *time.Time // Date only
NextInvoiceDate *time.Time // Date only
BillingCycleInMonths int64
Currency enum.Currency
TriggeredOnboardingStatusChange bool
AddressLine1 string
AddressLine2 string
Zip string
Locality string
Country string
Region string
OrganizationLegalName string
InvoiceEmail string
InvoiceEmailCC []string
InvoiceEmailBCC []string
InvoiceNote string
CanPayWithCard bool
CanPayWithDirectDebit bool
CanPayWithBankTransfer bool
InvoicingEnabled bool
PayOnline bool
PayAutomatically bool
AutoRenew bool
Check bool
DueDays int64
ContractInternalFields ContractInternalFields
LengthInMonths int64
Approved bool
}
type ContractEntities []ContractEntity
func (c ContractEntity) IsEnded() bool {
return c.EndedAt != nil && c.EndedAt.Before(utils.Now())
}
func (c ContractEntity) IsSigned() bool {
return c.SignedAt != nil && c.SignedAt.Before(utils.Now())
}
func (c ContractEntity) IsServiceStarted() bool {
return c.ServiceStartedAt != nil && c.ServiceStartedAt.Before(utils.Now())
}
func (c ContractEntity) IsEligibleToStartOnboarding() bool {
return !c.TriggeredOnboardingStatusChange && (c.IsSigned() || c.IsServiceStarted()) && !c.IsEnded()
}
func (c ContractEntity) IsDraft() bool {
return c.ContractStatus == enum.ContractStatusDraft
}