diff --git a/README.md b/README.md index f37011b..e7e2ea6 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ -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 diff --git a/internal/booking/store.go b/internal/booking/booking_store.go similarity index 71% rename from internal/booking/store.go rename to internal/booking/booking_store.go index b2e0d1c..52fce1a 100644 --- a/internal/booking/store.go +++ b/internal/booking/booking_store.go @@ -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 -} diff --git a/internal/booking/item_store.go b/internal/booking/item_store.go new file mode 100644 index 0000000..4d68841 --- /dev/null +++ b/internal/booking/item_store.go @@ -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 +}