generated from vshn/go-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from vshn/feat/subitems
Add sub-items to invoice
- Loading branch information
Showing
10 changed files
with
160 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{- template "_compute" . -}} | ||
{{- define "_compute" -}} | ||
{{- $s:="\u2001" -}}{{- /*We need to use unicode whitespaces to make Odoo render them*/ -}} | ||
Compute | ||
|
||
Qty: {{.Quantity | printf "%.2f"}} {{.Unit}}-Minutes | ||
Average Usage: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute | ||
{{if .SubItems.appuio_cloud_memory_subquery_memory_request -}} | ||
{{$s}}Memory Requests: {{.SubItems.appuio_cloud_memory_subquery_memory_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute | ||
{{end -}} | ||
{{if .SubItems.appuio_cloud_memory_subquery_cpu_request -}} | ||
{{$s}}CPU Requests: {{.SubItems.appuio_cloud_memory_subquery_cpu_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute | ||
{{end -}} | ||
Unit Price: CHF {{.PricePerUnit | printf "%.10f"}} / {{.Unit}} / Minute | ||
{{- end -}} |
4 changes: 1 addition & 3 deletions
4
description_templates/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
Compute | ||
|
||
{{template "_usage" . -}} | ||
{{template "_compute" . -}} |
4 changes: 1 addition & 3 deletions
4
description_templates/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
Compute | ||
|
||
{{template "_usage" . -}} | ||
{{template "_compute" . -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package descriptiontemplates_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/appuio/appuio-cloud-reporting/pkg/invoice" | ||
"github.com/stretchr/testify/require" | ||
"github.com/vshn/appuio-odoo-adapter/invoice/desctmpl" | ||
) | ||
|
||
func TestTempalte_MissingSubItem_NoError(t *testing.T) { | ||
templateFS := os.DirFS(".") | ||
r, err := desctmpl.ItemDescriptionTemplateRendererFromFS(templateFS, extension) | ||
require.NoError(t, err) | ||
|
||
item := invoice.Item{ | ||
Description: "Long form query description", | ||
QueryName: "default_query", | ||
ProductRef: invoice.ProductRef{ | ||
Target: "1919", | ||
Source: "appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0", | ||
}, | ||
Quantity: 87955674.09456764, | ||
QuantityMin: 456.345593, | ||
QuantityAvg: 456.345593, | ||
QuantityMax: 456.345593, | ||
Unit: "UNIT", | ||
PricePerUnit: 0.000000746, | ||
Discount: 0.33, | ||
Total: 43.962005025946798, | ||
SubItems: map[string]invoice.SubItem{ | ||
"appuio_cloud_memory_subquery_memory_request": { | ||
Description: "Memory request aggregated by namespace", | ||
QueryName: "appuio_cloud_memory_subquery_memory_request", | ||
Quantity: 34923234.04433424, | ||
QuantityMin: 2.251, | ||
QuantityAvg: 42.2, | ||
QuantityMax: 9001.1, | ||
Unit: "TPS", | ||
}, | ||
}, | ||
} | ||
|
||
_, err = r.RenderItemDescription(context.Background(), item) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters