[freeside-commits] branch master updated. 247a72232486b809bd0f0d88f3506dc0a1e79d93

Justin DeVuyst justin at 420.am
Mon Mar 20 13:28:32 PDT 2017


The branch, master has been updated
       via  247a72232486b809bd0f0d88f3506dc0a1e79d93 (commit)
      from  b285918ec3ab6c8203e9f8feaf234da306456e5e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 247a72232486b809bd0f0d88f3506dc0a1e79d93
Author: Justin DeVuyst <justin at devuyst.com>
Date:   Mon Mar 20 16:17:56 2017 -0400

    Add configurable daily auto-disable for quotations.  See RT#74665.

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 34e465d..8d83f92 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1506,6 +1506,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'quotation_disable_after_days',
+    'section'     => 'quotations',
+    'description' => 'The number of days, if set, after which a non-converted quotation will be automatically disabled.',
+    'type'        => 'text'
+  },
+
+  {
     'key'         => 'invoice_print_pdf',
     'section'     => 'printing',
     'description' => 'For all invoice print operations, store postal invoices for download in PDF format rather than printing them directly.',
diff --git a/FS/FS/Cron/disable_quotation.pm b/FS/FS/Cron/disable_quotation.pm
new file mode 100644
index 0000000..fde2686
--- /dev/null
+++ b/FS/FS/Cron/disable_quotation.pm
@@ -0,0 +1,21 @@
+package FS::Cron::disable_quotation;
+
+use vars qw( @ISA @EXPORT_OK );
+use Exporter;
+use FS::UID qw(dbh);
+use FS::Conf;
+
+ at ISA = qw( Exporter );
+ at EXPORT_OK = qw( disable_quotation );
+
+sub disable_quotation {
+    if ( my $days = FS::Conf->new->config( 'quotation_disable_after_days' ) ) {
+        my $sth = dbh->prepare(
+            "UPDATE quotation SET disabled = 'Y' WHERE _date < ?"
+        ) or die dbh->errstr;
+        $sth->execute( time - ( $days * 86400 ) ) or die $sth->errstr;
+        dbh->commit or die dbh->errstr if $FS::UID::AutoCommit;
+    }
+}
+
+1;
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index b12f90b..67c4860 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -91,6 +91,10 @@ export_batch_submit(%opt);
 use FS::Cron::send_subscribed qw(send_subscribed);
 send_subscribed(%opt);
 
+#does nothing unless quotation_disable_after_days is set.
+use FS::Cron::disable_quotation qw(disable_quotation);
+disable_quotation();
+
 #clears out cacti imports & deletes select database cache files
 use FS::Cron::cleanup qw( cleanup cleanup_before_backup );
 cleanup_before_backup();

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                   |    7 +++++++
 FS/FS/Cron/disable_quotation.pm |   21 +++++++++++++++++++++
 FS/bin/freeside-daily           |    4 ++++
 3 files changed, 32 insertions(+)
 create mode 100644 FS/FS/Cron/disable_quotation.pm




More information about the freeside-commits mailing list