Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 5

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
172 changes: 172 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: CI

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
# Match the PR base or push branch so addons track the same sumeru line.
SUMERU_REF: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}

jobs:
go-build:
name: Go build
runs-on: ubuntu-latest
defaults:
run:
working-directory: sumeru_addons
steps:
- name: Checkout sumeru_addons
uses: actions/checkout@v7
with:
path: sumeru_addons

- name: Checkout sumeru (replace sibling)
uses: actions/checkout@v7
with:
repository: ProjectMeru/sumeru
ref: ${{ env.SUMERU_REF }}
path: sumeru

- uses: actions/setup-go@v7
with:
go-version: "1.26.6"
cache: true
cache-dependency-path: sumeru_addons/go.sum

- name: Build all packages
env:
GOFLAGS: -mod=readonly
run: go build ./...

- name: Job summary
if: always()
run: |
echo "## Go build" >> "$GITHUB_STEP_SUMMARY"
echo "Command: \`go build ./...\` (replace sumeru => ../sumeru @ \`${{ env.SUMERU_REF }}\`)" >> "$GITHUB_STEP_SUMMARY"

go-test:
name: Go test
runs-on: ubuntu-latest
defaults:
run:
working-directory: sumeru_addons
steps:
- name: Checkout sumeru_addons
uses: actions/checkout@v7
with:
path: sumeru_addons

- name: Checkout sumeru (replace sibling)
uses: actions/checkout@v7
with:
repository: ProjectMeru/sumeru
ref: ${{ env.SUMERU_REF }}
path: sumeru

- uses: actions/setup-go@v7
with:
go-version: "1.26.6"
cache: true
cache-dependency-path: sumeru_addons/go.sum

- name: Run unit tests
env:
GOFLAGS: -mod=readonly
run: go test ./... -count=1 -timeout 15m

- name: Job summary
if: always()
run: |
echo "## Go test" >> "$GITHUB_STEP_SUMMARY"
echo "Command: \`go test ./...\` (replace sumeru => ../sumeru @ \`${{ env.SUMERU_REF }}\`)" >> "$GITHUB_STEP_SUMMARY"

go-lint:
name: Go lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: sumeru_addons
steps:
- name: Checkout sumeru_addons
uses: actions/checkout@v7
with:
path: sumeru_addons
fetch-depth: 0

- name: Checkout sumeru (replace sibling)
uses: actions/checkout@v7
with:
repository: ProjectMeru/sumeru
ref: ${{ env.SUMERU_REF }}
path: sumeru

- uses: actions/setup-go@v7
with:
go-version: "1.26.6"
cache: true
cache-dependency-path: sumeru_addons/go.sum

- name: go vet
run: go vet ./...

- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
working-directory: sumeru_addons
args: --timeout=10m
only-new-issues: ${{ github.event_name == 'pull_request' }}

- name: Job summary
if: always()
run: |
echo "## Go lint" >> "$GITHUB_STEP_SUMMARY"
echo "Commands: \`go vet ./...\`, \`golangci-lint run\`" >> "$GITHUB_STEP_SUMMARY"

go-vuln:
name: Go vulnerabilities
runs-on: ubuntu-latest
defaults:
run:
working-directory: sumeru_addons
steps:
- name: Checkout sumeru_addons
uses: actions/checkout@v7
with:
path: sumeru_addons

- name: Checkout sumeru (replace sibling)
uses: actions/checkout@v7
with:
repository: ProjectMeru/sumeru
ref: ${{ env.SUMERU_REF }}
path: sumeru

- uses: actions/setup-go@v7
with:
go-version: "1.26.6"
cache: true
cache-dependency-path: sumeru_addons/go.sum

- name: govulncheck
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...

- name: Job summary
if: always()
run: |
echo "## Go vulnerabilities" >> "$GITHUB_STEP_SUMMARY"
echo "Command: \`govulncheck ./...\`" >> "$GITHUB_STEP_SUMMARY"
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "2"

linters:
default: none
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
settings:
errcheck:
# Deferred Close errors are rarely actionable; keep errcheck for real ignored returns.
exclude-functions:
- (io.Closer).Close
- (*database/sql.Rows).Close
- (*database/sql.DB).Close
- (*os.File).Close
- (*compress/gzip.Reader).Close
- (*mime/multipart.FileHeader).Open
- (net/smtp.Client).Close
- (*net/smtp.Client).Close
- (*github.com/gorilla/websocket.Conn).Close

run:
timeout: 10m

issues:
max-issues-per-linter: 0
max-same-issues: 0
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# sumeru_addons

[![Go](https://img.shields.io/badge/Go-1.26.2+-00ADD8?logo=go&logoColor=white)](https://go.dev/dl/)
[![CI](https://github.com/ProjectMeru/sumeru_addons/actions/workflows/ci.yml/badge.svg)](https://github.com/ProjectMeru/sumeru_addons/actions/workflows/ci.yml)
[![Go](https://img.shields.io/badge/Go-1.26.6+-00ADD8?logo=go&logoColor=white)](https://go.dev/dl/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Pre-Alpha](https://img.shields.io/badge/Status-Pre--Alpha-critical?style=for-the-badge)](https://github.com/ProjectMeru/sumeru)

Expand Down
7 changes: 4 additions & 3 deletions account/services/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,14 @@ func actionReverseMoves(ctx context.Context, model string, id int, vals map[stri
reason := orm.AsString(wiz["reason"])
seqCode := "account.move.out_refund"
prefix := "RINV"
if revType == "in_refund" {
switch revType {
case "in_refund":
seqCode = "account.move.in_refund"
prefix = "RBILL"
} else if revType == "out_invoice" {
case "out_invoice":
seqCode = "account.move.out_invoice"
prefix = "INV"
} else if revType == "in_invoice" {
case "in_invoice":
seqCode = "account.move.in_invoice"
prefix = "BILL"
}
Expand Down
2 changes: 1 addition & 1 deletion account/services/bank_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func ReconcileStatementLine(ctx context.Context, moveLineID int, amount float64)
if math.Abs(res) <= balanceEpsilon {
return nil
}
newRes := res
var newRes float64
if res > 0 {
newRes = res - math.Abs(amount)
} else {
Expand Down
13 changes: 5 additions & 8 deletions account/services/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int
{"display_type", "=", "entry"},
})
var invLine map[string]interface{}
findInvLine:
for _, ln := range lines {
res := numericFloat(ln["amount_residual"])
if math.Abs(res) < balanceEpsilon {
Expand All @@ -31,12 +32,12 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int
case "out_invoice", "out_refund":
if atype == "asset_receivable" {
invLine = ln
break
break findInvLine
}
case "in_invoice", "in_refund":
if atype == "liability_payable" {
invLine = ln
break
break findInvLine
}
}
if invLine == nil && math.Abs(res) > balanceEpsilon {
Expand All @@ -59,10 +60,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int
return nil
}

debitID, creditID := int(invLineID), paymentLineID
if invRes < 0 {
debitID, creditID = paymentLineID, int(invLineID)
}
var debitID, creditID int
if numericFloat(invLine["debit"]) > 0 || invRes > 0 {
debitID, creditID = int(invLineID), paymentLineID
} else {
Expand All @@ -82,8 +80,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int
return err
}

newInvRes := invRes
newPayRes := payRes
var newInvRes, newPayRes float64
if invRes > 0 {
newInvRes = invRes - reconcileAmt
} else {
Expand Down
9 changes: 1 addition & 8 deletions account/services/reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,10 @@ func BalanceSheet(ctx context.Context, dateFrom, dateTo string) (*ReportResult,
if retained != 0 {
lines = append(lines, ReportLine{Name: "Current Year Earnings", Balance: round2(retained)})
}
assetTotal, liabEq := 0.0, 0.0
assetTotal := 0.0
for _, v := range assets {
assetTotal += v
}
for _, v := range liabilities {
liabEq += -v
}
for _, v := range equity {
liabEq += -v
}
liabEq += retained
return &ReportResult{
Title: "Balance Sheet",
DateFrom: dateFrom,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module sumeru_addons

go 1.26.2
go 1.26.6

replace sumeru => ../sumeru

require sumeru v0.0.0-00010101000000-000000000000

require (
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gpdf-dev/gpdf v1.0.11 // indirect
github.com/gpdf-dev/gpdf v1.0.12 // indirect
github.com/lib/pq v1.12.3 // indirect
golang.org/x/crypto v0.55.0 // indirect
golang.org/x/crypto v0.56.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gpdf-dev/gpdf v1.0.11 h1:IPtcb+/6COykKtenZ3CXexOoStdyNepiE7DHqnvyyew=
github.com/gpdf-dev/gpdf v1.0.11/go.mod h1:QTnE2q2L+q9E1neWCZen/V/x9iLOuJ1jWHBtylimfAw=
github.com/gpdf-dev/gpdf v1.0.12 h1:KAqoXq6iN+I99YbHrNIQqP77rnn2rRFq9pMoi2Ccroo=
github.com/gpdf-dev/gpdf v1.0.12/go.mod h1:QTnE2q2L+q9E1neWCZen/V/x9iLOuJ1jWHBtylimfAw=
github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ=
github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
2 changes: 1 addition & 1 deletion sale_crm/services/quotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func refreshQuotationCount(ctx context.Context, leadID int64) error {
}

func onLeadWonCreateQuotation(ctx context.Context, ev event.Event) error {
if orm.ConfigParamBool(ctx, "sale_crm.auto_quotation", true) == false {
if !orm.ConfigParamBool(ctx, "sale_crm.auto_quotation", true) {
return nil
}
model, _ := ev.Payload["model"].(string)
Expand Down