MT#56417 make Provisioning Templates "contract_contact" and "contract" sections optional

to better fit the usecase of *updating* subscribers, we
make the contract and contract_contact sections no longer
mandatory.

Change-Id: If3c34f2cd3a5201cf7da2729369fd6b1003f1a80
mr11.3
Rene Krenn 3 years ago
parent b850771110
commit 7cbf2f64bd

@ -137,7 +137,7 @@ sub validate_template {
my ($data,$prefix) = @_;
$prefix //= 'template: ';
die($prefix . "not a hash\n") unless 'HASH' eq ref $data;
foreach my $section (qw/contract subscriber/) {
foreach my $section (qw/subscriber/) {
die($prefix . "section '$section' required\n") unless exists $data->{$section};
die($prefix . "section '$section' is not a hash\n") unless 'HASH' eq ref $data->{$section};
}
@ -804,7 +804,7 @@ sub _init_contract_context {
$c->log->debug("provisioning template - contract contact: " . Dumper($context->{contract_contact}));
}
{
if (exists $template->{contact}) {
my %contract = ();
my @identifiers = _get_identifiers($template->{contract});
foreach my $col (keys %{$template->{contract}}) {
@ -1097,6 +1097,7 @@ sub _create_contract_contact {
my ($c, $context, $schema) = @_;
if (exists $context->{contract_contact}) {
unless ($context->{contract_contact}->{id}) {
my $contact = $schema->resultset('contacts')->create(
$context->{contract_contact},
@ -1105,6 +1106,7 @@ sub _create_contract_contact {
$c->log->debug("provisioning template - contract contact id $context->{contract_contact}->{id} created");
}
}
}
@ -1112,6 +1114,7 @@ sub _create_contract {
my ($c, $context, $schema) = @_;
if (exists $context->{contract}) {
unless ($context->{contract}->{id}) {
$context->{contract}->{contact_id} //= $context->{contract_contact}->{id};
die("contact_id for contract required") unless $context->{contract}->{contact_id};
@ -1128,6 +1131,7 @@ sub _create_contract {
);
$c->log->debug("provisioning template - contract id $context->{contract}->{id} created");
}
}
}

Loading…
Cancel
Save