Skip to content

Commit

Permalink
Merge pull request #91 from appuio/move-accounting-contact-name-to-an…
Browse files Browse the repository at this point in the history
…notation

Move accounting contact name to annotation
  • Loading branch information
bastjan authored Jan 13, 2023
2 parents 2fcc012 + 8b652d4 commit 37b1020
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
7 changes: 6 additions & 1 deletion apiserver/billing/odoostorage/odoo/odoo8/odoo8.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client/model"
)

const VSHNAccountingContactNameKey = "billing.appuio.io/vshn-accounting-contact-name"

// Used to identify the accounting contact of a company.
const roleAccountCategory = 7

Expand Down Expand Up @@ -146,9 +148,12 @@ func mapPartnersToBillingEntity(company model.Partner, accounting model.Partner)
CreationTimestamp: metav1.Time{
Time: accounting.CreationTimestamp.ToTime(),
},
Annotations: map[string]string{
VSHNAccountingContactNameKey: accounting.Name,
},
},
Spec: billingv1.BillingEntitySpec{
Name: company.Name + ", " + accounting.Name,
Name: company.Name,
Phone: company.Phone.Value,
Emails: company.Emails(),
Address: billingv1.BillingEntityAddress{
Expand Down
24 changes: 17 additions & 7 deletions apiserver/billing/odoostorage/odoo/odoo8/odoo8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"testing"
"time"

billingv1 "github.com/appuio/control-api/apis/billing/v1"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client/clientmock"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client/model"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

billingv1 "github.com/appuio/control-api/apis/billing/v1"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client/clientmock"
"github.com/appuio/control-api/apiserver/billing/odoostorage/odoo/odoo8/client/model"
)

func TestGet(t *testing.T) {
Expand Down Expand Up @@ -46,9 +47,12 @@ func TestGet(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "be-456",
CreationTimestamp: metav1.Time{Time: tn},
Annotations: map[string]string{
VSHNAccountingContactNameKey: "Accounting",
},
},
Spec: billingv1.BillingEntitySpec{
Name: "Test Company, Accounting",
Name: "Test Company",
Emails: []string{},
AccountingContact: billingv1.BillingEntityContact{
Emails: []string{
Expand Down Expand Up @@ -157,9 +161,12 @@ func TestList(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{
Name: "be-456",
Annotations: map[string]string{
VSHNAccountingContactNameKey: "Accounting",
},
},
Spec: billingv1.BillingEntitySpec{
Name: "Test Company, Accounting",
Name: "Test Company",
Emails: []string{},
AccountingContact: billingv1.BillingEntityContact{
Emails: []string{},
Expand All @@ -168,9 +175,12 @@ func TestList(t *testing.T) {
}, {
ObjectMeta: metav1.ObjectMeta{
Name: "be-457",
Annotations: map[string]string{
VSHNAccountingContactNameKey: "Accounting",
},
},
Spec: billingv1.BillingEntitySpec{
Name: "Foo Company, Accounting",
Name: "Foo Company",
Emails: []string{},
AccountingContact: billingv1.BillingEntityContact{
Emails: []string{},
Expand Down

0 comments on commit 37b1020

Please sign in to comment.