Code Duplication    Length = 38-40 lines in 2 locations

command/CreateFlightBillCommandHandler.php 1 location

@@ 49-88 (lines=40) @@
46
    /**
47
     * @param CreateFlightBillCommand $command
48
     */
49
    public function handle(CreateFlightBillCommand $command)
50
    {
51
        $flightProduct = $this->getProduct();
52
        $flight = $this->getFlight($command->getFlightId());
53
54
        $object = new Facture($this->db);
55
        $object->fetch_thirdparty();
56
57
        $object->socid = $this->getCustomer()->id;
58
        $object->type = $command->getBillType();
59
        $object->number = "provisoire";
60
        $object->date = $flight->date;
61
        $object->date_pointoftax = "";
62
        $object->note_public = $command->getPublicNote();
63
        $object->note_private = $command->getPrivateNote();
64
        $object->ref_client = "";
65
        $object->ref_int = "";
66
        $object->modelpdf = $command->getModelDocument();
67
        $object->cond_reglement_id = $command->getBillingCondition();
68
        $object->mode_reglement_id = $command->getBillingType();
69
        $object->fk_account = $command->getBankAccount();
70
71
        $id = $object->create($this->user);
72
73
        if ($id <= 0) {
74
            throw new \InvalidArgumentException('Error during bill creation');
75
        }
76
77
        $this->addOrderLine($object, $flightProduct, $flight);
78
79
        $this->addLinks($object, $flight);
80
        $this->addContacts($object, $flight);
81
82
        $this->generateBillDocument($command, $object, $id);
83
84
        $this->validates($object, $id);
85
86
        $this->generateBillDocument($command, $object, $id);
87
        $this->flagFlightAsBilled($flight);
88
    }
89
90
    /**
91
     * @return Product

command/CreateReceiverMonthBillCommandHandler.php 1 location

@@ 21-58 (lines=38) @@
18
    /**
19
     * @param CreateReceiverMonthBillCommand|CommandInterface $command
20
     */
21
    public function handle(CommandInterface $command)
22
    {
23
        $object = new Facture($this->db);
24
        $object->fetch_thirdparty();
25
26
        $object->socid = $this->getCustomer($command->getReceiverId())->id;
27
        $object->type = $command->getBillingType();
28
        $object->number = "provisoire";
29
        $object->date = $this->generateBillDate($command->getYear(), $command->getMonth());
30
        $object->date_pointoftax = "";
31
        $object->note_public = $command->getPublicNote();
32
        $object->note_private = $command->getPrivateNote();
33
        $object->ref_client = "";
34
        $object->ref_int = "";
35
        $object->modelpdf = $command->getModelDocument();
36
        $object->cond_reglement_id = $command->getBillingCondition();
37
        $object->mode_reglement_id = $command->getBillType();
38
        $object->fk_account = $this->getBankAccount();
39
40
        $id = $object->create($this->user);
41
42
        if ($id <= 0) {
43
            throw new \InvalidArgumentException('Error during bill creation');
44
        }
45
46
        $flightProduct = $this->getProduct();
47
        foreach ($command->getFlights() as $flight) {
48
            $this->addOrderLine($object, $flightProduct, $flight);
49
            $this->addLinks($object, $flight);
50
            $this->flagFlightAsBilled($flight);
51
        }
52
53
        $this->generateBillDocument($command, $object, $id);
54
55
        $this->validates($object, $id);
56
57
        $this->generateBillDocument($command, $object, $id);
58
    }
59
60
61
    /**