-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: paid subscriptions system and articles #467
Open
DioFun
wants to merge
84
commits into
master
Choose a base branch
from
subscriptions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
01e20d1
wip: begin of migration creation
DioFun 5a8e0df
feat: creating migration (work in progress)
benoitlx f76fb69
fix: relations that wasn't well defined, fixtures fix
DioFun fda8cd9
Remove user_id from subscription and get subscriptions through the sa…
DioFun 9f884e5
fix: through association was define after a call to it
DioFun 472b9a8
Add subscriptions modules routes
DioFun c82f46e
fix rubocop problems
DioFun 8956ebc
feat: creation and deletion of articles
DioFun 09e8c50
ref: change soft_delete! to soft_delete
DioFun a27935a
Deletion of subscriptions controller
DioFun 97ffc49
comment unusefull tests & try to fix those that did not passed
DioFun adbc98c
Comment outdated tests, fix existing that should pass
DioFun ffbccc5
fix: add locals
DioFun 6681798
fix: add locals
DioFun ca250bd
test: add some test and fix problems related
DioFun 66907ce
test: add more tests
DioFun b64f9ec
fix: let rails issue errors when trying to destroy a dependant article
DioFun 0e731a6
feat: manage subscription offers with tests impleted
DioFun 6d236ec
fix: mistake
DioFun 6ba8bd1
wip: sales implementation
DioFun 85f996d
wip: dynamically add articles to a sale using StimulusJS
nymous 4d14f17
wip: generate invoice pdf with hexapdf
D0gmaDev 518d6c6
wip: add subscription to sale
DioFun 152a8b5
fix(test): update fixtures regarding the column renaming of the last …
DioFun 2d9083e
feat(paymentMethods): add, remove payment methods
DioFun 5e49aef
wip: create sale, todo: implement invoice creation
DioFun 63a2e1d
refactor(subscription_offer&article): make new params shorter
DioFun 9692009
Merge branch 'master' into subscriptions
DioFun 7c24259
fix: fix rubocop outages
DioFun defe95b
Lock file up to date
DioFun 434a130
test(paymentMethod): add test for payment method controller and model
DioFun 58dff5c
test: add redirection assertion to Articles, Subscription offers and …
DioFun b1997a0
fix(locals): specify locals variable in partials
DioFun 48abb03
test(paymentMethod): fix should soft-delete payment_method
DioFun 368a182
feat(generate_invoices): return output as stream
D0gmaDev 28bd61c
Merge branch 'document_generator' into subscriptions
DioFun 4590d97
wip: sales invoices
DioFun c956e56
feat(sales): finish sale feature (need to be refactored)
DioFun eb89235
fix(saleForm): add event on select change
DioFun a0d683b
refactor(sales): refactor sales_creation
DioFun b9db1cd
fix(settingsFixture): add suitable parameters
DioFun d2391e9
refactor(sales): add default_scope for article, subscription_offer an…
DioFun e112313
fix(tests): fix tests broke by last commit & advised change in review
DioFun 4e2e840
fix(saleView): add min on duration field
DioFun fee752c
test: add a test for soft deletion & check deleted_at not nil for sof…
DioFun 06ad62e
fix(sales): fix sales reation
DioFun 12e32fd
refactor(invoiceSaleCreation): change name and place of the invoice h…
DioFun 6cae8a0
feat(subscriptions): create subscription on sale creation
DioFun 012f6bd
fix(invoices): multiple pages pdf
D0gmaDev 5b1bff1
fix(setting): rename last_invoice_id key to next_invoice_id
DioFun 8a5a714
refactor(sales): improve readability
D0gmaDev 6d3196f
test: write some invoice tests
D0gmaDev 74232b0
test(invoices): write generator service tests
D0gmaDev ef231da
test(articles_sales): create test for articles_sale model
DioFun a85b030
fix(sales): ensure duration is positive
D0gmaDev d7bbf2c
test(sales): start sales_controller tests
D0gmaDev 604b731
test(sales_controller): test if sales is not processable and duration…
DioFun 470c527
test(sales_controller): create test for invalid payment_method
DioFun 1768f59
fix(subscription): comment out cancel method
DioFun e5b05ec
test(sale): add test for sale model
DioFun 8894741
fix(subscription): comment out unuseful methods
DioFun 720c7d2
fix(sale): generate_sales_subscription_offers now returns true
DioFun 1a799a5
test(sale): test if subscription offers are not exhaustive
DioFun 97308cb
refactor: rework the sale and invoice flow
nymous 5a8745d
fix: add DB unique index to prevent duplicate ArticlesSales & show pr…
nymous 62a1671
chore: use create_join_table instead of manual tables
nymous f7612cc
fix: make duration and price strictly positive
nymous 1e45760
fix: remove total_price from sale/refund to compute it on the fly
nymous 9a89c40
refactor: make destroy/soft-delete more readable
nymous 30781cd
fix: improve sale subscription offer computation & docs
nymous 5e1cdc2
chore: remove unused comments
nymous 94969bd
ci: allow 'chore' commit type in overcommit
nymous a581ec2
fix: make Sale#total_price faster
nymous f32b650
docs: comment Sale.generate_sales_subscription_offers
nymous 941e461
chore: add DejaVu font license
nymous 26df468
fix: use number_to_currency instead of manual currency formatting
nymous c92c379
feat: protect Dashboard SQL queries with current user ability
nymous bc40946
feat: add frontend validation for article & subscription fields
nymous d786742
fix: automatically pluralize subscription 'months' duration
nymous 05f125a
fix: make invoice JSON not nullable
nymous 579bca7
test: make fixtures more realistic
nymous 3d6d1ab
fix: fix Rails not being able to delete many-to-many associations
nymous a755954
test: fix realistic fixtures to only have 1 article
nymous e825b68
test: fix sale setup to have new virtual attributes
nymous File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. | ||
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) | ||
|
||
|
||
Bitstream Vera Fonts Copyright | ||
------------------------------ | ||
|
||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is | ||
a trademark of Bitstream, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of the fonts accompanying this license ("Fonts") and associated | ||
documentation files (the "Font Software"), to reproduce and distribute the | ||
Font Software, including without limitation the rights to use, copy, merge, | ||
publish, distribute, and/or sell copies of the Font Software, and to permit | ||
persons to whom the Font Software is furnished to do so, subject to the | ||
following conditions: | ||
|
||
The above copyright and trademark notices and this permission notice shall | ||
be included in all copies of one or more of the Font Software typefaces. | ||
|
||
The Font Software may be modified, altered, or added to, and in particular | ||
the designs of glyphs or characters in the Fonts may be modified and | ||
additional glyphs or characters may be added to the Fonts, only if the fonts | ||
are renamed to names not containing either the words "Bitstream" or the word | ||
"Vera". | ||
|
||
This License becomes null and void to the extent applicable to Fonts or Font | ||
Software that has been modified and is distributed under the "Bitstream | ||
Vera" names. | ||
|
||
The Font Software may be sold as part of a larger software package but no | ||
copy of one or more of the Font Software typefaces may be sold by itself. | ||
|
||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, | ||
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME | ||
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING | ||
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | ||
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE | ||
FONT SOFTWARE. | ||
|
||
Except as contained in this notice, the names of Gnome, the Gnome | ||
Foundation, and Bitstream Inc., shall not be used in advertising or | ||
otherwise to promote the sale, use or other dealings in this Font Software | ||
without prior written authorization from the Gnome Foundation or Bitstream | ||
Inc., respectively. For further information, contact: fonts at gnome dot | ||
org. | ||
|
||
Arev Fonts Copyright | ||
------------------------------ | ||
|
||
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of the fonts accompanying this license ("Fonts") and | ||
associated documentation files (the "Font Software"), to reproduce | ||
and distribute the modifications to the Bitstream Vera Font Software, | ||
including without limitation the rights to use, copy, merge, publish, | ||
distribute, and/or sell copies of the Font Software, and to permit | ||
persons to whom the Font Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright and trademark notices and this permission notice | ||
shall be included in all copies of one or more of the Font Software | ||
typefaces. | ||
|
||
The Font Software may be modified, altered, or added to, and in | ||
particular the designs of glyphs or characters in the Fonts may be | ||
modified and additional glyphs or characters may be added to the | ||
Fonts, only if the fonts are renamed to names not containing either | ||
the words "Tavmjong Bah" or the word "Arev". | ||
|
||
This License becomes null and void to the extent applicable to Fonts | ||
or Font Software that has been modified and is distributed under the | ||
"Tavmjong Bah Arev" names. | ||
|
||
The Font Software may be sold as part of a larger software package but | ||
no copy of one or more of the Font Software typefaces may be sold by | ||
itself. | ||
|
||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT | ||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL | ||
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL | ||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM | ||
OTHER DEALINGS IN THE FONT SOFTWARE. | ||
|
||
Except as contained in this notice, the name of Tavmjong Bah shall not | ||
be used in advertising or otherwise to promote the sale, use or other | ||
dealings in this Font Software without prior written authorization | ||
from Tavmjong Bah. For further information, contact: tavmjong @ free | ||
. fr. | ||
|
||
TeX Gyre DJV Math | ||
----------------- | ||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. | ||
|
||
Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski | ||
(on behalf of TeX users groups) are in public domain. | ||
|
||
Letters imported from Euler Fraktur from AMSfonts are (c) American | ||
Mathematical Society (see below). | ||
Bitstream Vera Fonts Copyright | ||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera | ||
is a trademark of Bitstream, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of the fonts accompanying this license (“Fonts”) and associated | ||
documentation | ||
files (the “Font Software”), to reproduce and distribute the Font Software, | ||
including without limitation the rights to use, copy, merge, publish, | ||
distribute, | ||
and/or sell copies of the Font Software, and to permit persons to whom | ||
the Font Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright and trademark notices and this permission notice | ||
shall be | ||
included in all copies of one or more of the Font Software typefaces. | ||
|
||
The Font Software may be modified, altered, or added to, and in particular | ||
the designs of glyphs or characters in the Fonts may be modified and | ||
additional | ||
glyphs or characters may be added to the Fonts, only if the fonts are | ||
renamed | ||
to names not containing either the words “Bitstream” or the word “Vera”. | ||
|
||
This License becomes null and void to the extent applicable to Fonts or | ||
Font Software | ||
that has been modified and is distributed under the “Bitstream Vera” | ||
names. | ||
|
||
The Font Software may be sold as part of a larger software package but | ||
no copy | ||
of one or more of the Font Software typefaces may be sold by itself. | ||
|
||
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, | ||
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME | ||
FOUNDATION | ||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, | ||
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN | ||
ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR | ||
INABILITY TO USE | ||
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. | ||
Except as contained in this notice, the names of GNOME, the GNOME | ||
Foundation, | ||
and Bitstream Inc., shall not be used in advertising or otherwise to promote | ||
the sale, use or other dealings in this Font Software without prior written | ||
authorization from the GNOME Foundation or Bitstream Inc., respectively. | ||
For further information, contact: fonts at gnome dot org. | ||
|
||
AMSFonts (v. 2.2) copyright | ||
|
||
The PostScript Type 1 implementation of the AMSFonts produced by and | ||
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely | ||
available for general use. This has been accomplished through the | ||
cooperation | ||
of a consortium of scientific publishers with Blue Sky Research and Y&Y. | ||
Members of this consortium include: | ||
|
||
Elsevier Science IBM Corporation Society for Industrial and Applied | ||
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS) | ||
|
||
In order to assure the authenticity of these fonts, copyright will be | ||
held by | ||
the American Mathematical Society. This is not meant to restrict in any way | ||
the legitimate use of the fonts, such as (but not limited to) electronic | ||
distribution of documents containing these fonts, inclusion of these fonts | ||
into other public domain or commercial font collections or computer | ||
applications, use of the outline data to create derivative fonts and/or | ||
faces, etc. However, the AMS does require that the AMS copyright notice be | ||
removed from any derivative versions of the fonts which have been altered in | ||
any way. In addition, to ensure the fidelity of TeX documents using Computer | ||
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces, | ||
has requested that any alterations which yield different font metrics be | ||
given a different name. | ||
|
||
$Id$ |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
# Do NOT implement edit/update methods, we want to keep | ||
# articles immutable. | ||
# If you want to edit an article, create a new one and | ||
# soft-delete the other. | ||
class ArticlesController < ApplicationController | ||
def new | ||
@article = Article.new | ||
authorize! :new, @article | ||
end | ||
|
||
def create | ||
@article = Article.new(article_params) | ||
authorize! :create, @article | ||
if @article.save | ||
flash[:success] = "Article #{article_params[:name]} created!" | ||
redirect_to admin_path | ||
else | ||
render 'new', status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@article = Article.find(params[:id]) | ||
authorize! :destroy, @article | ||
# Try to destroy (if there is no associated sale/refund), | ||
# else soft-delete to keep current sales immutable (not | ||
# change article price on past sales) | ||
@article.destroy or @article.soft_delete | ||
redirect_to admin_path | ||
end | ||
|
||
def article_params | ||
params.require(:article).permit(:price, :name) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class DashboardController < ApplicationController | ||
def index | ||
authorize! :manage, :all # TODO: use finer grained permissions | ||
@articles = Article.accessible_by(current_ability).order(created_at: :desc) | ||
@subscription_offers = SubscriptionOffer.accessible_by(current_ability).order(created_at: :desc) | ||
@payment_methods = PaymentMethod.accessible_by(current_ability).order(created_at: :desc) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
# Do NOT implement edit/update methods, we want to keep | ||
# payment methods immutable. | ||
# If you want to edit a payment method, create a new one and | ||
# soft-delete the other. | ||
class PaymentMethodsController < ApplicationController | ||
def new | ||
@payment_method = PaymentMethod.new | ||
authorize! :new, @payment_method | ||
end | ||
|
||
def create | ||
@payment_method = PaymentMethod.new(payment_method_params) | ||
authorize! :create, @payment_method | ||
if @payment_method.save | ||
flash[:success] = "Payment method #{payment_method_params[:name]} created!" | ||
redirect_to admin_path | ||
else | ||
render 'new', status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@payment_method = PaymentMethod.find(params[:id]) | ||
authorize! :destroy, @payment_method | ||
# Try to destroy (if there is no associated sale/refund), | ||
# else soft-delete to keep current sales immutable (not | ||
# change payment method on past sales) | ||
@payment_method.destroy or @payment_method.soft_delete | ||
redirect_to admin_path | ||
end | ||
|
||
def payment_method_params | ||
params.require(:payment_method).permit(:name, :auto_verify) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we receive the price as a "human" number (5.00 €), we need to multiply it here to get cents or else the validation will not be happy with a float.