Feature: Late Fees can now be assessed to unpaid invoices

This commit is contained in:
johnnyq 2023-07-11 11:40:53 -04:00
parent eb1e792e77
commit bb16c4b7b8
6 changed files with 46 additions and 6 deletions

View File

@ -1139,11 +1139,22 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.2'");
}
//if (CURRENT_DATABASE_VERSION == '0.6.2') {
//Insert queries here required to update to DB version 0.6.2
if (CURRENT_DATABASE_VERSION == '0.6.2') {
//Insert queries here required to update to DB version 0.6.3
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_invoice_late_fee_enable` TINYINT(1) NOT NULL DEFAULT 0 AFTER `config_invoice_from_email`");
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_invoice_late_fee_percent` DECIMAL(5,2) NOT NULL DEFAULT 0 AFTER `config_invoice_late_fee_enable`");
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.2'");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.3'");
}
//if (CURRENT_DATABASE_VERSION == '0.6.3') {
//Insert queries here required to update to DB version 0.6.4
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.4'");
//}
} else {

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "0.6.2");
DEFINE("LATEST_DATABASE_VERSION", "0.6.3");

4
db.sql
View File

@ -1134,6 +1134,8 @@ CREATE TABLE `settings` (
`config_invoice_footer` text DEFAULT NULL,
`config_invoice_from_name` varchar(200) DEFAULT NULL,
`config_invoice_from_email` varchar(200) DEFAULT NULL,
`config_invoice_late_fee_enable` tinyint(1) NOT NULL DEFAULT 0,
`config_invoice_late_fee_percent` decimal(5,2) NOT NULL DEFAULT 0.00,
`config_recurring_prefix` varchar(200) DEFAULT NULL,
`config_recurring_next_number` int(11) NOT NULL,
`config_quote_prefix` varchar(200) DEFAULT NULL,
@ -1618,4 +1620,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-07-03 20:22:39
-- Dump completed on 2023-07-11 11:40:09

View File

@ -42,6 +42,8 @@ $config_invoice_next_number = intval($row['config_invoice_next_number']);
$config_invoice_footer = $row['config_invoice_footer'];
$config_invoice_from_name = $row['config_invoice_from_name'];
$config_invoice_from_email = $row['config_invoice_from_email'];
$config_invoice_late_fee_enable = intval($row['config_invoice_late_fee_enable']);
$config_invoice_late_fee_percent = floatval($row['config_invoice_late_fee_percent']);
// Recurring
$config_recurring_prefix = $row['config_recurring_prefix'];

View File

@ -157,10 +157,13 @@ if (isset($_POST['edit_invoice_settings'])) {
$config_invoice_footer = sanitizeInput($_POST['config_invoice_footer']);
$config_invoice_from_email = sanitizeInput($_POST['config_invoice_from_email']);
$config_invoice_from_name = sanitizeInput($_POST['config_invoice_from_name']);
$config_invoice_late_fee_enable = intval($_POST['config_invoice_late_fee_enable']);
$config_invoice_late_fee_percent = floatval($_POST['config_invoice_late_fee_percent']);
$config_recurring_prefix = sanitizeInput($_POST['config_recurring_prefix']);
$config_recurring_next_number = intval($_POST['config_recurring_next_number']);
mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_invoice_footer = '$config_invoice_footer', config_invoice_from_email = '$config_invoice_from_email', config_invoice_from_name = '$config_invoice_from_name', config_recurring_prefix = '$config_recurring_prefix', config_recurring_next_number = $config_recurring_next_number WHERE company_id = 1");
mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_invoice_footer = '$config_invoice_footer', config_invoice_from_email = '$config_invoice_from_email', config_invoice_from_name = '$config_invoice_from_name', config_invoice_late_fee_enable = $config_invoice_late_fee_enable, config_invoice_late_fee_percent = $config_invoice_late_fee_percent, config_recurring_prefix = '$config_recurring_prefix', config_recurring_next_number = $config_recurring_next_number WHERE company_id = 1");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified invoice settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");

View File

@ -57,6 +57,28 @@ require_once("inc_all_settings.php"); ?>
<hr>
<legend>Invoice Late Fees</legend>
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" name="config_invoice_late_fee_enable" <?php if ($config_invoice_late_fee_enable == 1) { echo "checked"; } ?> value="1" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Enable Late Fee</label>
</div>
</div>
<div class="form-group">
<label>Late Fee %</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
</div>
<input type="number" class="form-control" min="0" max="100" step="0.01" name="config_invoice_late_fee_percent" value="<?php echo $config_invoice_late_fee_percent; ?>">
</div>
<small class="text-secondary">We recommend updating the invoice footer to include policies on your late charges. This will be applied every 30 days after the invoice Due Date.</small>
</div>
<hr>
<legend>Recurring Invoice</legend>
<div class="form-group">