Skip to content

Commit

Permalink
Merge pull request #2 from siwapp/master
Browse files Browse the repository at this point in the history
update to latest codebase
  • Loading branch information
JMCA2 authored Dec 17, 2016
2 parents 9d94e26 + 79bae96 commit cd3e100
Show file tree
Hide file tree
Showing 64 changed files with 611 additions and 225 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cache:
- $HOME/.composer/cache

php:
- '5.6'
- '7.0'
- '7.1'

Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@

## Installation

The following will ask you to setup the database info, so make sure you have one
ready.
Make sure you have [composer](https://getcomposer.org/) installed.
Then run the following (it will ask you for database info, so make sure you have one ready):

$ composer create-project --stability=dev siwapp/siwapp-sf3 my_siwapp; cd my_siwapp

You will need to have Java installed and available in your path (for yuicompressor).
On Debian/Ubuntu-based systems you can install it using the following:

$ sudo apt-get install default-jre-headless

Then you can dump the assets:

$ php bin/console assetic:dump --env=prod
Expand Down Expand Up @@ -92,6 +87,8 @@ Just add a cronjob that runs `php bin/console siwapp:recurring:generate-pending`

### Interface language

To have the siwapp interface in another language you will need the php intl extension installed.
Then visit your profile page, change your locale and then log out. When you log back in the interface language should be switched.
To have the siwapp interface in another language you will need the php-intl extension installed.

Visit your profile page, change your locale and then log out. When you log back in the interface language should be switched.

Siwapp is translated only to Spanish for now, feel free to contribute more translations!
Binary file removed app/Resources/java/yuicompressor-2.4.7.jar
Binary file not shown.
14 changes: 10 additions & 4 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ assetic:
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
yui_js:
jar: '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'
yui_css:
jar: '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'
bundles:
- SiwappConfigBundle
- SiwappCoreBundle
- SiwappInvoiceBundle
- SiwappCustomerBundle
- SiwappProductBundle
- SiwappDashboardBundle
- SiwappEstimateBundle
- SiwappRecurringInvoiceBundle
- SiwappUserBundle

# Doctrine Configuration
doctrine:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
},
"require": {
"php": ">=5.6",
"php": ">=7.0",
"symfony/symfony": "3.2.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
Expand Down
72 changes: 36 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Siwapp/ConfigBundle/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function globalSettingsAction(Request $request)

if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$series = $data['series'];
$taxes = $data['taxes'];
Expand Down
65 changes: 65 additions & 0 deletions src/Siwapp/CoreBundle/Controller/AbstractInvoiceController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Siwapp\CoreBundle\Controller;

use Siwapp\CoreBundle\Entity\AbstractInvoice;
use Siwapp\CoreBundle\Entity\Item;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

abstract class AbstractInvoiceController extends Controller
{

protected function getPdf(string $html): string
{
$config = $this->getDoctrine()->getRepository('SiwappConfigBundle:Property');
$pdfSize = $config->get('pdf_size');
$pdfOrientation = $config->get('pdf_orientation');
$config = [];
if ($pdfSize) {
$config['page-size'] = $pdfSize;
}
if ($pdfOrientation) {
$config['orientation'] = $pdfOrientation;
}

return $this->get('knp_snappy.pdf')->getOutputFromHtml($html, $config);
}

protected function getInvoiceTotalsFromPost(array $post, AbstractInvoice $invoice, string $locale): array
{
$em = $this->getDoctrine()->getManager();
$taxRepo = $em->getRepository('SiwappCoreBundle:Tax');
$currency = $em->getRepository('SiwappConfigBundle:Property')->get('currency');
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);

$totals = [];
foreach ($post['items'] as $index => $postItem) {
$item = new Item;
$item->setUnitaryCost($postItem['unitary_cost']);
$item->setQuantity($postItem['quantity']);
$item->setDiscount($postItem['discount_percent']);
if (isset($postItem['taxes'])) {
foreach($postItem['taxes'] as $taxId) {
$tax = $taxRepo->find($taxId);
if (!$tax) {
continue;
}
$item->addTax($tax);
}
}
$totals['items'][$index] = [
'gross_amount' => $formatter->formatCurrency($item->getGrossAmount(), $currency),
];
$invoice->addItem($item);
}
$invoice->checkAmounts();

$totals += [
'invoice_base_amount' => $formatter->formatCurrency($invoice->getBaseAmount(), $currency),
'invoice_tax_amount' => $formatter->formatCurrency($invoice->getTaxAmount(), $currency),
'invoice_gross_amount' => $formatter->formatCurrency($invoice->getGrossAmount(), $currency),
];

return $totals;
}
}
2 changes: 1 addition & 1 deletion src/Siwapp/CoreBundle/Controller/CoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Siwapp\CoreBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class CoreController extends Controller
{
Expand Down
Loading

0 comments on commit cd3e100

Please sign in to comment.