From 259c9d70c0fc53379f3fae57f82ce92ee86c2661 Mon Sep 17 00:00:00 2001 From: Volodymyr Denchyk Date: Thu, 11 Jun 2020 00:19:26 +0300 Subject: [PATCH 1/3] MAR10001-909: Add Company ID to Company --- .../Bundle/CustomerBundle/Entity/Company.php | 36 +++++++++++++ .../CustomerBundle/Form/Type/CompanyType.php | 4 ++ .../Schema/MarelloCustomerBundleInstaller.php | 3 +- .../Schema/v1_4/MarelloCustomerBundle.php | 39 ++++++++++++++ .../Resources/config/services.yml | 7 +++ .../Resources/config/validation.yml | 3 ++ .../Resources/translations/messages.en.yml | 1 + .../Resources/translations/validators.en.yml | 4 ++ .../Resources/views/Company/update.html.twig | 1 + .../Resources/views/Company/view.html.twig | 1 + .../Validator/CompanyCodeValidator.php | 53 +++++++++++++++++++ .../Validator/Constraints/CompanyCode.php | 29 ++++++++++ .../Resources/views/Invoice/view.html.twig | 6 +++ .../Resources/views/Pdf/creditmemo.html.twig | 4 +- .../Resources/views/Pdf/invoice.html.twig | 4 +- 15 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php create mode 100644 src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml create mode 100644 src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php create mode 100644 src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php diff --git a/src/Marello/Bundle/CustomerBundle/Entity/Company.php b/src/Marello/Bundle/CustomerBundle/Entity/Company.php index ded06a85d..3aa5045d3 100644 --- a/src/Marello/Bundle/CustomerBundle/Entity/Company.php +++ b/src/Marello/Bundle/CustomerBundle/Entity/Company.php @@ -83,6 +83,23 @@ class Company extends ExtendCompany implements OrganizationAwareInterface */ protected $name; + /** + * @var string + * + * @ORM\Column(type="string", nullable=true) + * @ConfigField( + * defaultValues={ + * "dataaudit"={ + * "auditable"=true + * }, + * "importexport"={ + * "order"=35 + * } + * } + * ) + */ + protected $code; + /** * @var PaymentTerm * @@ -226,6 +243,25 @@ public function getName() return $this->name; } + /** + * @return string|null + */ + public function getCode() + { + return $this->code; + } + + /** + * @param string|null $code + * @return $this + */ + public function setCode($code = null) + { + $this->code = $code; + + return $this; + } + /** * @return PaymentTerm */ diff --git a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php index 05e534d88..25f7959c4 100644 --- a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php +++ b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php @@ -42,6 +42,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', TextType::class, ['label' => 'marello.customer.company.name.label']) + ->add('code', TextType::class, [ + 'label' => 'marello.customer.company.code.label', + 'required' => false + ]) ->add( 'parent', ParentCompanySelectType::class, diff --git a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php index 5fa23c38b..b8b703c09 100644 --- a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php +++ b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php @@ -34,7 +34,7 @@ class MarelloCustomerBundleInstaller implements */ public function getMigrationVersion() { - return 'v1_3'; + return 'v1_4'; } /** @@ -63,6 +63,7 @@ protected function createMarelloCompanyTable(Schema $schema) $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('name', 'string', ['length' => 255]); + $table->addColumn('code', 'string', ['length' => 255, 'notnull' => false]); $table->addColumn('payment_term_id', 'integer', ['notnull' => false]); $table->addColumn('parent_id', 'integer', ['notnull' => false]); $table->addColumn('organization_id', 'integer', ['notnull' => false]); diff --git a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php new file mode 100644 index 000000000..c1acbfffd --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php @@ -0,0 +1,39 @@ +getTable(MarelloCustomerBundleInstaller::MARELLO_COMPANY_TABLE); + $table->addColumn('code', 'string', ['length' => 255, 'notnull' => false]); + } + + /** + * Sets the ActivityExtension + * + * @param ActivityExtension $activityExtension + */ + public function setActivityExtension(ActivityExtension $activityExtension) + { + $this->activityExtension = $activityExtension; + } +} diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml index abf2ec059..5fcd64a4a 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml @@ -130,3 +130,10 @@ services: marello_customer.provider.customer_address: class: 'Marello\Bundle\CustomerBundle\Provider\CustomerAddressProvider' + + marello_customer.form.validator.company_code: + class: 'Marello\Bundle\CustomerBundle\Validator\CompanyCodeValidator' + arguments: + - '@oro_entity.doctrine_helper' + tags: + - { name: validator.constraint_validator, alias: marello_customer.company_code_validator } diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml index c1e8c682c..8be94acef 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml @@ -1,3 +1,4 @@ +<<<<<<< HEAD Marello\Bundle\CustomerBundle\Entity\Customer: properties: firstName: @@ -9,6 +10,8 @@ Marello\Bundle\CustomerBundle\Entity\Customer: - Email: ~ Marello\Bundle\CustomerBundle\Entity\Company: + constraints: + - Marello\Bundle\CustomerBundle\Validator\Constraints\CompanyCode: ~ properties: name: - NotBlank: ~ \ No newline at end of file diff --git a/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml index 371299200..5c407c3b9 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml @@ -28,6 +28,7 @@ marello: entity_grid_all_view_label: All %entity_plural_label% id.label: 'Id' name.label: 'Name' + code.label: 'Code' parent.label: 'Parent' children.label: 'Children' addresses.label: 'Addresses' diff --git a/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml b/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml new file mode 100644 index 000000000..1895c5da7 --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml @@ -0,0 +1,4 @@ +marello: + customer: + company: + code.message: 'Company code should be unique per Organization.' diff --git a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig index a6d8c96ce..38907bc63 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig +++ b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig @@ -51,6 +51,7 @@ 'title': '', 'data': [ form_row(form.name), + form_row(form.code), form_row(form.parent), form_row(form.paymentTerm), form_widget(form.appendCustomers, {'id': 'appendCustomers'}), diff --git a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig index e5c99ae3b..86ff9874d 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig +++ b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig @@ -23,6 +23,7 @@
{{ UI.renderProperty('marello.customer.company.name.label'|trans, entity.name) }} + {{ UI.renderProperty('marello.customer.company.code.label'|trans, entity.code ? entity.code : 'N/A') }} {{ UI.renderProperty('oro.ui.created_at'|trans, entity.createdAt ? entity.createdAt|oro_format_datetime : 'N/A') }} {{ UI.renderProperty('oro.ui.updated_at'|trans, entity.updatedAt ? entity.updatedAt|oro_format_datetime : 'N/A') }} {% if entity.parent %} diff --git a/src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php b/src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php new file mode 100644 index 000000000..6f4b32c53 --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php @@ -0,0 +1,53 @@ +doctrineHelper = $doctrineHelper; + } + + /** + * {@inheritDoc} + */ + public function validate($entity, Constraint $constraint) + { + if (!$constraint instanceof CompanyCode) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\CompanyCode'); + } + + if (!$entity instanceof Company) { + throw new UnexpectedTypeException($entity, Company::class); + } + $organization = $entity->getOrganization(); + $code = $entity->getCode(); + if ($organization && $code) { + $existingCompanies = $this->doctrineHelper + ->getEntityManagerForClass(Company::class) + ->getRepository(Company::class) + ->findBy(['code' => $code, 'organization' => $organization]); + if (!empty($existingCompanies)) { + $this->context->buildViolation($constraint->message) + ->atPath('code') + ->addViolation(); + } + } + } +} diff --git a/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php b/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php new file mode 100644 index 000000000..806ffec15 --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php @@ -0,0 +1,29 @@ +
- {# Customer details #}

+ {% if entity.customer.company.code %} + {{ 'marello.customer.company.entity_label'|trans ~ ' ' ~ 'marello.customer.company.code.label'|trans ~ ': ' ~ entity.customer.company.code }} + {% endif %} {% set address = entity.billingAddress %} {% set name = address|oro_format_name(locale) %} {% if name is empty %} diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig index a52eaf731..42a8e60ca 100644 --- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig +++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig @@ -210,8 +210,10 @@

- {# Customer details #}

+ {% if entity.customer.company.code %} + {{ 'marello.customer.company.entity_label'|trans ~ ' ' ~ 'marello.customer.company.code.label'|trans ~ ': ' ~ entity.customer.company.code }} + {% endif %} {% set address = entity.billingAddress %} {% set name = address|oro_format_name(locale) %} {% if name is empty %} From 0a4bb46ccbafebfbb1e5b948dcbf5725b2afb3e4 Mon Sep 17 00:00:00 2001 From: Hotlander Date: Mon, 15 Jun 2020 08:51:31 +0200 Subject: [PATCH 2/3] - renamed Company code to Company number - added pdf translation - moved company number on the PDF --- .../Bundle/CustomerBundle/Entity/Company.php | 24 ++++++++++++------- .../CustomerBundle/Form/Type/CompanyType.php | 4 ++-- .../Schema/MarelloCustomerBundleInstaller.php | 3 ++- .../Schema/v1_4/MarelloCustomerBundle.php | 20 +++------------- .../Resources/config/oro/datagrids.yml | 1 - .../Resources/config/services.yml | 6 ++--- .../Resources/config/validation.yml | 2 +- .../Resources/translations/messages.en.yml | 2 +- .../Resources/translations/pdf.en.yml | 5 ++++ .../Resources/translations/validators.en.yml | 2 +- .../Resources/views/Company/update.html.twig | 2 +- .../Resources/views/Company/view.html.twig | 2 +- ...lidator.php => CompanyNumberValidator.php} | 22 +++++++++-------- .../{CompanyCode.php => CompanyNumber.php} | 6 ++--- .../Resources/views/Invoice/view.html.twig | 7 ++---- .../Resources/views/Pdf/creditmemo.html.twig | 9 ++++--- .../Resources/views/Pdf/invoice.html.twig | 9 ++++--- 17 files changed, 61 insertions(+), 65 deletions(-) create mode 100644 src/Marello/Bundle/CustomerBundle/Resources/translations/pdf.en.yml rename src/Marello/Bundle/CustomerBundle/Validator/{CompanyCodeValidator.php => CompanyNumberValidator.php} (73%) rename src/Marello/Bundle/CustomerBundle/Validator/Constraints/{CompanyCode.php => CompanyNumber.php} (68%) diff --git a/src/Marello/Bundle/CustomerBundle/Entity/Company.php b/src/Marello/Bundle/CustomerBundle/Entity/Company.php index 3aa5045d3..7fc4938a3 100644 --- a/src/Marello/Bundle/CustomerBundle/Entity/Company.php +++ b/src/Marello/Bundle/CustomerBundle/Entity/Company.php @@ -16,7 +16,15 @@ /** * @ORM\Entity(repositoryClass="Marello\Bundle\CustomerBundle\Entity\Repository\CompanyRepository") - * @ORM\Table(name="marello_customer_company" ) + * @ORM\Table(name="marello_customer_company", + * uniqueConstraints={ + * @ORM\UniqueConstraint( + * name="marello_customer_company_compnrorgidx", + * columns={"company_number,organization_id"} + * ) + * } + * + * ) * * @Config( * routeName="marello_customer_company_index", @@ -86,7 +94,7 @@ class Company extends ExtendCompany implements OrganizationAwareInterface /** * @var string * - * @ORM\Column(type="string", nullable=true) + * @ORM\Column(name="company_number", type="string", nullable=true) * @ConfigField( * defaultValues={ * "dataaudit"={ @@ -98,7 +106,7 @@ class Company extends ExtendCompany implements OrganizationAwareInterface * } * ) */ - protected $code; + protected $companyNumber; /** * @var PaymentTerm @@ -246,18 +254,18 @@ public function getName() /** * @return string|null */ - public function getCode() + public function getCompanyNumber(): ?string { - return $this->code; + return $this->companyNumber; } /** - * @param string|null $code + * @param string|null $companyNumber * @return $this */ - public function setCode($code = null) + public function setCompanyNumber(string $companyNumber = null) { - $this->code = $code; + $this->companyNumber = $companyNumber; return $this; } diff --git a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php index 25f7959c4..87a4d20ac 100644 --- a/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php +++ b/src/Marello/Bundle/CustomerBundle/Form/Type/CompanyType.php @@ -42,8 +42,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', TextType::class, ['label' => 'marello.customer.company.name.label']) - ->add('code', TextType::class, [ - 'label' => 'marello.customer.company.code.label', + ->add('companyNumber', TextType::class, [ + 'label' => 'marello.customer.company.company_number.label', 'required' => false ]) ->add( diff --git a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php index b8b703c09..ae7d80129 100644 --- a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php +++ b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php @@ -63,13 +63,14 @@ protected function createMarelloCompanyTable(Schema $schema) $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('name', 'string', ['length' => 255]); - $table->addColumn('code', 'string', ['length' => 255, 'notnull' => false]); + $table->addColumn('company_number', 'string', ['length' => 255, 'notnull' => false]); $table->addColumn('payment_term_id', 'integer', ['notnull' => false]); $table->addColumn('parent_id', 'integer', ['notnull' => false]); $table->addColumn('organization_id', 'integer', ['notnull' => false]); $table->addColumn('created_at', 'datetime'); $table->addColumn('updated_at', 'datetime', ['notnull' => false]); $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['company_number', 'organization_id'], 'marello_customer_company_compnrorgidx'); } /** diff --git a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php index c1acbfffd..dc45bf2c3 100644 --- a/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php +++ b/src/Marello/Bundle/CustomerBundle/Migrations/Schema/v1_4/MarelloCustomerBundle.php @@ -11,29 +11,15 @@ use Marello\Bundle\CustomerBundle\Migrations\Schema\MarelloCustomerBundleInstaller; -class MarelloCustomerBundle implements Migration, ActivityExtensionAwareInterface +class MarelloCustomerBundle implements Migration { - /** - * @var ActivityExtension - */ - protected $activityExtension; - /** * @inheritDoc */ public function up(Schema $schema, QueryBag $queries) { $table = $schema->getTable(MarelloCustomerBundleInstaller::MARELLO_COMPANY_TABLE); - $table->addColumn('code', 'string', ['length' => 255, 'notnull' => false]); - } - - /** - * Sets the ActivityExtension - * - * @param ActivityExtension $activityExtension - */ - public function setActivityExtension(ActivityExtension $activityExtension) - { - $this->activityExtension = $activityExtension; + $table->addColumn('company_number', 'string', ['length' => 255, 'notnull' => false]); + $table->addUniqueIndex(['company_number', 'organization_id'], 'marello_customer_company_compnrorgidx'); } } diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/oro/datagrids.yml index 8d000f027..55460253c 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/oro/datagrids.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/oro/datagrids.yml @@ -1,5 +1,4 @@ datagrids: - marello-customer: source: type: orm diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml index 5fcd64a4a..bf043f992 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/services.yml @@ -131,9 +131,9 @@ services: marello_customer.provider.customer_address: class: 'Marello\Bundle\CustomerBundle\Provider\CustomerAddressProvider' - marello_customer.form.validator.company_code: - class: 'Marello\Bundle\CustomerBundle\Validator\CompanyCodeValidator' + marello_customer.form.validator.company_number: + class: 'Marello\Bundle\CustomerBundle\Validator\CompanyNumberValidator' arguments: - '@oro_entity.doctrine_helper' tags: - - { name: validator.constraint_validator, alias: marello_customer.company_code_validator } + - { name: validator.constraint_validator, alias: marello_customer.company_number_validator } diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml index 8be94acef..67a9d914b 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml @@ -11,7 +11,7 @@ Marello\Bundle\CustomerBundle\Entity\Customer: Marello\Bundle\CustomerBundle\Entity\Company: constraints: - - Marello\Bundle\CustomerBundle\Validator\Constraints\CompanyCode: ~ + - Marello\Bundle\CustomerBundle\Validator\Constraints\CompanyNumber: ~ properties: name: - NotBlank: ~ \ No newline at end of file diff --git a/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml index 5c407c3b9..bffdb9031 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/translations/messages.en.yml @@ -28,7 +28,7 @@ marello: entity_grid_all_view_label: All %entity_plural_label% id.label: 'Id' name.label: 'Name' - code.label: 'Code' + company_number.label: 'Company Number' parent.label: 'Parent' children.label: 'Children' addresses.label: 'Addresses' diff --git a/src/Marello/Bundle/CustomerBundle/Resources/translations/pdf.en.yml b/src/Marello/Bundle/CustomerBundle/Resources/translations/pdf.en.yml new file mode 100644 index 000000000..da88d9569 --- /dev/null +++ b/src/Marello/Bundle/CustomerBundle/Resources/translations/pdf.en.yml @@ -0,0 +1,5 @@ +marello: + customer: + company: + pdf: + company_number.label: "Company Number" diff --git a/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml b/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml index 1895c5da7..405f76552 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/translations/validators.en.yml @@ -1,4 +1,4 @@ marello: customer: company: - code.message: 'Company code should be unique per Organization.' + number.message: 'Company number should be unique per Organization.' diff --git a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig index 38907bc63..360527cdc 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig +++ b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/update.html.twig @@ -51,7 +51,7 @@ 'title': '', 'data': [ form_row(form.name), - form_row(form.code), + form_row(form.companyNumber), form_row(form.parent), form_row(form.paymentTerm), form_widget(form.appendCustomers, {'id': 'appendCustomers'}), diff --git a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig index 86ff9874d..c7f2e79b1 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig +++ b/src/Marello/Bundle/CustomerBundle/Resources/views/Company/view.html.twig @@ -23,7 +23,7 @@

{{ UI.renderProperty('marello.customer.company.name.label'|trans, entity.name) }} - {{ UI.renderProperty('marello.customer.company.code.label'|trans, entity.code ? entity.code : 'N/A') }} + {{ UI.renderProperty('marello.customer.company.company_number.label'|trans, entity.companyNumber ? entity.companyNumber : 'N/A') }} {{ UI.renderProperty('oro.ui.created_at'|trans, entity.createdAt ? entity.createdAt|oro_format_datetime : 'N/A') }} {{ UI.renderProperty('oro.ui.updated_at'|trans, entity.updatedAt ? entity.updatedAt|oro_format_datetime : 'N/A') }} {% if entity.parent %} diff --git a/src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php b/src/Marello/Bundle/CustomerBundle/Validator/CompanyNumberValidator.php similarity index 73% rename from src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php rename to src/Marello/Bundle/CustomerBundle/Validator/CompanyNumberValidator.php index 6f4b32c53..b6800b2f2 100644 --- a/src/Marello/Bundle/CustomerBundle/Validator/CompanyCodeValidator.php +++ b/src/Marello/Bundle/CustomerBundle/Validator/CompanyNumberValidator.php @@ -2,14 +2,16 @@ namespace Marello\Bundle\CustomerBundle\Validator; -use Marello\Bundle\CustomerBundle\Entity\Company; -use Marello\Bundle\CustomerBundle\Validator\Constraints\CompanyCode; -use Oro\Bundle\EntityBundle\ORM\DoctrineHelper; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; -class CompanyCodeValidator extends ConstraintValidator +use Oro\Bundle\EntityBundle\ORM\DoctrineHelper; + +use Marello\Bundle\CustomerBundle\Entity\Company; +use Marello\Bundle\CustomerBundle\Validator\Constraints\CompanyNumber; + +class CompanyNumberValidator extends ConstraintValidator { /** * @var DoctrineHelper @@ -29,23 +31,23 @@ public function __construct(DoctrineHelper $doctrineHelper) */ public function validate($entity, Constraint $constraint) { - if (!$constraint instanceof CompanyCode) { - throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\CompanyCode'); + if (!$constraint instanceof CompanyNumber) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\CompanyNumber'); } if (!$entity instanceof Company) { throw new UnexpectedTypeException($entity, Company::class); } $organization = $entity->getOrganization(); - $code = $entity->getCode(); - if ($organization && $code) { + $companyNumber = $entity->getCompanyNumber(); + if ($organization && $companyNumber) { $existingCompanies = $this->doctrineHelper ->getEntityManagerForClass(Company::class) ->getRepository(Company::class) - ->findBy(['code' => $code, 'organization' => $organization]); + ->findBy(['companyNumber' => $companyNumber, 'organization' => $organization]); if (!empty($existingCompanies)) { $this->context->buildViolation($constraint->message) - ->atPath('code') + ->atPath('companyNumber') ->addViolation(); } } diff --git a/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php b/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyNumber.php similarity index 68% rename from src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php rename to src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyNumber.php index 806ffec15..7d5747a21 100644 --- a/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyCode.php +++ b/src/Marello/Bundle/CustomerBundle/Validator/Constraints/CompanyNumber.php @@ -4,19 +4,19 @@ use Symfony\Component\Validator\Constraint; -class CompanyCode extends Constraint +class CompanyNumber extends Constraint { /** * @var string */ - public $message = 'marello.customer.company.code.message'; + public $message = 'marello.customer.company.number.message'; /** * @return string */ public function validatedBy() { - return 'marello_customer.company_code_validator'; + return 'marello_customer.company_number_validator'; } /** diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig index 18733ee3e..4799e021a 100644 --- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig +++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig @@ -75,11 +75,8 @@ 'marello.customer.company.entity_label'|trans, UI.entityViewLink(entity.customer.company, entity.customer.company.name, 'marello_customer_company_view') ) }} - {% if entity.customer.company.code %} - {{ UI.renderHtmlProperty( - 'marello.customer.company.entity_label'|trans ~ ' ' ~ 'marello.customer.company.code.label'|trans, - entity.customer.company.code - ) }} + {% if entity.customer.company.companyNumber %} + {{ UI.renderProperty('marello.customer.company.company_number.label'|trans, entity.customer.company.companyNumber) }} {% endif %} {% endif %} {{ UI.renderHtmlProperty( diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig index 3c919828c..73f57208f 100644 --- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig +++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig @@ -211,9 +211,6 @@

- {% if entity.customer.company.code %} - {{ 'marello.customer.company.entity_label'|trans ~ ' ' ~ 'marello.customer.company.code.label'|trans ~ ': ' ~ entity.customer.company.code }} - {% endif %} {% set address = entity.billingAddress %} {% set name = address|oro_format_name(locale) %} {% if name is empty %} @@ -248,8 +245,10 @@

{{ entity.invoicedAt|date('d-m-Y') }}
{{ 'marello.pdf.creditmemo.creditmemo_number.label'|trans({}, 'pdf', language) }}:
{% if entity.invoiceNumber is not empty %}{{ entity.invoiceNumber }}{% else %} {% endif %}
-
{{ 'marello.pdf.creditmemo.debtor_number.label'|trans({}, 'pdf', language) }}:
-
{{ entity.customer.id }}
+ {% if entity.customer.company.companyNumber %} +
{{ 'marello.customer.company.pdf.company_number.label'|trans({}, 'pdf', language) }}:
+
{{ entity.customer.company.companyNumber }}
+ {% endif %}
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig index 42a8e60ca..a9499a871 100644 --- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig +++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig @@ -211,9 +211,6 @@

- {% if entity.customer.company.code %} - {{ 'marello.customer.company.entity_label'|trans ~ ' ' ~ 'marello.customer.company.code.label'|trans ~ ': ' ~ entity.customer.company.code }} - {% endif %} {% set address = entity.billingAddress %} {% set name = address|oro_format_name(locale) %} {% if name is empty %} @@ -248,8 +245,10 @@

{{ entity.invoicedAt|date('d-m-Y') }}
{{ 'marello.pdf.invoice.invoice_number.label'|trans({}, 'pdf', language) }}:
{% if entity.invoiceNumber is not empty %}{{ entity.invoiceNumber }}{% else %} {% endif %}
-
{{ 'marello.pdf.invoice.debtor_number.label'|trans({}, 'pdf', language) }}:
-
{{ entity.customer.id }}
+ {% if entity.customer.company.companyNumber %} +
{{ 'marello.customer.company.pdf.company_number.label'|trans({}, 'pdf', language) }}:
+
{{ entity.customer.company.companyNumber }}
+ {% endif %}
From 0ac656700f6fc0fe9480eed802352d8d74e960f6 Mon Sep 17 00:00:00 2001 From: Hotlander Date: Mon, 15 Jun 2020 10:11:33 +0200 Subject: [PATCH 3/3] - removed commit reference in validation file --- .../Bundle/CustomerBundle/Resources/config/validation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml index 67a9d914b..fb93c4341 100644 --- a/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml +++ b/src/Marello/Bundle/CustomerBundle/Resources/config/validation.yml @@ -1,4 +1,3 @@ -<<<<<<< HEAD Marello\Bundle\CustomerBundle\Entity\Customer: properties: firstName: