diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php
index 1e803faf10cd..8884dbdef622 100644
--- a/app/Services/Payment/DeletePayment.php
+++ b/app/Services/Payment/DeletePayment.php
@@ -109,7 +109,11 @@ class DeletePayment
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
- } else {
+ }
+ elseif($paymentable_invoice->balance == 0){
+ $paymentable_invoice->service()->setStatus(Invoice::STATUS_PAID)->save();
+ }
+ else {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
}
} else {
diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 538b40b1d311..01d2d7d6fe43 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -670,16 +670,16 @@ class HtmlEngine
$data['$payment.transaction_reference'] = ['value' => '', 'label' => ctrans('texts.transaction_reference')];
- if ($this->entity_string == 'invoice' && $this->entity->payments()->exists()) {
+ if ($this->entity_string == 'invoice' && $this->entity->net_payments()->exists()) {
$payment_list = '
';
- foreach ($this->entity->payments as $payment) {
+ foreach ($this->entity->net_payments as $payment) {
$payment_list .= ctrans('texts.payment_subject') . ": " . $this->formatDate($payment->date, $this->client->date_format()) . " :: " . Number::formatMoney($payment->amount, $this->client) ." :: ". GatewayType::getAlias($payment->gateway_type_id) . "
";
}
$data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')];
- $payment = $this->entity->payments()->first();
+ $payment = $this->entity->net_payments()->first();
$data['$payment.custom1'] = ['value' => $payment->custom_value1, 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment1')];
$data['$payment.custom2'] = ['value' => $payment->custom_value2, 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment2')];