From 185a10ce4c90416bac4bb2a9c855cce169fbd675 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sat, 30 Dec 2017 16:16:47 +0100 Subject: [PATCH 1/9] Fix rendering of the infinity symbol Returning \u221E instead would have worked instead: it would have rendered an actual infinity sign client side. I was a bit more comfortable with rendering ∞ client side instead, but either works fine on all browsers I've tested. Also, there are many ways to render raw output, see: http://mrhaki.blogspot.nl/2013/11/grails-goodness-generating-raw-output.html --- grails-app/views/rendement/_rendement.gsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grails-app/views/rendement/_rendement.gsp b/grails-app/views/rendement/_rendement.gsp index f52728c..cd03445 100644 --- a/grails-app/views/rendement/_rendement.gsp +++ b/grails-app/views/rendement/_rendement.gsp @@ -13,7 +13,7 @@ ${r.product.naam} ${r.aantalIngekocht} ${r.aantalBesteld} - ${r.percentage} + ${raw(r.percentage)} @@ -21,6 +21,6 @@ Totaal ${it.totaalIngekocht} ${it.totaalBesteld} - ${it.totalPercentage} + ${raw(it.totalPercentage)} \ No newline at end of file From c8ce26814cc9ebb4c07686bab0f5e505486fb798 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sat, 30 Dec 2017 16:46:16 +0100 Subject: [PATCH 2/9] Rename change message key .title to .defaulttitle This makes it more obvious it's the default (it can be changed in the settings) --- grails-app/i18n/messages_nl.properties | 4 ++-- grails-app/services/stampos/SettingsService.groovy | 4 ++-- test/unit/stampos/SettingsServiceSpec.groovy | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grails-app/i18n/messages_nl.properties b/grails-app/i18n/messages_nl.properties index 0729118..8d6334c 100644 --- a/grails-app/i18n/messages_nl.properties +++ b/grails-app/i18n/messages_nl.properties @@ -55,10 +55,10 @@ typeMismatch.java.math.BigDecimal=Attribuut {0} is geen geldig nummer typeMismatch.java.math.BigInteger=Attribuut {0} is geen geldig nummer -mail.insufficientfunds.title=Je rekening moet betaald worden +mail.insufficientfunds.defaulttitle=Je rekening moet betaald worden mail.insufficientfunds.message=Hallo {0},\n\nJe hebt een rekening van {1} euro. Maak daarom minimaal dit bedrag over op rekening van {2} op naam van {3}. -mail.sufficientfunds.title=Je tegoed is %s +mail.sufficientfunds.defaulttitle=Je tegoed is %s mail.sufficientfunds.message=Hallo {0},\n\nJe hebt een tegoed van {1} euro. Als je je tegoed wilt aanvullen kan dit door middel van geld over te maken op rekening {2} op naam van {3}. mail.funds.footer=\n\nMet vriendelijke groeten,\n\n\nHet barteam\n\nJe bestellingen en betalingen diff --git a/grails-app/services/stampos/SettingsService.groovy b/grails-app/services/stampos/SettingsService.groovy index cc1c280..3e09518 100644 --- a/grails-app/services/stampos/SettingsService.groovy +++ b/grails-app/services/stampos/SettingsService.groovy @@ -322,7 +322,7 @@ class SettingsService { def getSufficientFundsTitleValue() { - def defaultMessage = messageSource.getMessage('mail.sufficientfunds.title', null, Locale.default) + def defaultMessage = messageSource.getMessage('mail.sufficientfunds.defaulttitle', null, Locale.default) return getSetting(S_SUFFICIENT_FUNDS_TITLE, defaultMessage) } @@ -338,7 +338,7 @@ class SettingsService { def getInsufficientFundsTitleValue() { - def defaultMessage = messageSource.getMessage('mail.insufficientfunds.title', null, Locale.default) + def defaultMessage = messageSource.getMessage('mail.insufficientfunds.defaulttitle', null, Locale.default) return getSetting(S_INSUFFICIENT_FUNDS_TITLE, defaultMessage) } diff --git a/test/unit/stampos/SettingsServiceSpec.groovy b/test/unit/stampos/SettingsServiceSpec.groovy index 3bfd4d0..5f00d09 100644 --- a/test/unit/stampos/SettingsServiceSpec.groovy +++ b/test/unit/stampos/SettingsServiceSpec.groovy @@ -30,7 +30,7 @@ class SettingsServiceSpec extends Specification { void "test title sufficient funds default"() { given: when: - messageSource.addMessage("mail.sufficientfunds.title", Locale.default, "Your credit: %s") + messageSource.addMessage("mail.sufficientfunds.defaulttitle", Locale.default, "Your credit: %s") then: assertEquals("Your credit: \u20AC2,20", service.getSufficientFundsTitle(2.2)) } @@ -38,7 +38,7 @@ class SettingsServiceSpec extends Specification { void "test title sufficient funds set"() { given: when: - messageSource.addMessage("mail.sufficientfunds.title", Locale.default, "Your credit: %s") + messageSource.addMessage("mail.sufficientfunds.defaulttitle", Locale.default, "Your credit: %s") service.setSufficientFundsTitle("Due: %s") then: @@ -48,7 +48,7 @@ class SettingsServiceSpec extends Specification { void "test title insufficient funds default"() { given: when: - messageSource.addMessage("mail.insufficientfunds.title", Locale.default, "Your debit: %s") + messageSource.addMessage("mail.insufficientfunds.defaulttitle", Locale.default, "Your debit: %s") then: assertEquals("Your debit: \u20AC2,20", service.getInsufficientFundsTitle(2.2)) } @@ -56,7 +56,7 @@ class SettingsServiceSpec extends Specification { void "test title insufficient funds set"() { given: when: - messageSource.addMessage("mail.insufficientfunds.title", Locale.default, "Your debit: %s") + messageSource.addMessage("mail.insufficientfunds.defaulttitle", Locale.default, "Your debit: %s") service.setInsufficientFundsTitle("To pay: %s") then: From 423595aaa018bf615b4539928f476ddabe90b5fa Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sat, 30 Dec 2017 22:35:36 +0100 Subject: [PATCH 3/9] Group rendement stuff together --- grails-app/views/beheer/index.gsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grails-app/views/beheer/index.gsp b/grails-app/views/beheer/index.gsp index c6e9d81..d1eaa82 100644 --- a/grails-app/views/beheer/index.gsp +++ b/grails-app/views/beheer/index.gsp @@ -120,9 +120,9 @@
Bestellingen en betalingen van klanten
Deblokkeer klanten
+
Registreer inkopen
Tel de inhoud van de bar
-
Rendement van de bar (schatting nav inkopen)
Rendement van de bar (nav telling)

From 3ff339def9f93016aa5868fdacc0a457d4eff885 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sat, 30 Dec 2017 22:36:46 +0100 Subject: [PATCH 4/9] Implement overview screen (it isn't weekly yet) --- .../stampos/WeeklyController.groovy | 17 ++++++ grails-app/views/beheer/klantoverzicht.gsp | 1 + grails-app/views/weekly/index.gsp | 56 +++++++++++++++++++ test/unit/stampos/WeeklyControllerSpec.groovy | 20 +++++++ 4 files changed, 94 insertions(+) create mode 100644 grails-app/controllers/stampos/WeeklyController.groovy create mode 100644 grails-app/views/weekly/index.gsp create mode 100644 test/unit/stampos/WeeklyControllerSpec.groovy diff --git a/grails-app/controllers/stampos/WeeklyController.groovy b/grails-app/controllers/stampos/WeeklyController.groovy new file mode 100644 index 0000000..dfcd1c3 --- /dev/null +++ b/grails-app/controllers/stampos/WeeklyController.groovy @@ -0,0 +1,17 @@ +package stampos + +class WeeklyController { + + def index() + { + def besteld = BestelRegel.executeQuery("select br.productPrijs.product.naam, sum(br.aantal), sum(br.aantal * br.productPrijs.prijs) from BestelRegel br group by br.productPrijs.product.naam") + boolean noData = besteld.isEmpty() + int totalAmount = 0 + BigDecimal totalRevenue = 0 + for(b in besteld) { + totalAmount += b[1] + totalRevenue += b[2] + } + return [noData: noData, besteld: besteld, totalAmount: totalAmount, totalRevenue: totalRevenue] + } +} diff --git a/grails-app/views/beheer/klantoverzicht.gsp b/grails-app/views/beheer/klantoverzicht.gsp index 646eb73..01182d0 100644 --- a/grails-app/views/beheer/klantoverzicht.gsp +++ b/grails-app/views/beheer/klantoverzicht.gsp @@ -6,6 +6,7 @@ Bestellingen en betalingen van alle klanten
+ Bestellingen en betalingen per week

Bestellingen en betalingen van klanten

diff --git a/grails-app/views/weekly/index.gsp b/grails-app/views/weekly/index.gsp new file mode 100644 index 0000000..3fce67e --- /dev/null +++ b/grails-app/views/weekly/index.gsp @@ -0,0 +1,56 @@ +<%@page import="stampos.NumberUtils"%> + + + + + + Besteld en betaald + + +

Besteld en betaald

+ + + Er is niets besteld of betaald in deze periode + + + + + + + + + + + + + + + + + + + + + + +
ProductBesteldOmzet
${b[0]}${b[1]}${NumberUtils.formatMoney(b[2])}
Totaal${totalAmount}${NumberUtils.formatMoney(totalRevenue)}
+
+ + \ No newline at end of file diff --git a/test/unit/stampos/WeeklyControllerSpec.groovy b/test/unit/stampos/WeeklyControllerSpec.groovy new file mode 100644 index 0000000..0d567f7 --- /dev/null +++ b/test/unit/stampos/WeeklyControllerSpec.groovy @@ -0,0 +1,20 @@ +package stampos + +import grails.test.mixin.TestFor +import spock.lang.Specification + +/** + * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions + */ +@TestFor(WeeklyController) +class WeeklyControllerSpec extends Specification { + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + } +} From b884371835927f095835630705f5b6d7fe43c514 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sat, 30 Dec 2017 23:28:44 +0100 Subject: [PATCH 5/9] Add support for viewing payments and only view 1 week --- .../stampos/WeeklyController.groovy | 25 ++++++++--- grails-app/views/weekly/index.gsp | 42 +++++++++++++++---- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/grails-app/controllers/stampos/WeeklyController.groovy b/grails-app/controllers/stampos/WeeklyController.groovy index dfcd1c3..f8125c9 100644 --- a/grails-app/controllers/stampos/WeeklyController.groovy +++ b/grails-app/controllers/stampos/WeeklyController.groovy @@ -4,14 +4,27 @@ class WeeklyController { def index() { - def besteld = BestelRegel.executeQuery("select br.productPrijs.product.naam, sum(br.aantal), sum(br.aantal * br.productPrijs.prijs) from BestelRegel br group by br.productPrijs.product.naam") - boolean noData = besteld.isEmpty() + def now = new Date() + def aWeekAgo = now - 7 + + def ordered = BestelRegel.executeQuery("select br.productPrijs.product.naam, sum(br.aantal), sum(br.aantal * br.productPrijs.prijs) from BestelRegel br where br.bestelling.datum > :dateFrom and br.bestelling.datum < :dateTo group by br.productPrijs.product.naam", + [dateFrom: aWeekAgo, dateTo: now]) + boolean nothingOrdered = ordered.isEmpty() int totalAmount = 0 BigDecimal totalRevenue = 0 - for(b in besteld) { - totalAmount += b[1] - totalRevenue += b[2] + for(o in ordered) { + totalAmount += o[1] + totalRevenue += o[2] } - return [noData: noData, besteld: besteld, totalAmount: totalAmount, totalRevenue: totalRevenue] + + def paid = Betaling.findAllByDatumGreaterThanAndDatumLessThan(aWeekAgo, now) + + def nothingPaid = paid.isEmpty() + BigDecimal totalPaid = 0 + for(p in paid) { + totalPaid += p.bedrag + } + + return [nothingOrdered: nothingOrdered, ordered: ordered, totalAmount: totalAmount, totalRevenue: totalRevenue, nothingPaid: nothingPaid, totalPaid: totalPaid, paid: paid] } } diff --git a/grails-app/views/weekly/index.gsp b/grails-app/views/weekly/index.gsp index 3fce67e..f0bf9a7 100644 --- a/grails-app/views/weekly/index.gsp +++ b/grails-app/views/weekly/index.gsp @@ -24,12 +24,12 @@ Besteld en betaald -

Besteld en betaald

+

Besteld

- - Er is niets besteld of betaald in deze periode + + Er is niets besteld in deze periode - + @@ -37,11 +37,11 @@ - + - - - + + + @@ -52,5 +52,31 @@
ProductOmzet
${b[0]}${b[1]}${NumberUtils.formatMoney(b[2])}${o[0]}${o[1]}${NumberUtils.formatMoney(o[2])}
+ +

Betaald

+ + + Er zijn been betalingen in deze periode + + + + + + + + + + + + + + + + + + + +
NaamBetaald
${p.klant.naam}${NumberUtils.formatMoney(p.bedrag)}
Totaal${NumberUtils.formatMoney(totalPaid)}
+
\ No newline at end of file From d5308ec4191f3d790f9a139252be2d6341a846f5 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 31 Dec 2017 01:02:14 +0100 Subject: [PATCH 6/9] Remove useless DateFormats --- grails-app/controllers/stampos/KlantinfoController.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/grails-app/controllers/stampos/KlantinfoController.groovy b/grails-app/controllers/stampos/KlantinfoController.groovy index 6c77862..416eb41 100644 --- a/grails-app/controllers/stampos/KlantinfoController.groovy +++ b/grails-app/controllers/stampos/KlantinfoController.groovy @@ -9,8 +9,6 @@ import grails.converters.JSON class KlantinfoController { private static final maxItems = 15; - static DateFormat bestellingFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm") - static DateFormat betalingFormat = new SimpleDateFormat("dd-MM-yyyy") def testDataService def klantInfoService From 57210f27d0b5f655b1ffe0045e18e5491bab2f61 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 31 Dec 2017 01:07:27 +0100 Subject: [PATCH 7/9] Print the applicable dates and fix the next button showing up after navigating moving previous and then back --- .../stampos/WeeklyController.groovy | 41 ++++++++++++++----- grails-app/views/weekly/index.gsp | 8 ++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/grails-app/controllers/stampos/WeeklyController.groovy b/grails-app/controllers/stampos/WeeklyController.groovy index f8125c9..a2b0c11 100644 --- a/grails-app/controllers/stampos/WeeklyController.groovy +++ b/grails-app/controllers/stampos/WeeklyController.groovy @@ -1,14 +1,19 @@ package stampos +import java.text.DateFormat +import java.text.SimpleDateFormat + class WeeklyController { + + static DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy") - def index() - { - def now = new Date() - def aWeekAgo = now - 7 - - def ordered = BestelRegel.executeQuery("select br.productPrijs.product.naam, sum(br.aantal), sum(br.aantal * br.productPrijs.prijs) from BestelRegel br where br.bestelling.datum > :dateFrom and br.bestelling.datum < :dateTo group by br.productPrijs.product.naam", - [dateFrom: aWeekAgo, dateTo: now]) + def index() { + Date today = new Date().clearTime() + Date endDate = params.endDate ? new Date(params.endDate as long) : today + Date beginDate = params.beginDate ? new Date(params.beginDate as long) : endDate - 7 + + def ordered = BestelRegel.executeQuery("select br.productPrijs.product.naam, sum(br.aantal), sum(br.aantal * br.productPrijs.prijs) from BestelRegel br where br.bestelling.datum > :dateFrom and br.bestelling.datum < :dateTo group by br.productPrijs.product.naam", + [dateFrom: beginDate, dateTo: endDate]) boolean nothingOrdered = ordered.isEmpty() int totalAmount = 0 BigDecimal totalRevenue = 0 @@ -16,15 +21,29 @@ class WeeklyController { totalAmount += o[1] totalRevenue += o[2] } - - def paid = Betaling.findAllByDatumGreaterThanAndDatumLessThan(aWeekAgo, now) - + + def paid = Betaling.findAllByDatumGreaterThanAndDatumLessThan(beginDate, endDate) + def nothingPaid = paid.isEmpty() BigDecimal totalPaid = 0 for(p in paid) { totalPaid += p.bedrag } - return [nothingOrdered: nothingOrdered, ordered: ordered, totalAmount: totalAmount, totalRevenue: totalRevenue, nothingPaid: nothingPaid, totalPaid: totalPaid, paid: paid] + return [ + nothingOrdered: nothingOrdered, + ordered: ordered, + totalAmount: totalAmount, + totalRevenue: totalRevenue, + nothingPaid: nothingPaid, + totalPaid: totalPaid, + paid: paid, + beginDateFormatted: dateFormat.format(beginDate), + endDateFormatted: dateFormat.format(endDate), + previousBeginDate: (beginDate - 7).getTime(), + previousEndDate: (endDate - 7).getTime(), + nextBeginDate: (beginDate + 7).getTime(), + nextEndDate: (endDate + 7).getTime(), + shouldShowLinkToNextWeek: endDate < today] } } diff --git a/grails-app/views/weekly/index.gsp b/grails-app/views/weekly/index.gsp index f0bf9a7..6481e79 100644 --- a/grails-app/views/weekly/index.gsp +++ b/grails-app/views/weekly/index.gsp @@ -24,6 +24,14 @@ Besteld en betaald +
+ Vorige week + + ${beginDateFormatted} - ${endDateFormatted} + + Volgende week + +

Besteld

From b29f4bf8b6d9b258ae5d95326f3c0775e30c8c5d Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 31 Dec 2017 01:29:27 +0100 Subject: [PATCH 8/9] Add installing info to the readme --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 188c26d..852c67e 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,23 @@ This is a bar system designed for venues where you know your customers. It has t - Drastically reduce the amount of money your customers owe you - Automate the administrative tasks of running a bar as much as possible -# User friendly +## User friendly Click on your name, click on the products you want to order, press "Confirm" and you're all set. It can't get much more user friendly than this. -# Reduces the amount your customers owe you +## Reduces the amount your customers owe you In most systems, people start with 0 debt to the bar, and with every drink, this increases. Then after a while, people pay their debt and they have 0 again. This means that in any point in time, the bar is owed quite a bit of money. In StamPOS, this works differently: people are expected to have credit with the bar. When they run out, they will be blocked, they can only order during the same weekend, but that's it. They could just pay their bill, but that means they can only order for 1 weekend again. It's handier for your customers to wire more money than they actually owe, so they can order for more than just 1 weekend. In the off chance a customer hasn't paid, but bar personell still wants to allow ordering for him/her, there's an unblock functionality. -# Automate administrative tasks +## Automates administrative tasks The following is automated: - Sending an e-mail to all applicable users with their balance with the bar - Determine which users have paid and which amount (using an export of internet banking) - Sending a weekly e-mail to the owner of the bar with a backup of the database and a list of all users and their balance + +# Installing +- Download and install Tomcat 8. For most convenience, set the port number to 80 +- Download [the latest version of StamPOS](https://github.com/cristan/stampos/releases/latest), rename it to ROOT.war and deploy it to Tomcat. You can do this by placing it in /webapps in the Tomcat installation directory, or by using the built-in manager. +- Go to [localhost](http://localhost) to see your installation :) \ No newline at end of file From b14b9fb49b48debc0654eb163227e225db878185 Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Sun, 31 Dec 2017 01:35:40 +0100 Subject: [PATCH 9/9] Bump version to 2.9.0 --- application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.properties b/application.properties index a28280b..e44b407 100644 --- a/application.properties +++ b/application.properties @@ -3,4 +3,4 @@ app.grails.version=2.5.5 app.name=StamPOS app.servlet.version=3.0 -app.version=2.8.1 +app.version=2.9.0