Skip to content

Commit

Permalink
feat(transactions): partial transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
yyewolf committed Aug 24, 2023
1 parent 7eb6285 commit f03e673
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 87 deletions.
10 changes: 10 additions & 0 deletions backend/api/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ func (s *Server) PatchTransactionItemId(c echo.Context, accountId autogen.UUID,
item.TotalCost = *params.Amount * item.UnitCost
}

if params.AlreadyDone != nil {
if *params.AlreadyDone > item.ItemAmount {
return Error400(c)
}
item.ItemAlreadyDone = *params.AlreadyDone
if item.ItemAlreadyDone == item.ItemAmount {
item.State = autogen.TransactionItemFinished
}
}

origItem, err := s.DBackend.GetItem(c.Request().Context(), itemId.String())
if err != nil {
if err == mongo.ErrNoDocuments {
Expand Down
158 changes: 85 additions & 73 deletions backend/autogen/bar.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion bar.openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,13 @@ paths:
schema:
type: integer
format: uint64
- name: already_done
in: query
description: Update item's already done
required: false
schema:
type: integer
format: uint64
responses:
'200':
description: ''
Expand Down Expand Up @@ -4213,6 +4220,9 @@ components:
item_amount:
type: integer
format: uint64
item_already_done:
type: integer
format: uint64
unit_cost:
type: integer
format: uint64
Expand All @@ -4225,6 +4235,7 @@ components:
- item_id
- item_name
- item_amount
- item_already_done
- unit_cost
- total_cost
- state
Expand Down Expand Up @@ -4264,7 +4275,6 @@ components:
amount:
type: integer
format: uint64

required:
- item_id
- amount
Expand Down
Loading

0 comments on commit f03e673

Please sign in to comment.