mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 10:46:50 +00:00
add booking fees total
This commit is contained in:
parent
da38546c3d
commit
24799bd2db
4 changed files with 41 additions and 17 deletions
|
|
@ -75,6 +75,7 @@ type Report struct {
|
|||
Fee float64
|
||||
Profit float64
|
||||
CardTotal float64
|
||||
BookingFees float64
|
||||
}
|
||||
|
||||
type Line struct {
|
||||
|
|
@ -148,5 +149,12 @@ func (bs Service) BuildReport(period string, month, year int) *Report {
|
|||
Profit: u.Reduce(lines, func(l *Line, sum float64) float64 { return sum + l.Profit() }, 0.0),
|
||||
Lines: lines,
|
||||
CardTotal: cardTotal,
|
||||
BookingFees: u.Reduce(lines, func(l *Line, sum float64) float64 {
|
||||
if l.Platform == "Booking" {
|
||||
return sum + l.PlatformFees
|
||||
} else {
|
||||
return sum
|
||||
}
|
||||
}, 0.0),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ func handleComputeReport(bs *booking.Service, hc *config.Host) echo.HandlerFunc
|
|||
Fee: strconv.FormatFloat(r.Fee, 'f', 2, 64),
|
||||
Profit: strconv.FormatFloat(r.Profit, 'f', 2, 64),
|
||||
CardTotal: strconv.FormatFloat(r.CardTotal, 'f', 2, 64),
|
||||
BookingFees: strconv.FormatFloat(r.BookingFees, 'f', 2, 64),
|
||||
Lines: u.Map(r.Lines, func(l *booking.Line) *views.ReportLine {
|
||||
return &views.ReportLine{
|
||||
Id: l.InvoiceNumber(hc),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package views
|
|||
type ReportViewModel struct {
|
||||
Total string
|
||||
CardTotal string
|
||||
BookingFees string
|
||||
PlatformFees string
|
||||
Fee string
|
||||
Profit string
|
||||
|
|
@ -82,8 +83,8 @@ templ ReportSection(report *ReportViewModel) {
|
|||
<td></td>
|
||||
<td>Card-only: </td>
|
||||
<td>{ report.CardTotal }</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Booking-only:</td>
|
||||
<td>{ report.BookingFees }</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import "bytes"
|
|||
type ReportViewModel struct {
|
||||
Total string
|
||||
CardTotal string
|
||||
BookingFees string
|
||||
PlatformFees string
|
||||
Fee string
|
||||
Profit string
|
||||
|
|
@ -66,7 +67,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(row.Id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 52, Col: 16}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 53, Col: 16}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -79,7 +80,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(row.CustomerName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 55, Col: 28}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 56, Col: 28}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -92,7 +93,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(row.From)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 56, Col: 20}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 57, Col: 20}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -105,7 +106,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(row.To)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 57, Col: 18}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 58, Col: 18}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -118,7 +119,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(row.Total)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 58, Col: 21}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 59, Col: 21}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -131,7 +132,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(row.Platform)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 59, Col: 24}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 60, Col: 24}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -144,7 +145,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(row.PlatformFees)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 60, Col: 28}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 61, Col: 28}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -157,7 +158,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(row.Fee)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 61, Col: 19}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 62, Col: 19}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -170,7 +171,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(row.Profit)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 62, Col: 22}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 63, Col: 22}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -188,7 +189,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(report.Total)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 72, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 73, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -201,7 +202,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(report.PlatformFees)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 74, Col: 30}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 75, Col: 30}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -214,7 +215,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(report.Fee)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 75, Col: 21}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 76, Col: 21}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -227,7 +228,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(report.Profit)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 76, Col: 24}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 77, Col: 24}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
|
@ -240,13 +241,26 @@ func ReportSection(report *ReportViewModel) templ.Component {
|
|||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(report.CardTotal)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 83, Col: 27}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 84, Col: 27}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td></td><td></td><td></td><td></td></tr></tfoot></table></div>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>Booking-only:</td><td>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(report.BookingFees)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/report_section.templ`, Line: 86, Col: 29}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td></td><td></td></tr></tfoot></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue