Workflow/Activities/Companies/New.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« Plugin/Companies.pm ↑ Summary
1 package Daje::Workflow::Activities::Companies::New;
2 0 ▶use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=2.6
3 use v5.42;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Workflow::Activities::Companies::Activity - A workflow activity
9 #
10 # SYNOPSIS
11 # ========
12 #;
13 #
14 # DESCRIPTION
15 # ===========
16 #
17 # Daje::Workflow::Activities::Companies::Activity is a Daje workflow activity.
18 #
19 # METHODS
20 # =======
21 #
22 # Daje::Workflow::Activities::Companies::Activity inherits all methods from
23 # Daje::Workflow::Activities::Tools::Generate::Base and implements the following new ones.
24 #
25 # activity
26 #
27 # SEE ALSO
28 # ========
29 #
30 # Mojolicious, Mojolicious::Guides, https://mojolicious.org.
31 #
32 # LICENSE
33 # =======
34 #
35 # Copyright (C) janeskil1525.
36 #
37 # This library is free software; you can redistribute it and/or modify
38 # it under the same terms as Perl itself.
39 #
40 # AUTHOR
41 # ======
42 #
43 # janeskil1525 E<lt>janeskil1525@gmail.com
44 #
45  
46 # This file is generated once automatically by Daje Tools 2026-02-02 15:02:14.
47 # It will not be touched by Daje Tools again.
48  
49 # <!-- Autogenerated file 2026-02-02 15:02:14 -->
50  
51 use Daje::Database::Model::CompaniesCompanies;
52 use Daje::Database::Model::CompaniesUsers;
53 use Daje::Database::Model::UsersUsers;
54 use Data::Dumper;
55  
56 sub save_new_companies_companies($self) {
57  
58 $self->model->insert_history(
59 "New client",
60 "Daje::Workflow::Activities::Companies::New::save_new_companies_companies",
61 1
62 );
63  
64 try {
65 my $data = $self->context->{context}->{payload};
66 my $user = $data->{user};
67 $data->{companies_workflow_fkey} = $self->context->{context}->{workflow}->{workflow_fkey};
68 delete %$data{user};
69 my $companies_companies_pkey = Daje::Database::Model::CompaniesCompanies->new(
70 db => $self->db
71 )->insert($data)->{data}->{companies_companies_pkey};
72  
73 my $companies_user->{users_users_fkey} = $user->{users_users_pkey};
74 $companies_user->{companies_companies_fkey} = $companies_companies_pkey;
75 Daje::Database::Model::CompaniesUsers->new(
76 db => $self->db
77 )->insert($companies_user);
78  
79 my $active_user->{active} = "true";
80 $active_user->{users_users_pkey} = $user->{users_users_pkey};;
81 Daje::Database::Model::UsersUsers->new(
82 db => $self->db
83 )->update($active_user);
84  
85 $self->model->insert_history(
86 "New client " . $data->{name},
87 "Daje::Workflow::Activities::Companies::New::save_new_companies_companies",
88 2
89 );
90 } catch ($e) {
91 $self->error->add_error($e)
92 }
93  
94 }
95  
96 1;
97  
« Plugin/Companies.pm ↑ Summary