better method to compare dates, ignore future year for multiyear payments
This commit is contained in:
parent
7e05e83022
commit
49fb992d75
11
notify.pl
11
notify.pl
|
@ -32,7 +32,7 @@ my $function = $ARGV[0] || "empty";
|
||||||
my $function_variable = $ARGV[1] || "empty";
|
my $function_variable = $ARGV[1] || "empty";
|
||||||
|
|
||||||
# define the prices for the different components of the VM
|
# define the prices for the different components of the VM
|
||||||
my $base_price = '60';
|
my $base_price = '64';
|
||||||
my %memory_prices = ('2G' => '10', '4G' => '30', '8G' => '70');
|
my %memory_prices = ('2G' => '10', '4G' => '30', '8G' => '70');
|
||||||
my %hdd_prices = ('50G' => '50', '100G' => '100', '150G' => '150', '200G' => '200');
|
my %hdd_prices = ('50G' => '50', '100G' => '100', '150G' => '150', '200G' => '200');
|
||||||
|
|
||||||
|
@ -183,10 +183,13 @@ if ($function =~ /notify/) {
|
||||||
my $month = strftime("%m", localtime);
|
my $month = strftime("%m", localtime);
|
||||||
for my $vm_name (sort keys %vms) {
|
for my $vm_name (sort keys %vms) {
|
||||||
if ($vms{$vm_name}{'donated'} =~ /(done|expire|sponsor|renewal)/) { delete $vms{$vm_name}; next; }
|
if ($vms{$vm_name}{'donated'} =~ /(done|expire|sponsor|renewal)/) { delete $vms{$vm_name}; next; }
|
||||||
if ($vms{$vm_name}{'date'} =~ /$year\//) { delete $vms{$vm_name}; next; }
|
|
||||||
if ($vms{$vm_name}{'date'} !~ /\/$month\//) { delete $vms{$vm_name}; next; }
|
my ($_vm_year, $_vm_month, $_vm_day) = split('/', $vms{$vm_name}{'date'});
|
||||||
|
if ($_vm_year >= $year) { delete $vms{$vm_name}; next; }
|
||||||
|
if ($_vm_month != $month) { delete $vms{$vm_name}; next; }
|
||||||
|
|
||||||
if ($function =~ /(renewal|deprovision)/) {
|
if ($function =~ /(renewal|deprovision)/) {
|
||||||
if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} =~ /yes/) { delete $vms{$vm_name}; next; }
|
if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} ne "") { delete $vms{$vm_name}; next; }
|
||||||
}
|
}
|
||||||
if ($function =~ /subscription/) {
|
if ($function =~ /subscription/) {
|
||||||
if (!defined $vms{$vm_name}{'subscription'} or $vms{$vm_name}{'subscription'} eq "" or $vms{$vm_name}{'subscription'} =~ /no/) { delete $vms{$vm_name}; next; }
|
if (!defined $vms{$vm_name}{'subscription'} or $vms{$vm_name}{'subscription'} eq "" or $vms{$vm_name}{'subscription'} =~ /no/) { delete $vms{$vm_name}; next; }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
mac="fe:e1:ab:dd:73:a4"
|
mac="fe:e1:ab:dd:73:a4"
|
||||||
ip="192.168.1.1"
|
ip="192.168.1.1"
|
||||||
owner="testuser1"
|
owner="testuser1"
|
||||||
date="2018/12/02"
|
date="2018/01/02"
|
||||||
payment="70"
|
payment="70"
|
||||||
donated=""
|
donated=""
|
||||||
name="Test1 User"
|
name="Test1 User"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
date="2018/07/02"
|
date="2018/02/02"
|
||||||
payment="70"
|
payment="70"
|
||||||
subscription=""
|
subscription=""
|
||||||
donated=""
|
donated=""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
date="2020/07/21"
|
date="2020/01/21"
|
||||||
payment="60"
|
payment="60"
|
||||||
subscription="yes"
|
subscription="yes"
|
||||||
donated=""
|
donated=""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
date="2020/07/21"
|
date="2024/01/21"
|
||||||
payment="60"
|
payment="sponsor"
|
||||||
subscription="no"
|
subscription=""
|
||||||
donated=""
|
donated="sponsor"
|
||||||
name="Test3"
|
name="Test3"
|
||||||
email="vm03@high5.nl"
|
email="vm03@high5.nl"
|
||||||
sshkey="ssh-ed25519 AAAAC3NzDI1NTE5AaaaIK7lMIQ4L4GcOyclKj9WLQPnHrGuP5ExjxZVmvLn"
|
sshkey="ssh-ed25519 AAAAC3NzDI1NTE5AaaaIK7lMIQ4L4GcOyclKj9WLQPnHrGuP5ExjxZVmvLn"
|
||||||
|
|
Loading…
Reference in New Issue