You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ The key of the budget. Each envelope tracks budget for one specific purpose, e.g
21
21
22
22
If you do not spend all of the allocated budget, it rolls over to the next month. This allows to allocate a budget for expenses that do not occur that often. Say you have an insurance that is billed yearly for 120€. In this case, you can budget 10€ per month for this insurance. Once the bill arrives, all the needed budget is already allocated.
23
23
24
+
Contrary to other popular tools, if you overspend on an Envelope, the negative balance also rolls over to the next month and has to be balanced by allocating this amount. It is planned to make this behaviour configurable by budget. If you want to help out in the development of this, see [#327](https://github.com/envelope-zero/backend/issues/327).
25
+
24
26
### Transaction
25
27
26
28
A transaction represents an actual transaction. Paying for groceries, getting paid your salary, gifting somebody money for their wedding, all of those are transactions. Every transaction must be tied to a source account and destination account.
assert.True(suite.T(), envelopeMonth.Spent.Equal(spent.Neg()), "Month calculation for 2022-01 is wrong: should be %v, but is %v", spent.Neg(), envelopeMonth.Spent)
assert.True(suite.T(), envelopeMonth.Spent.Equal(spent.Neg()), "Month calculation for 2022-02 is wrong: should be %v, but is %v", spent, envelopeMonth.Spent)
assert.True(suite.T(), envelopeMonth.Spent.Equal(decimal.NewFromFloat(0)), "Month calculation for 2022-01 is wrong: should be %v, but is %v", decimal.NewFromFloat(0), envelopeMonth.Spent)
assert.Nil(suite.T(), err, "Transactions must be able to be created without an envelope (to enable internal transfers without an Envelope)")
165
+
assert.Nil(suite.T(), err, "Transactions must be able to be created without an envelope (to enable internal transfers without an Envelope and income transactions)")
suite.Assert().Fail("Resource could not be saved", err)
231
+
}
232
+
233
+
allocationFeb:=&models.Allocation{
234
+
AllocationCreate: models.AllocationCreate{
235
+
EnvelopeID: envelope.ID,
236
+
Month: january.AddDate(0, 1, 0),
237
+
Amount: decimal.NewFromFloat(40),
238
+
},
239
+
}
240
+
err=database.DB.Create(&allocationFeb).Error
241
+
iferr!=nil {
242
+
suite.Assert().Fail("Resource could not be saved", err)
243
+
}
244
+
245
+
transaction:=&models.Transaction{
246
+
TransactionCreate: models.TransactionCreate{
247
+
BudgetID: budget.ID,
248
+
EnvelopeID: &envelope.ID,
249
+
Amount: decimal.NewFromFloat(15),
250
+
SourceAccountID: internalAccount.ID,
251
+
DestinationAccountID: externalAccount.ID,
252
+
Date: january,
253
+
},
254
+
}
255
+
err=database.DB.Create(&transaction).Error
256
+
iferr!=nil {
257
+
suite.Assert().Fail("Resource could not be saved", err)
258
+
}
259
+
260
+
transaction2:=&models.Transaction{
261
+
TransactionCreate: models.TransactionCreate{
262
+
BudgetID: budget.ID,
263
+
EnvelopeID: &envelope.ID,
264
+
Amount: decimal.NewFromFloat(30),
265
+
SourceAccountID: internalAccount.ID,
266
+
DestinationAccountID: externalAccount.ID,
267
+
Date: january.AddDate(0, 1, 0),
268
+
},
269
+
}
270
+
err=database.DB.Create(&transaction2).Error
271
+
iferr!=nil {
272
+
suite.Assert().Fail("Resource could not be saved", err)
273
+
}
274
+
275
+
shouldBalance:=decimal.NewFromFloat(35)
276
+
envelopeMonth, err:=envelope.Month(january)
277
+
assert.Nil(suite.T(), err)
278
+
assert.True(suite.T(), envelopeMonth.Balance.Equal(shouldBalance), "Balance calculation for 2022-01 is wrong: should be %v, but is %v", shouldBalance, envelopeMonth.Balance)
assert.True(suite.T(), envelopeMonth.Balance.Equal(shouldBalance), "Balance calculation for 2022-02 is wrong: should be %v, but is %v", shouldBalance, envelopeMonth.Balance)
0 commit comments