split repo

This commit is contained in:
Ruidy 2024-09-08 23:16:50 +02:00
parent 542dbf0f97
commit e02de4daa5
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 56 additions and 58 deletions

View file

@ -6,8 +6,9 @@
</a>
</div>
Rentease is a property-management application to help landlords to manage your rental properties efficiently. With
Rentease, you can create invoices, generate activity reports, and sync all the booking platforms you use.
Rentease is a property-management application to help landlords to manage your rental
properties efficiently. With Rentease, you can create invoices, generate activity
reports, and sync all the booking platforms you use.
## Features
@ -15,7 +16,7 @@ Rentease, you can create invoices, generate activity reports, and sync all the b
- **Activity Reports**: Generate detailed reports of rental activities to keep track of your property performance.
- **Platform Sync**: Sync bookings across multiple platforms to streamline your rental management.
[![RentEase Screen Shot][product-screenshot]](https://example.com)
[![RentEase Screenshot][product-screenshot]](https://example.com)
## Getting Started
@ -23,10 +24,10 @@ To get started with Rentease, follow these steps.
### Prerequisites
You need a version of the Go programming language installed. You can either install it via your package manager or
via [Go's official website](https://go.dev/).
You also need a PostgreSQL database. You can install it locally using Homebrew or use a cloud alternative such as
Railway.
You need a version of the Go programming language installed. You can either install
it via your package manager or via [Go's official website](https://go.dev/).
You also need a PostgreSQL database. You can install it locally using Homebrew or
use a cloud alternative such as Railway, fly.io, _etc._.
### Installation
@ -82,16 +83,17 @@ Rentease is built using the following technologies:
## Roadmap
See the [open issues](https://github.com/users/rjNemo/projects/2/views/1) for a full list of proposed features (and
known issues).
See the [open issues](https://github.com/users/rjNemo/projects/2/views/1) for a full
list of proposed features (and known issues).
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any
contributions you make are **greatly appreciated**.
Contributions are what make the open source community such an amazing place to learn,
inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create
a pull request. You can also simply open an issue with the tag "enhancement".
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
1. Fork the Project
@ -103,7 +105,3 @@ Don't forget to give the project a star! Thanks again!
## License
Distributed under the MIT License. See `LICENSE.md` for more information.
## TODO
- [ ] other dates are not stored/parsed properly

View file

@ -5,7 +5,6 @@ import (
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type PgStore struct {
@ -101,43 +100,3 @@ func (ps *PgStore) Cancel(id int) error {
Update("canceled", true).
Error
}
// items
func (ps *PgStore) CreateItem(i *Item) error {
return ps.db.Create(i).Error
}
func (ps *PgStore) PayItem(id int) (*Item, error) {
i := new(Item)
if err := ps.db.Model(i).
Clauses(clause.Returning{}).
Where("id = ?", id).
Update("payment_status", "Completed").
Error; err != nil {
return nil, err
}
return i, nil
}
func (ps *PgStore) GetItem(id int) (*Item, error) {
i := &Item{Id: id}
err := ps.db.First(i).Error
return i, err
}
func (ps *PgStore) UpdateItem(id int, item string, paymentMethod string, paymentStatus string, qty int, price float64) (*Item, error) {
i := new(Item)
err := ps.db.Model(i).
Clauses(clause.Returning{}).
Where("id = ?", id).
Updates(map[string]any{
"item": item,
"payment_method": paymentMethod,
"payment_status": paymentStatus,
"quantity": qty,
"price": price,
}).
Error
return i, err
}

View file

@ -0,0 +1,41 @@
package booking
import "gorm.io/gorm/clause"
func (ps *PgStore) CreateItem(i *Item) error {
return ps.db.Create(i).Error
}
func (ps *PgStore) PayItem(id int) (*Item, error) {
i := new(Item)
if err := ps.db.Model(i).
Clauses(clause.Returning{}).
Where("id = ?", id).
Update("payment_status", "Completed").
Error; err != nil {
return nil, err
}
return i, nil
}
func (ps *PgStore) GetItem(id int) (*Item, error) {
i := &Item{Id: id}
err := ps.db.First(i).Error
return i, err
}
func (ps *PgStore) UpdateItem(id int, item string, paymentMethod string, paymentStatus string, qty int, price float64) (*Item, error) {
i := new(Item)
err := ps.db.Model(i).
Clauses(clause.Returning{}).
Where("id = ?", id).
Updates(map[string]any{
"item": item,
"payment_method": paymentMethod,
"payment_status": paymentStatus,
"quantity": qty,
"price": price,
}).
Error
return i, err
}