Browse Source

Refactoring services #885

refactoring
Guillaume 1 year ago
parent
commit
48f99d38ef
19 changed files with 189 additions and 32 deletions
  1. +5
    -0
      common/logic/Distribution/Distribution/Distribution.php
  2. +10
    -0
      common/logic/Distribution/PointSaleDistribution/PointSaleDistribution.php
  3. +10
    -0
      common/logic/Distribution/ProductDistribution/ProductDistribution.php
  4. +10
    -0
      common/logic/Document/Document/Document.php
  5. +25
    -1
      common/logic/Order/Order/Order.php
  6. +10
    -0
      common/logic/Order/OrderStatusHistory/OrderStatusHistory.php
  7. +3
    -3
      common/logic/Order/ProductOrder/ProductOrder.php
  8. +8
    -12
      common/logic/PointSale/PointSale/PointSale.php
  9. +5
    -0
      common/logic/PointSale/UserPointSale/UserPointSale.php
  10. +6
    -4
      common/logic/Producer/Producer/Producer.php
  11. +10
    -0
      common/logic/Product/Product/Product.php
  12. +10
    -0
      common/logic/Product/ProductPointSale/ProductPointSale.php
  13. +20
    -0
      common/logic/Product/ProductPrice/ProductPrice.php
  14. +5
    -0
      common/logic/Subscription/ProductSubscription/ProductSubscription.php
  15. +15
    -0
      common/logic/Subscription/Subscription/Subscription.php
  16. +15
    -0
      common/logic/User/CreditHistory/CreditHistory.php
  17. +7
    -12
      common/logic/User/UserProducer/UserProducer.php
  18. +10
    -0
      common/logic/User/UserProducer/UserProducerRepository.php
  19. +5
    -0
      common/logic/User/UserUserGroup/UserUserGroup.php

+ 5
- 0
common/logic/Distribution/Distribution/Distribution.php View File

@@ -87,6 +87,11 @@ class Distribution extends ActiveRecordCommon
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function populateProducer(Producer $producer): void
{
$this->populateFieldObject('id_producer', 'producer', $producer);
}

public function getOrder()
{
return $this->hasMany(Order::class, ['id_distribution' => 'id']);

+ 10
- 0
common/logic/Distribution/PointSaleDistribution/PointSaleDistribution.php View File

@@ -86,8 +86,18 @@ class PointSaleDistribution extends ActiveRecordCommon
return $this->hasOne(Distribution::class, ['id' => 'id_distribution']);
}

public function populateDistribution(Distribution $distribution): void
{
$this->populateFieldObject('id_distribution', 'distribution', $distribution);
}

public function getPointSale()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}
}

+ 10
- 0
common/logic/Distribution/ProductDistribution/ProductDistribution.php View File

@@ -85,9 +85,19 @@ class ProductDistribution extends ActiveRecordCommon
{
return $this->hasOne(Product::class, ['id' => 'id_product']);
}

public function populateProduct(Product $product): void
{
$this->populateFieldObject('id_product', 'product', $product);
}
public function getDistribution()
{
return $this->hasOne(Distribution::class, ['id' => 'id_distribution']);
}

public function populateDistribution(Distribution $distribution): void
{
$this->populateFieldObject('id_distribution', 'distribution', $distribution);
}
}

+ 10
- 0
common/logic/Document/Document/Document.php View File

@@ -106,11 +106,21 @@ class Document extends ActiveRecordCommon implements DocumentInterface
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}

public function getProducer()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function populateProducer(Producer $producer): void
{
$this->populateFieldObject('id_producer', 'producer', $producer);
}

public function relationOrders($fieldIdDocument)
{
$orderRepository = new OrderRepository();

+ 25
- 1
common/logic/Order/Order/Order.php View File

@@ -171,13 +171,17 @@ class Order extends ActiveRecordCommon
$this->populateFieldObject('id_distribution', 'distribution', $distribution);
}


public function getPointSale()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale'])
->with('userPointSale');
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'point_sale', $pointSale);
}

public function getCreditHistory()
{
return $this->hasMany(CreditHistory::class, ['id_order' => 'id']);
@@ -189,18 +193,38 @@ class Order extends ActiveRecordCommon
->with('productSubscription');
}

public function populateSubscription(Subscription $subscription): void
{
$this->populateFieldObject('id_subscription', 'subscription', $subscription);
}

public function getInvoice()
{
return $this->hasOne(Invoice::class, ['id' => 'id_invoice']);
}

public function populateInvoice(Invoice $invoice): void
{
$this->populateFieldObject('id_invoice', 'invoice', $invoice);
}

public function getQuotation()
{
return $this->hasOne(Quotation::class, ['id' => 'id_quotation']);
}

public function populateQuotation(Quotation $quotation): void
{
$this->populateFieldObject('id_quotation', 'quotation', $quotation);
}

public function getDeliveryNote()
{
return $this->hasOne(DeliveryNote::class, ['id' => 'id_delivery_note']);
}

public function populateDeliveryNote(DeliveryNote $deliveryNote): void
{
$this->populateFieldObject('id_delivery_note', 'deliveryNote', $deliveryNote);
}
}

+ 10
- 0
common/logic/Order/OrderStatusHistory/OrderStatusHistory.php View File

@@ -55,8 +55,18 @@ class OrderStatusHistory extends ActiveRecordCommon
return $this->hasOne(Order::class, ['id' => 'id_order']);
}

public function populateOrder(Order $order): void
{
$this->populateFieldObject('id_order', 'order', $order);
}

public function getUser()
{
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}
}

+ 3
- 3
common/logic/Order/ProductOrder/ProductOrder.php View File

@@ -69,7 +69,7 @@ class ProductOrder extends ActiveRecordCommon

public function populateProduct(Product $product)
{
$this->populateFieldObject('product', 'id_product', $product);
$this->populateFieldObject('id_product', 'product', $product);
}

public function getOrder()
@@ -79,7 +79,7 @@ class ProductOrder extends ActiveRecordCommon

public function populateOrder(Order $order)
{
$this->populateFieldObject('order', 'id_order', $order);
$this->populateFieldObject('id_order', 'order', $order);
}

public function getTaxRate()
@@ -89,7 +89,7 @@ class ProductOrder extends ActiveRecordCommon

public function populateTaxRate(TaxRate $taxRate)
{
$this->populateFieldObject('taxRate', 'id_tax_rate', $taxRate);
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate);
}

/**

+ 8
- 12
common/logic/PointSale/PointSale/PointSale.php View File

@@ -133,26 +133,22 @@ class PointSale extends ActiveRecordCommon

public function getUserPointSale()
{
return $this->hasMany(
UserPointSale::class,
['id_point_sale' => 'id']
);
return $this->hasMany(UserPointSale::class, ['id_point_sale' => 'id']);
}

public function getPointSaleDistribution()
{
return $this->hasMany(
PointSaleDistribution::class,
['id_point_sale' => 'id']
);
return $this->hasMany(PointSaleDistribution::class, ['id_point_sale' => 'id']);
}

public function getUser()
{
return $this->hasOne(
User::class,
['id' => 'id_user']
);
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}

/**

+ 5
- 0
common/logic/PointSale/UserPointSale/UserPointSale.php View File

@@ -83,4 +83,9 @@ class UserPointSale extends ActiveRecordCommon
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}
}

+ 6
- 4
common/logic/Producer/Producer/Producer.php View File

@@ -404,10 +404,7 @@ class Producer extends ActiveRecordCommon

public function getUserProducer()
{
return $this->hasMany(
UserProducer::class,
['id_producer' => 'id']
);
return $this->hasMany(UserProducer::class, ['id_producer' => 'id']);
}

public function getUser()
@@ -426,6 +423,11 @@ class Producer extends ActiveRecordCommon
return $this->hasOne(TaxRate::class, ['id' => 'id_tax_rate_default']);
}

public function populateTaxRate(TaxRate $taxRate): void
{
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate);
}

// ---

public static function getBillingTypePopulateDropdown()

+ 10
- 0
common/logic/Product/Product/Product.php View File

@@ -207,6 +207,11 @@ class Product extends ActiveRecordCommon
return $this->hasOne(TaxRate::class, ['id' => 'id_tax_rate']);
}

public function populateTaxRate(TaxRate $taxRate): void
{
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate);
}

public function getProductPrice()
{
return $this->hasMany( ProductPrice::class, ['id_product' => 'id']);
@@ -217,6 +222,11 @@ class Product extends ActiveRecordCommon
return $this->hasOne( ProductCategory::class, ['id' => 'id_product_category']);
}

public function populateProductCategory(ProductCategory $productCategory): void
{
$this->populateFieldObject('id_product_category', 'productCategory', $productCategory);
}

public function getProductPointSale()
{
return $this->hasMany(ProductPointSale::class, ['id_product' => 'id']);

+ 10
- 0
common/logic/Product/ProductPointSale/ProductPointSale.php View File

@@ -89,8 +89,18 @@ class ProductPointSale extends ActiveRecordCommon
return $this->hasOne( Product::class, ['id' => 'id_product']);
}

public function populateProduct(Product $product): void
{
$this->populateFieldObject('id_product', 'product', $product);
}

public function getPointSale()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}
}

+ 20
- 0
common/logic/Product/ProductPrice/ProductPrice.php View File

@@ -130,18 +130,38 @@ class ProductPrice extends ActiveRecordCommon
return $this->hasOne(Product::class, ['id' => 'id_product']);
}

public function populateProduct(Product $product): void
{
$this->populateFieldObject('id_product', 'product', $product);
}

public function getPointSale()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}

public function getUserGroup()
{
return $this->hasOne(UserGroup::class, ['id' => 'id_user_group']);
}

public function populateUserGroup(UserGroup $userGroup): void
{
$this->populateFieldObject('id_user_group', 'userGroup', $userGroup);
}

public function getUser()
{
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}
}

+ 5
- 0
common/logic/Subscription/ProductSubscription/ProductSubscription.php View File

@@ -89,4 +89,9 @@ class ProductSubscription extends ActiveRecordCommon
{
return $this->hasOne(Product::class, ['id' => 'id_product']);
}

public function populateProduct(Product $product): void
{
$this->populateFieldObject('id_product', 'product', $product);
}
}

+ 15
- 0
common/logic/Subscription/Subscription/Subscription.php View File

@@ -112,16 +112,31 @@ class Subscription extends ActiveRecordCommon
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}

public function getProducer()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function populateProducer(Producer $producer): void
{
$this->populateFieldObject('id_producer', 'producer', $producer);
}

public function getPointSale()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}

public function getProductSubscription()
{
return $this->hasMany(ProductSubscription::class, ['id_subscription' => 'id'])

+ 15
- 0
common/logic/User/CreditHistory/CreditHistory.php View File

@@ -103,6 +103,11 @@ class CreditHistory extends ActiveRecordCommon
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}

public function getUserObject(): ?User
{
return $this->user;
@@ -113,6 +118,11 @@ class CreditHistory extends ActiveRecordCommon
return $this->hasOne(User::class, ['id' => 'id_user_action']);
}

public function populateUserAction(User $user): void
{
$this->populateFieldObject('id_user_action', 'userAction', $user);
}

public function getUserActionObject(): ?User
{
return $this->userAction;
@@ -123,6 +133,11 @@ class CreditHistory extends ActiveRecordCommon
return $this->hasOne(Order::class, ['id' => 'id_order']);
}

public function populateOrder(Order $order): void
{
$this->populateFieldObject('id_order', 'order', $order);
}

public function getOrderObject(): ?Order
{
return $this->order;

+ 7
- 12
common/logic/User/UserProducer/UserProducer.php View File

@@ -89,24 +89,19 @@ class UserProducer extends ActiveRecordCommon
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function populateProducer(Producer $producer): void
{
$this->populateFieldObject('id_producer', 'producer', $producer);
}

public function getUser()
{
return $this->hasOne(User::class, ['id' => 'id_user']);
}

/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function defaultOptionsSearch()
public function populateUser(User $user): void
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'user_producer.id_producer'
];
$this->populateFieldObject('id_user', 'user', $user);
}

public function getIdUser(): int

+ 10
- 0
common/logic/User/UserProducer/UserProducerRepository.php View File

@@ -9,6 +9,16 @@ use common\logic\User\User\User;

class UserProducerRepository extends BaseService implements RepositoryInterface
{
public function defaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'user_producer.id_producer'
];
}

public function getOne(User $user, Producer $producer)
{
return UserProducer::searchOne([

+ 5
- 0
common/logic/User/UserUserGroup/UserUserGroup.php View File

@@ -82,4 +82,9 @@ class UserUserGroup extends ActiveRecordCommon
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function populatePointSale(PointSale $pointSale): void
{
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale);
}
}

Loading…
Cancel
Save