-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bfc9506
Showing
24 changed files
with
1,506 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"pluginName":"Money","pluginDescription":"Money Fieldtype for CraftCMS v3","pluginVersion":"1.0.0","pluginAuthorName":"Leevi Graham","pluginVendorName":"newism","pluginAuthorUrl":"https://newism.com.au","pluginAuthorGithub":"newism","codeComments":"yes","pluginComponents":["fieldtypes"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"Money","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} |
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,32 @@ | ||
# CRAFT ENVIRONMENT | ||
.env.php | ||
.env.sh | ||
.env | ||
|
||
# COMPOSER | ||
/vendor | ||
|
||
# BUILD FILES | ||
/bower_components/* | ||
/node_modules/* | ||
/build/* | ||
/yarn-error.log | ||
|
||
# MISC FILES | ||
.cache | ||
.DS_Store | ||
.idea | ||
.project | ||
.settings | ||
*.esproj | ||
*.sublime-workspace | ||
*.sublime-project | ||
*.tmproj | ||
*.tmproject | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
config.codekit3 | ||
prepros-6.config |
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,9 @@ | ||
# Money Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## 1.0.0 - 2020-05-09 | ||
### Added | ||
- Initial release |
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,40 @@ | ||
Copyright © Newism Pty Ltd | ||
|
||
Permission is hereby granted to any person obtaining a copy of this software | ||
(the “Software”) to use, copy, modify, merge, publish and/or distribute copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
1. **Don’t plagiarize.** The above copyright notice and this license shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
2. **Don’t use the same license on more than one project.** Each licensed copy | ||
of the Software shall be actively installed in no more than one production | ||
environment at a time. | ||
|
||
3. **Don’t mess with the licensing features.** Software features related to | ||
licensing shall not be altered or circumvented in any way, including (but | ||
not limited to) license validation, payment prompts, feature restrictions, | ||
and update eligibility. | ||
|
||
4. **Pay up.** Payment shall be made immediately upon receipt of any notice, | ||
prompt, reminder, or other message indicating that a payment is owed. | ||
|
||
5. **Follow the law.** All use of the Software shall not violate any applicable | ||
law or regulation, nor infringe the rights of any other person or entity. | ||
|
||
Failure to comply with the foregoing conditions will automatically and | ||
immediately result in termination of the permission granted hereby. This | ||
license does not include any right to receive updates to the Software or | ||
technical support. Licensees bear all risk related to the quality and | ||
performance of the Software and any modifications made or obtained to it, | ||
including liability for actual and consequential harm, such as loss or | ||
corruption of data, and any necessary service, repair, or correction. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER | ||
LIABILITY, INCLUDING SPECIAL, INCIDENTAL AND CONSEQUENTIAL DAMAGES, WHETHER IN | ||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,114 @@ | ||
# Money plugin for Craft CMS 3.x | ||
|
||
![in action](resources/img/in-action.gif) | ||
|
||
![site settings](resources/img/site-settings.png) | ||
|
||
## Requirements | ||
|
||
This plugin requires Craft CMS 3.5.0 or later. | ||
|
||
## Installation | ||
|
||
To install the plugin, follow these instructions. | ||
|
||
1. Open your terminal and go to your Craft project: | ||
|
||
```console | ||
$ cd /path/to/project | ||
``` | ||
|
||
2. Then tell Composer to load the plugin: | ||
|
||
```console | ||
$ composer require newism/craft3-money | ||
``` | ||
|
||
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Money or run | ||
|
||
```console | ||
$ ./craft plugin/install money | ||
``` | ||
|
||
## Money Overview | ||
|
||
Money is a custom field type and formatter that uses the [moneyphp/money](https://github.com/moneyphp/money) library. Values are stored as json in the database and normalized as a [Money](https://github.com/moneyphp/money/blob/master/src/Money.php) Value Object. | ||
|
||
Currencies are loaded from the [moneyphp/money](https://github.com/moneyphp/money) library. A full list can be found here: https://github.com/moneyphp/money/blob/master/resources/currency.php | ||
|
||
This plugin also loads in `symfony/intl` for currency names. | ||
|
||
## Configuring Money | ||
|
||
Money has two levels of configuration: | ||
|
||
* Site settings using a config file or plugin settings | ||
* Field settings | ||
|
||
*Note: Field settings are appended to Site settings.* | ||
|
||
The two settings are: | ||
|
||
* Preferred currencies: These currencies are displayed first in the currency drop down. | ||
* Excluded currencies: These currencies are excluded from the currency drop down. | ||
|
||
Both settings accept a comma delimited list of alphabetical currency codes. | ||
|
||
It's recommended that you exclude the following currencies: `XBA, XBB, XBC, XBD, XTS, XXX, XAU, XPD, XPT, XAG` | ||
|
||
To use a config file see [./src/config.php](./src/config.php). | ||
|
||
## Using Money | ||
|
||
This plugin includes a service for rendering the field value. | ||
|
||
Note: In the three methods below `value` must be an instance of `Money`. The examples use the ['Elvis Operator'](https://twig.symfony.com/doc/3.x/templates.html#other-operators). | ||
|
||
### International formatter | ||
|
||
{{ value ? craft.money.intlFormatter.format(value) }} | ||
|
||
# or explicitly define the locale | ||
{{ value ? craft.money.getIntlFormatter(locale).format(value) }} | ||
|
||
The `intlFormatter` returns a `[IntlMoneyFormatter](http://moneyphp.org/en/stable/features/formatting.html#intl-money-formatter)` object. This formatter requires the intl extension. | ||
|
||
Calling `.format()` will return a string with the currency symbol in a format that matches `locale`. Separators will also match the locale. | ||
|
||
`locale` is an optional parameter and falls back to the locale defined by Craft: `\Craft::$app->locale->id` | ||
|
||
See: http://moneyphp.org/en/stable/features/formatting.html#intl-money-formatter | ||
|
||
### International Decimal Formatter | ||
|
||
{{ value ? craft.money.intlDecimalFormatter.format(value) }} | ||
|
||
# or explicitly define the locale | ||
{{ value ? craft.money.getIntlDecimalFormatter(locale).format(value) }} | ||
|
||
Outputs the same as above without the currency symbol. | ||
|
||
See: http://moneyphp.org/en/stable/features/formatting.html#intl-decimal-formatter | ||
|
||
### Decimal Formatter | ||
|
||
{{ value ? craft.money.decimalFormatter.format(value) }} | ||
|
||
This formatter outputs a simple decimal string which is always in a consistent format independent of locale. | ||
|
||
## Money Roadmap | ||
|
||
Some things to do, and ideas for potential features: | ||
|
||
* Test multiple versions of PHP | ||
* Review the usage of `symfony/intl` for currency names | ||
* Write tests | ||
* Check GraphQL output | ||
* Add localised strings for plugin ui | ||
* Release it | ||
|
||
## Credits | ||
|
||
Brought to you by [Newism](http://newism.com.au) | ||
|
||
[<img src="./resources/img/icon.svg" width="100px" />](http://newism.com.au/) |
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,46 @@ | ||
{ | ||
"name": "newism/craft3-money", | ||
"description": "Money Fieldtype for CraftCMS v3", | ||
"type": "craft-plugin", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"craft", | ||
"cms", | ||
"craftcms", | ||
"craft-plugin", | ||
"money" | ||
], | ||
"support": { | ||
"docs": "https://github.com/newism/craft3-money/blob/master/README.md", | ||
"issues": "https://github.com/newism/craft3-money/issues" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Leevi Graham", | ||
"homepage": "https://newism.com.au" | ||
} | ||
], | ||
"require": { | ||
"craftcms/cms": "^3.4.0", | ||
"moneyphp/money": "^3.3", | ||
"symfony/intl": "^5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"newism\\money\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"name": "Money", | ||
"handle": "money", | ||
"developer": "Leevi Graham", | ||
"developerUrl": "https://newism.com.au", | ||
"documentationUrl": "https://github.com/newism/money/blob/master/README.md", | ||
"changelogUrl": "https://raw.githubusercontent.com/newism/money/master/CHANGELOG.md", | ||
"components": { | ||
"money": "MoneyService" | ||
}, | ||
"class": "newism\\money\\Plugin" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.