mirror of https://github.com/itflow-org/itflow
Fix Adding Expense on recurring stripe payments in cron
This commit is contained in:
parent
cece9ad46c
commit
2283ad0eb2
|
|
@ -750,6 +750,7 @@ while ($row = mysqli_fetch_array($sql_recurring_payments)) {
|
|||
$invoice_due = sanitizeInput($row['invoice_due']);
|
||||
$invoice_amount = floatval($row['invoice_amount']);
|
||||
$invoice_url_key = sanitizeInput($row['invoice_url_key']);
|
||||
$invoice_currency_code = sanitizeInput($row['invoice_currency_code']);
|
||||
$recurring_payment_account_id = intval($row['recurring_payment_account_id']);
|
||||
$recurring_payment_method = sanitizeInput($row['recurring_payment_method']);
|
||||
$recurring_payment_currency_code = sanitizeInput($row['recurring_payment_currency_code']);
|
||||
|
|
@ -780,6 +781,10 @@ while ($row = mysqli_fetch_array($sql_recurring_payments)) {
|
|||
$provider_name = sanitizeInput($saved_payment['payment_provider_name']);
|
||||
$provider_private_key = $saved_payment['payment_provider_private_key'];
|
||||
$account_id = intval($saved_payment['payment_provider_account']);
|
||||
$expense_category_id = intval($row['payment_provider_expense_category']);
|
||||
$expense_vendor_id = intval($row['payment_provider_expense_vendor']);
|
||||
$expense_percentage_fee = floatval($row['payment_provider_expense_percentage_fee']);
|
||||
$expense_flat_fee = floatval($row['payment_provider_expense_flat_fee']);
|
||||
$saved_payment_description = sanitizeInput($saved_payment['saved_payment_description']);
|
||||
$stripe_payment_method_id = $saved_payment['saved_payment_provider_method'];
|
||||
|
||||
|
|
@ -844,9 +849,9 @@ while ($row = mysqli_fetch_array($sql_recurring_payments)) {
|
|||
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Online Payment added (autopay)', history_invoice_id = $invoice_id");
|
||||
|
||||
// EXPENSE: Stripe gateway fee as an expense (if configured)
|
||||
if ($config_stripe_expense_vendor > 0 && $config_stripe_expense_category > 0) {
|
||||
$gateway_fee = round($invoice_amount * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
mysqli_query($mysqli, "INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_fee, expense_currency_code = '$pi_currency', expense_account_id = $config_stripe_account, expense_vendor_id = $config_stripe_expense_vendor, expense_client_id = $client_id, expense_category_id = $config_stripe_expense_category, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number in the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id'");
|
||||
if ($expense_vendor_id > 0 && $expense_category_id > 0) {
|
||||
$gateway_fee = round($invoice_amount * $expense_percentage_fee + $expense_flat_fee, 2);
|
||||
mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_fee, expense_currency_code = '$invoice_currency_code', expense_account_id = $account_id, expense_vendor_id = $expense_vendor_id, expense_client_id = $client_id, expense_category_id = $expense_category_id, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number In the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id'");
|
||||
}
|
||||
|
||||
// RECEIPT EMAIL
|
||||
|
|
|
|||
Loading…
Reference in New Issue