change the way product is created

This commit is contained in:
Manuel Raynaud
2014-03-13 09:56:11 +01:00
parent d8e1f24fda
commit e4ba7d8d11
13 changed files with 259 additions and 107 deletions

View File

@@ -6,14 +6,17 @@ return array(
'%obj modification' => '%obj modification',
'A currency with code "%name" already exists.' => 'A currency with code "%name" already exists.',
'A message with name "%name" already exists.' => 'A message with name "%name" already exists.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.',
'A variable with name "%name" already exists.' => 'A variable with name "%name" already exists.',
'Activate logs only for these IP Addresses' => 'Activate logs only for these IP Addresses',
'Activate logs only for these files' => 'Activate logs only for these files',
'Add to all product templates' => 'Add to all product templates',
'Additional address' => 'Additional address',
'Address ID not found' => 'Address ID not found',
'Address Line 2' => 'Address Line 2',
'Address Line 3' => 'Address Line 3',
'Address label' => 'Address label',
'Administrator ID not found' => 'Administrator ID not found',
'Advertise this product as new' => 'Advertise this product as new',
'Alerts' => 'Alerts',
'Alpha code 2 *' => 'Alpha code 2 *',
@@ -25,6 +28,7 @@ return array(
'Auth mode' => 'Auth mode',
'Available quantity' => 'Available quantity',
'Available quantity *' => 'Available quantity *',
'Bad tax list JSON' => 'Bad tax list JSON',
'Business ID' => 'Business ID',
'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.',
'Cannot find the shop country. Please select a shop country.' => 'Cannot find the shop country. Please select a shop country.',
@@ -41,6 +45,7 @@ return array(
'Constant amount found in one of the product\'s feature' => 'Constant amount found in one of the product\'s feature',
'Content title *' => 'Content title *',
'Country' => 'Country',
'Country ID not found' => 'Country ID not found',
'Country area' => 'Country area',
'Country title *' => 'Country title *',
'Critical' => 'Critical',
@@ -49,6 +54,7 @@ return array(
'Default folder *' => 'Default folder *',
'Default product category *' => 'Default product category *',
'Default product sale element' => 'Default product sale element',
'Delivery module ID not found' => 'Delivery module ID not found',
'Description' => 'Description',
'Detailed description' => 'Detailed description',
'Disabled' => 'Disabled',
@@ -73,6 +79,7 @@ return array(
'ISO 639-1 Code' => 'ISO 639-1 Code',
'ISO Code *' => 'ISO Code *',
'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :',
'Impossible to delete a customer who already have orders' => 'Impossible to delete a customer who already have orders',
'Information' => 'Information',
'Invalid product_sale_elements' => 'Invalid product_sale_elements',
'Invalid value for walkMode parameter: %value' => 'Invalid value for walkMode parameter: %value',
@@ -88,6 +95,7 @@ return array(
'Message subject' => 'Message subject',
'Meta Description' => 'Meta Description',
'Meta Keywords' => 'Meta Keywords',
'Module ID not found' => 'Module ID not found',
'Name' => 'Name',
'Name *' => 'Name *',
'Name of the HTML layout file' => 'Name of the HTML layout file',
@@ -99,6 +107,7 @@ return array(
'No %obj was updated.' => 'No %obj was updated.',
'No, I am a new customer.' => 'No, I am a new customer.',
'Notices' => 'Notices',
'Order address ID not found' => 'Order address ID not found',
'Page Title' => 'Page Title',
'Parent category *' => 'Parent category *',
'Parent folder *' => 'Parent folder *',
@@ -108,6 +117,7 @@ return array(
'Percentage of the product price' => 'Percentage of the product price',
'Percentage removed from the cart' => 'Percentage removed from the cart',
'Phone' => 'Phone',
'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.',
'Please enter your email address' => 'Please enter your email address',
'Please enter your password' => 'Please enter your password',
'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Please specify either \'path\' or \'file\' parameter in {url} function.',
@@ -123,6 +133,7 @@ return array(
'Product ID' => 'Product ID',
'Product ID *' => 'Product ID *',
'Product base price excluding taxes *' => 'Product base price excluding taxes *',
'Product base price with taxes' => 'Product base price with taxes',
'Product price excluding taxes' => 'Product price excluding taxes',
'Product price excluding taxes *' => 'Product price excluding taxes *',
'Product price including taxes' => 'Product price including taxes',
@@ -133,6 +144,8 @@ return array(
'ProductSaleElement modification' => 'ProductSaleElement modification',
'Profile' => 'Profile',
'Profile Code' => 'Profile Code',
'Profile ID not found' => 'Profile ID not found',
'Profile `code` already exists' => 'Profile `code` already exists',
'Purpose *' => 'Purpose *',
'Quantity' => 'Quantity',
'Rate from € *' => 'Rate from € *',
@@ -167,20 +180,31 @@ return array(
'Summary' => 'Summary',
'Symbol *' => 'Symbol *',
'System log configuration failed.' => 'System log configuration failed.',
'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON',
'Tax list is not valid JSON' => 'Tax list is not valid JSON',
'Tax rule ID not found' => 'Tax rule ID not found',
'Tax rule for this product *' => 'Tax rule for this product *',
'Template Name *' => 'Template Name *',
'Template file %file cannot be found.' => 'Template file %file cannot be found.',
'Text File' => 'Text File',
'Text Message' => 'Text Message',
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
'This category is online.' => 'This category is online.',
'This content is online.' => 'This content is online.',
'This coupon does not exists' => 'This coupon does not exists',
'This email already exists.' => 'This email already exists.',
'This email does not exists' => 'This email does not exists',
'This extension must be installed and loaded' => 'This extension must be installed and loaded',
'This folder is online.' => 'This folder is online.',
'This login already exists' => 'This login already exists',
'This product is on sale' => 'This product is on sale',
'This product is online' => 'This product is online',
'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d',
'This value should not be blank.' => 'This value should not be blank.',
'Timeout' => 'Timeout',
'Title' => 'Title',
'Title *' => 'Title *',
'Title ID not found' => 'Title ID not found',
'Type' => 'Type',
'Username' => 'Username',
'Username *' => 'Username *',
@@ -190,42 +214,20 @@ return array(
'Weight' => 'Weight',
'Weight *' => 'Weight *',
'Yes, I have a password :' => 'Yes, I have a password :',
'You are already registered!' => 'You are already registered!',
'Your Email Address' => 'Your Email Address',
'Your Message' => 'Your Message',
'Your current password does not match.' => 'Your current password does not match.',
'Zip code' => 'Zip code',
'date format' => 'date format',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'payment module %s is not a Thelia\Module\PaymentModuleInterface',
'language locale' => 'language locale',
'mailing system modification' => 'mailing system modification',
'shipping area name' => 'shipping area name',
'time format' => 'time format',
'This value should not be blank.' => 'This value should not be blank.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.',
'Administrator ID not found' => 'Administrator ID not found',
'This login already exists' => 'This login already exists',
'password confirmation is not the same as password field' => 'password confirmation is not the same as password field',
'password must be composed of at least 4 characters' => 'password must be composed of at least 4 characters',
'this product id does not exists : %d' => 'this product id does not exists : %d',
'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d',
'quantity value is not valid' => 'quantity value is not valid',
'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.',
'This email already exists.' => 'This email already exists.',
'This email does not exists' => 'This email does not exists',
'Your current password does not match.' => 'Your current password does not match.',
'Module ID not found' => 'Module ID not found',
'You are already registered!' => 'You are already registered!',
'Address ID not found' => 'Address ID not found',
'Delivery module ID not found' => 'Delivery module ID not found',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface',
'Order address ID not found' => 'Order address ID not found',
'Title ID not found' => 'Title ID not found',
'Country ID not found' => 'Country ID not found',
'Profile `code` already exists' => 'Profile `code` already exists',
'Profile ID not found' => 'Profile ID not found',
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
'Tax rule ID not found' => 'Tax rule ID not found',
'Tax list is not valid JSON' => 'Tax list is not valid JSON',
'Bad tax list JSON' => 'Bad tax list JSON',
'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON',
'Please check your input: %s' => 'Please check your input: %s',
'Sorry, an error occured: %s' => 'Sorry, an error occured: %s',
'shipping area name' => 'shipping area name',
'this product id does not exists : %d' => 'this product id does not exists : %d',
'time format' => 'time format',
);

View File

@@ -6,14 +6,17 @@ return array(
'%obj modification' => 'Modification de %obj',
'A currency with code "%name" already exists.' => 'Une devise avec la code "%name" existe déjà',
'A message with name "%name" already exists.' => 'Un message avec le nom "%name" existe déjà.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.',
'A variable with name "%name" already exists.' => 'Une variable avec le nom "%name" existe déjà.',
'Activate logs only for these IP Addresses' => 'Activer les logs uniquement pour ces adresses IP',
'Activate logs only for these files' => 'Activer les logs uniquement pour ces fichiers',
'Add to all product templates' => 'Ajouter à tous les templates produit',
'Additional address' => 'Adresse complémentaire',
'Address ID not found' => 'ID de l\'adresse non trouvé',
'Address Line 2' => 'Adresse 1',
'Address Line 3' => 'Adresse 2',
'Address label' => 'Adresse',
'Administrator ID not found' => 'ID de l\'administrateur not trouvé',
'Advertise this product as new' => 'Afficher ce produit comme nouveau',
'Alerts' => 'Alertes',
'Alpha code 2 *' => 'Code Alpha 2 *',
@@ -25,6 +28,7 @@ return array(
'Auth mode' => 'Mode d\'authentification',
'Available quantity' => 'Quantité disponible',
'Available quantity *' => 'Quantité disponible *',
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
'Business ID' => 'ID du business',
'Cannot find a default country. Please define one.' => 'Impossible de trouver un pays par défaut. Veuillez en définir un.',
'Cannot find the shop country. Please select a shop country.' => 'Impossible de trouver le pays du magasin. Veuillez en sélectionner un.',
@@ -41,6 +45,7 @@ return array(
'Constant amount found in one of the product\'s feature' => 'Montant fixe trouvé depuis une caractéristique produit',
'Content title *' => 'Titre du contenu *',
'Country' => 'Pays',
'Country ID not found' => 'ID du pays non trouvé',
'Country area' => 'Zone du pays',
'Country title *' => 'Pays *',
'Critical' => 'Critique',
@@ -49,6 +54,7 @@ return array(
'Default folder *' => 'Dossier par défaut *',
'Default product category *' => 'Catégorie du produit par défaut *',
'Default product sale element' => 'Product Sale Element par défaut',
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
'Description' => 'Description',
'Detailed description' => 'Description détaillée',
'Disabled' => 'Désactivé',
@@ -73,6 +79,7 @@ return array(
'ISO 639-1 Code' => 'Code ISO 639-1',
'ISO Code *' => 'Code ISO *',
'If a translation is missing or incomplete :' => 'Si une traduction est manquante ou incomplète :',
'Impossible to delete a customer who already have orders' => 'Impossible de supprimer un client si celui-ci a déjà une commande',
'Information' => 'Information',
'Invalid product_sale_elements' => 'product_sale_elements invalide',
'Invalid value for walkMode parameter: %value' => 'Valeur incorrecte pour le paramètre walkMode : %value',
@@ -88,6 +95,7 @@ return array(
'Message subject' => 'Sujet',
'Meta Description' => 'Meta description',
'Meta Keywords' => 'Meta keywords',
'Module ID not found' => 'Id du module non trouvé',
'Name' => 'Nom',
'Name *' => 'Nom *',
'Name of the HTML layout file' => 'Nom du layout HTML',
@@ -99,6 +107,7 @@ return array(
'No %obj was updated.' => 'Aucun %obj mis à jour',
'No, I am a new customer.' => 'Non, je suis un nouveau client.',
'Notices' => 'Notices',
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
'Page Title' => 'Titre de la page',
'Parent category *' => 'Catégorie parente *',
'Parent folder *' => 'Dossier parent *',
@@ -108,6 +117,7 @@ return array(
'Percentage of the product price' => 'Pourcentage du prix du produit',
'Percentage removed from the cart' => 'Pourcentage déduit du panier',
'Phone' => 'Téléphone',
'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.',
'Please enter your email address' => 'Renseignez votre adresse mail',
'Please enter your password' => 'Entrez votre mot de passe.',
'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Veuillez spécifier soit le paramètre \'chemin\' ou \'fichier\' dans la fonction {url}',
@@ -123,6 +133,7 @@ return array(
'Product ID' => 'ID produit',
'Product ID *' => 'ID produit *',
'Product base price excluding taxes *' => 'Prix du produit Hors Taxe *',
'Product base price with taxes' => 'Prix du produit TTC',
'Product price excluding taxes' => 'Prix du produit Hors Taxes',
'Product price excluding taxes *' => 'prix HT',
'Product price including taxes' => 'Prix du produit taxes incluses',
@@ -133,6 +144,8 @@ return array(
'ProductSaleElement modification' => 'Modification de ProductSaleElement.',
'Profile' => 'Profil',
'Profile Code' => 'Profil',
'Profile ID not found' => 'ID du profil non trouvé',
'Profile `code` already exists' => 'Le `code` du profil existe déjà',
'Purpose *' => 'Objet',
'Rate from € *' => 'Taux à partie de l\'€ *',
'Redirecting ...' => 'Redirection ...',
@@ -166,20 +179,31 @@ return array(
'Summary' => 'Résumé',
'Symbol *' => 'Symbole *',
'System log configuration failed.' => 'Erreur du configurateur de log system.',
'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes',
'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide',
'Tax rule ID not found' => 'ID de la règle de taxe non trouvé',
'Tax rule for this product *' => 'Règle de taxe pour ce produit *',
'Template Name *' => 'Nom du template *',
'Template file %file cannot be found.' => 'Le fichier %file n\'a pas été trouvé dans le template. ',
'Text File' => 'Fichier texte',
'Text Message' => 'Message au format texte',
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
'This category is online.' => 'Cette catégorie est en ligne.',
'This content is online.' => 'Ce contenu est en ligne.',
'This coupon does not exists' => 'Ce code promo n\'existe pas',
'This email already exists.' => 'Cette adresse email existe déjà',
'This email does not exists' => 'Cette adresse email n\'existe pas',
'This extension must be installed and loaded' => 'Cette extension doit être installée et chargée.',
'This folder is online.' => 'Ce dossier est en ligne.',
'This login already exists' => 'Cet identifiant existe déjà',
'This product is on sale' => 'Ce produit est en promo',
'This product is online' => 'Ce produit est en ligne',
'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d',
'This value should not be blank.' => 'Cette valeur ne doit pas être vide.',
'Timeout' => 'Délai d\'attente expiré',
'Title' => 'Titre',
'Title *' => 'Titre *',
'Title ID not found' => 'ID de la civilité non trouvé',
'Type' => 'Type',
'Username' => 'Nom d\'utilisateur',
'Username *' => 'Nom d\'utilisateur *',
@@ -189,42 +213,20 @@ return array(
'Weight' => 'Poids',
'Weight *' => 'Poids *',
'Yes, I have a password :' => 'Oui, j\'ai un mot de passe :',
'You are already registered!' => 'Vous êtes déjà enregistré !',
'Your Email Address' => 'Votre adresse mail',
'Your Message' => 'Votre message',
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',
'Zip code' => 'Code postal',
'date format' => 'Format de date',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface',
'language locale' => 'Langue locale',
'mailing system modification' => 'Modification du système d\'envoi de mail.',
'shipping area name' => 'Nom de la zone de livraison',
'time format' => 'Format d\'heure',
'This value should not be blank.' => 'Cette valeur ne doit pas être vide.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.',
'Administrator ID not found' => 'ID de l\'administrateur not trouvé',
'This login already exists' => 'Cet identifiant existe déjà',
'password confirmation is not the same as password field' => 'le mot de passe de confirmation n\'est pas le même que le champ mot de passe',
'password must be composed of at least 4 characters' => 'le mot de passe doit être composé d\'au moins 4 caractères',
'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas',
'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'Le module de paiement %s n\'est pas une instance de Thelia\Module\PaymentModuleInterface ',
'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide',
'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.',
'This email already exists.' => 'Cette adresse email existe déjà',
'This email does not exists' => 'Cette adresse email n\'existe pas',
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',
'Module ID not found' => 'Id du module non trouvé',
'You are already registered!' => 'Vous êtes déjà enregistré !',
'Address ID not found' => 'ID de l\'adresse non trouvé',
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface',
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
'Title ID not found' => 'ID de la civilité non trouvé',
'Country ID not found' => 'ID du pays non trouvé',
'Profile `code` already exists' => 'Le `code` du profil existe déjà',
'Profile ID not found' => 'ID du profil non trouvé',
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
'Tax rule ID not found' => 'ID de la règle de taxe non trouvé',
'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide',
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes',
'Please check your input: %s' => 'Veuillez vérifier votre saisie: %s',
'Sorry, an error occured: %s' => 'Désolé, une erreur est survenue: %s',
'shipping area name' => 'Nom de la zone de livraison',
'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas',
'time format' => 'Format d\'heure',
);

View File

@@ -340,6 +340,10 @@
<default key="_controller">Thelia\Controller\Admin\ProductController::priceCaclulator</default>
</route>
<route id="admin.product.calculate-raw-price" path="/admin/product/calculate-raw-price">
<default key="_controller">Thelia\Controller\Admin\ProductController::calculatePrice</default>
</route>
<route id="admin.product.load-converted-prices" path="/admin/product/load-converted-prices">
<default key="_controller">Thelia\Controller\Admin\ProductController::loadConvertedPrices</default>
</route>

View File

@@ -73,6 +73,7 @@ use Thelia\Form\ProductSaleElementUpdateForm;
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
use Thelia\Form\ProductCombinationGenerationForm;
use Thelia\Model\TaxRuleQuery;
use Thelia\TaxEngine\Calculator;
use Thelia\Tools\NumberFormat;
@@ -1155,10 +1156,10 @@ class ProductController extends AbstractSeoCrudController
{
$return_price = 0;
$price = floatval($this->getRequest()->get('price', 0));
$product_id = intval($this->getRequest()->get('product_id', 0));
$action = $this->getRequest()->get('action', ''); // With ot without tax
$convert = intval($this->getRequest()->get('convert_from_default_currency', 0));
$price = floatval($this->getRequest()->query->get('price', 0));
$product_id = intval($this->getRequest()->query->get('product_id', 0));
$action = $this->getRequest()->query->get('action', ''); // With ot without tax
$convert = intval($this->getRequest()->query->get('convert_from_default_currency', 0));
if (null !== $product = ProductQuery::create()->findPk($product_id)) {
@@ -1171,7 +1172,46 @@ class ProductController extends AbstractSeoCrudController
}
if ($convert != 0) {
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
$return_price = $price * Currency::getDefaultCurrency()->getRate();
}
}
return new JsonResponse(array('result' => $return_price));
}
/**
*
* Calculate tax or untax price for a non existing product.
*
* For an existing product, use self::priceCaclulator
*
* @return JsonResponse
*/
public function calculatePrice()
{
$return_price = 0;
$price = floatval($this->getRequest()->query->get('price'));
$tax_rule_id = intval($this->getRequest()->query->get('tax_rule'));
$action = $this->getRequest()->query->get('action'); // With ot without tax
$taxRule = TaxRuleQuery::create()->findPk($tax_rule_id);
if (null !== $price && null !== $taxRule) {
$calculator = new Calculator();
$calculator->loadTaxRuleWithoutProduct(
$taxRule,
Country::getShopLocation()
);
if ($action == 'to_tax') {
$return_price = $calculator->getTaxedPrice($price);
} elseif ($action == 'from_tax') {
$return_price = $calculator->getUntaxedPrice($price);
} else {
$return_price = $price;
}
}
@@ -1251,7 +1291,7 @@ class ProductController extends AbstractSeoCrudController
}
if ($convert != 0) {
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
$return_price = $price * Currency::getDefaultCurrency()->getRate();
}
// Format the number using '.', to perform further calculation

View File

@@ -88,7 +88,7 @@ class OrderPayment extends BaseForm
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
$context->addViolation(
sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
);
}
}

View File

@@ -70,8 +70,12 @@ class ProductCreationForm extends BaseForm
->add("price", "number", array(
"constraints" => array(new NotBlank()),
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
"label_attr" => array("for" => "price_field")
"label_attr" => array("for" => "price_without_tax")
))
->add("tax_price", "number", array(
"label" => Translator::getInstance()->trans("Product base price with taxes"),
"label_attr" => array("for" => "price_with_tax")
))
->add("currency", "integer", array(
"constraints" => array(new NotBlank()),
"label" => Translator::getInstance()->trans("Price currency *"),
@@ -83,7 +87,7 @@ class ProductCreationForm extends BaseForm
"label_attr" => array("for" => "tax_rule_field")
))
->add("weight", "number", array(
"label" => Translator::getInstance()->trans("Weight *"),
"label" => Translator::getInstance()->trans("Weight"),
"label_attr" => array("for" => "weight_field")
))
;

View File

@@ -100,6 +100,27 @@ class Calculator
return $this;
}
public function loadTaxRuleWithoutProduct(TaxRule $taxRule, Country $country)
{
$this->product = null;
$this->country = null;
$this->taxRulesCollection = null;
if ($taxRule->getId() === null) {
throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
}
if ($country->getId() === null) {
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
}
$this->country = $country;
$this->product = new Product();
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
return $this;
}
public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null)
{
return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice;

View File

@@ -47,6 +47,7 @@ class FeatureFixAmountTaxType extends BaseTaxType
public function fixAmountRetriever(Product $product)
{
$taxAmount = 0;
$featureId = $this->getRequirement("feature");
$query = FeatureProductQuery::create()
@@ -54,14 +55,17 @@ class FeatureFixAmountTaxType extends BaseTaxType
->filterByFeatureId($featureId)
->findOne();
$taxAmount = $query->getFreeTextValue();
if (null !== $query) {
$taxAmount = $query->getFreeTextValue();
$testInt = new FloatType();
if (!$testInt->isValid($taxAmount)) {
throw new TaxEngineException(
$testInt = new FloatType();
if (!$testInt->isValid($taxAmount)) {
throw new TaxEngineException(
Translator::getInstance()->trans('Feature value does not match FLOAT format'),
TaxEngineException::FEATURE_BAD_EXPECTED_VALUE
);
);
}
}
return $taxAmount;