mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-19 10:40:36 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1ad2d5b40 | ||
|
|
03af3457ab | ||
|
|
0d35cffb83 |
No files matched your search
@@ -126,6 +126,7 @@ Estimates and invoices keep their number, date, customer, total and **man-hours*
|
|||||||
* Time lines are linked to their time activities, so QuickBooks marks the time as billed. Estimates the invoice was made from, or imported into it, are linked and closed when it's saved.
|
* Time lines are linked to their time activities, so QuickBooks marks the time as billed. Estimates the invoice was made from, or imported into it, are linked and closed when it's saved.
|
||||||
* **Custom fields from the work orders**: the issues behind an invoice are the ones its time lines and lineitems estimates name. Plugins can fill custom fields from them when they're imported, and block a save (e.g. redmine_qbo_vehicles fills the VIN and mileage and allows one vehicle per invoice). On its own, redmine_qbo leaves the boxes as typed.
|
* **Custom fields from the work orders**: the issues behind an invoice are the ones its time lines and lineitems estimates name. Plugins can fill custom fields from them when they're imported, and block a save (e.g. redmine_qbo_vehicles fills the VIN and mileage and allows one vehicle per invoice). On its own, redmine_qbo leaves the boxes as typed.
|
||||||
* **Sales person**: an invoice credits the sales person on the estimate it was made from (the first linked estimate that names one); if none does, the user who writes the invoice.
|
* **Sales person**: an invoice credits the sales person on the estimate it was made from (the first linked estimate that names one); if none does, the user who writes the invoice.
|
||||||
|
* Invoices show their status, worked out from the balance and due date like QuickBooks' invoice list: **Paid**, **Partially paid**, **Overdue**, **Open** or **Voided** (a zero total), on the customer page's invoice list and the invoice page.
|
||||||
* Invoices with a payment applied open read-only. The due date is left to QuickBooks (from the customer's terms) unless one is picked. The "default message shown on invoices" fills in the message.
|
* Invoices with a payment applied open read-only. The due date is left to QuickBooks (from the customer's terms) unless one is picked. The "default message shown on invoices" fills in the message.
|
||||||
|
|
||||||
### Payments
|
### Payments
|
||||||
@@ -142,7 +143,7 @@ Estimates and invoices keep their number, date, customer, total and **man-hours*
|
|||||||
**Business report** in the top menu compares, for a period (this or last month, quarter or year, or custom dates):
|
**Business report** in the top menu compares, for a period (this or last month, quarter or year, or custom dates):
|
||||||
|
|
||||||
* **Sales**: estimates written, invoices written and payments received (totals and counts), invoiced vs. estimated, collected vs. invoiced, and what's still owed on those invoices.
|
* **Sales**: estimates written, invoices written and payments received (totals and counts), invoiced vs. estimated, collected vs. invoiced, and what's still owed on those invoices.
|
||||||
* **Hours**: estimated hours on estimates, issues' estimated time, invoiced hours on invoices and time spent, with invoiced vs. spent and spent vs. estimated.
|
* **Hours**: estimated hours on estimates, issues' estimated time, invoiced hours on invoices and time spent, with spent vs. estimated, and the **cost performance index** (CPI = invoiced hours ÷ spent hours): green at 1.00 or more, yellow below 1, red below 0.80. Each month shows its CPI too.
|
||||||
* **By month**: every figure month by month, with totals.
|
* **By month**: every figure month by month, with totals.
|
||||||
|
|
||||||
Estimates, invoices and payments count by their QuickBooks date. Issues' estimated time counts issues created in the period, leaving out parents so subtasks aren't counted twice. Spent time counts time logged in the period. While estimates, invoices or payments are syncing, the report says so (with how many have been read) and refreshes every 30 seconds; the settings page's Synchronization table shows the same per type. Estimates and invoices synced before these figures were added have no total or hours until a full sync (the report says how many); run one again after changing the labor products/services.
|
Estimates, invoices and payments count by their QuickBooks date. Issues' estimated time counts issues created in the period, leaving out parents so subtasks aren't counted twice. Spent time counts time logged in the period. While estimates, invoices or payments are syncing, the report says so (with how many have been read) and refreshes every 30 seconds; the settings page's Synchronization table shows the same per type. Estimates and invoices synced before these figures were added have no total or hours until a full sync (the report says how many); run one again after changing the labor products/services.
|
||||||
|
|||||||
@@ -22,4 +22,11 @@ class Invoice < QboBaseModel
|
|||||||
doc_number
|
doc_number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Paid, partially paid, overdue, open or voided, from the cached total, balance and due date
|
||||||
|
# (RedmineQboBilling::InvoiceStatus); nil when the balance isn't cached
|
||||||
|
def status(today: User.current.today)
|
||||||
|
RedmineQboBilling::InvoiceStatus.status(total: self[:total_amount], balance: self[:balance],
|
||||||
|
due_date: self[:due_date], today: today)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<% unless invoices.empty? %>
|
<% unless invoices.empty? %>
|
||||||
|
<%= render partial: 'qbo_estimates/status_styles' %>
|
||||||
|
|
||||||
<%= form_with(url: invoice_path, method: :get) do |form| %>
|
<%= form_with(url: invoice_path, method: :get) do |form| %>
|
||||||
|
|
||||||
@@ -10,13 +11,19 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<div class="qbo-invoice-list">
|
||||||
<% invoices.sort.reverse.each do |invoice| %>
|
<% invoices.sort.reverse.each do |invoice| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<%= check_box_tag "invoice_ids[]", invoice.id, false, onchange: "updateLink()", data: { url: invoice_path(invoice), text: "Invoice ##{invoice.to_s}" }, class: "invoice-checkbox appointment" if invoices.count > 1 %>
|
<%= check_box_tag "invoice_ids[]", invoice.id, false, onchange: "updateLink()", data: { url: invoice_path(invoice), text: "Invoice ##{invoice.to_s}" }, class: "invoice-checkbox appointment" if invoices.count > 1 %>
|
||||||
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
||||||
|
<%# Paid / partially paid / overdue / open / voided, from the cached balance and due date %>
|
||||||
|
<% if (status = invoice.status) %>
|
||||||
|
<span class="qbo-estimate-status qbo-invoice-status-<%= status %>"><%= RedmineQboBilling::InvoiceStatus.label(status) %></span>
|
||||||
|
<% end %>
|
||||||
<%= render partial: 'qbo_invoices/invoice_actions', locals: { invoice: invoice } if RedmineQboBilling.invoice_writer? %>
|
<%= render partial: 'qbo_invoices/invoice_actions', locals: { invoice: invoice } if RedmineQboBilling.invoice_writer? %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% if invoices.count > 1 %>
|
<% if invoices.count > 1 %>
|
||||||
<%= form.submit t(:button_bulk_pdf) %>
|
<%= form.submit t(:button_bulk_pdf) %>
|
||||||
|
|||||||
@@ -15,9 +15,13 @@
|
|||||||
<% if form.sent? %>
|
<% if form.sent? %>
|
||||||
<span class="qbo-estimate-status qbo-estimate-status-sent"><%= l(:label_estimate_sent) %></span>
|
<span class="qbo-estimate-status qbo-estimate-status-sent"><%= l(:label_estimate_sent) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if invoice && form.locked == :paid %>
|
<% if invoice %>
|
||||||
<% fully_paid = form.balance.to_d.zero? %>
|
<% status = RedmineQboBilling::InvoiceStatus.status(total: form.total, balance: form.balance,
|
||||||
<span class="qbo-estimate-status qbo-estimate-status-<%= fully_paid ? 'closed' : 'accepted' %>"><%= l(fully_paid ? :label_invoice_paid : :label_invoice_partially_paid) %></span>
|
due_date: RedmineQboBilling::EstimateForm.date(form.due_date),
|
||||||
|
today: User.current.today) %>
|
||||||
|
<% if status %>
|
||||||
|
<span class="qbo-estimate-status qbo-invoice-status-<%= status %>"><%= RedmineQboBilling::InvoiceStatus.label(status) %></span>
|
||||||
|
<% end %>
|
||||||
<% elsif !invoice && form.txn_status.present? %>
|
<% elsif !invoice && form.txn_status.present? %>
|
||||||
<span class="qbo-estimate-status qbo-estimate-status-<%= form.txn_status.downcase %>"><%= form.txn_status %></span>
|
<span class="qbo-estimate-status qbo-estimate-status-<%= form.txn_status.downcase %>"><%= form.txn_status %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -7,4 +7,11 @@
|
|||||||
.qbo-estimate-status-closed, .qbo-estimate-status-converted { background: #e8eefa; color: #0d47a1; }
|
.qbo-estimate-status-closed, .qbo-estimate-status-converted { background: #e8eefa; color: #0d47a1; }
|
||||||
.qbo-estimate-status-rejected { background: #fdecea; color: #b71c1c; }
|
.qbo-estimate-status-rejected { background: #fdecea; color: #b71c1c; }
|
||||||
.qbo-estimate-list .qbo-estimate-status { font-size: .8em; padding: 1px 7px; margin-left: 4px; }
|
.qbo-estimate-list .qbo-estimate-status { font-size: .8em; padding: 1px 7px; margin-left: 4px; }
|
||||||
|
/* Invoices (RedmineQboBilling::InvoiceStatus) */
|
||||||
|
.qbo-invoice-status-paid { background: #e6f4e4; color: #108000; }
|
||||||
|
.qbo-invoice-status-partial { background: #fff4d6; color: #8a6100; }
|
||||||
|
.qbo-invoice-status-overdue { background: #fdecea; color: #b71c1c; }
|
||||||
|
.qbo-invoice-status-open { background: #e8eefa; color: #0d47a1; }
|
||||||
|
.qbo-invoice-status-voided { background: #eceef1; color: #6b6c72; text-decoration: line-through; }
|
||||||
|
.qbo-invoice-list .qbo-estimate-status { font-size: .8em; padding: 1px 7px; margin-left: 4px; }
|
||||||
</style>
|
</style>
|
||||||
@@ -91,8 +91,16 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<% cpi_badge = lambda do |cpi|
|
||||||
|
level = RedmineQboBilling::BusinessReport.cpi_level(cpi)
|
||||||
|
content_tag(:span, cpi.nil? ? '–' : format('%.2f', cpi), class: "qbo-cpi qbo-cpi-#{level || 'none'}")
|
||||||
|
end %>
|
||||||
|
<p class="qbo-report-cpi">
|
||||||
|
<span class="qbo-cpi-label" title="<%= l(:text_report_cpi) %>"><%= l(:label_report_cpi) %></span>
|
||||||
|
<%= cpi_badge.call(@report.cpi) %>
|
||||||
|
<em class="info"><%= l(:text_report_cpi) %></em>
|
||||||
|
</p>
|
||||||
<p class="qbo-report-ratios">
|
<p class="qbo-report-ratios">
|
||||||
<%= l(:label_report_invoiced_of_spent) %>: <strong><%= pct.call(ratios[:invoiced_of_spent]) %></strong><br />
|
|
||||||
<%= l(:label_report_spent_of_estimated) %>: <strong><%= pct.call(ratios[:spent_of_estimated]) %></strong>
|
<%= l(:label_report_spent_of_estimated) %>: <strong><%= pct.call(ratios[:spent_of_estimated]) %></strong>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -111,6 +119,7 @@
|
|||||||
<th><%= l(:label_report_issue_hours) %></th>
|
<th><%= l(:label_report_issue_hours) %></th>
|
||||||
<th><%= l(:label_report_invoice_hours) %></th>
|
<th><%= l(:label_report_invoice_hours) %></th>
|
||||||
<th><%= l(:label_report_spent_hours) %></th>
|
<th><%= l(:label_report_spent_hours) %></th>
|
||||||
|
<th class="cpi"><%= l(:label_report_cpi_short) %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -124,6 +133,7 @@
|
|||||||
<td><%= fmt_hours.call(row[:issue_hours]) %></td>
|
<td><%= fmt_hours.call(row[:issue_hours]) %></td>
|
||||||
<td><%= fmt_hours.call(row[:invoice_hours]) %></td>
|
<td><%= fmt_hours.call(row[:invoice_hours]) %></td>
|
||||||
<td><%= fmt_hours.call(row[:spent_hours]) %></td>
|
<td><%= fmt_hours.call(row[:spent_hours]) %></td>
|
||||||
|
<td class="cpi"><%= cpi_badge.call(RedmineQboBilling::BusinessReport.cpi(row[:invoice_hours], row[:spent_hours])) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -137,6 +147,7 @@
|
|||||||
<td><strong><%= fmt_hours.call(hours[:issue_hours]) %></strong></td>
|
<td><strong><%= fmt_hours.call(hours[:issue_hours]) %></strong></td>
|
||||||
<td><strong><%= fmt_hours.call(hours[:invoice_hours]) %></strong></td>
|
<td><strong><%= fmt_hours.call(hours[:invoice_hours]) %></strong></td>
|
||||||
<td><strong><%= fmt_hours.call(hours[:spent_hours]) %></strong></td>
|
<td><strong><%= fmt_hours.call(hours[:spent_hours]) %></strong></td>
|
||||||
|
<td class="cpi"><%= cpi_badge.call(@report.cpi) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
@@ -154,6 +165,15 @@
|
|||||||
.qbo-bar-payments, .qbo-bar-spent_hours { background: #5aa05a; }
|
.qbo-bar-payments, .qbo-bar-spent_hours { background: #5aa05a; }
|
||||||
.qbo-bar-issue_hours { background: #9b7fc0; }
|
.qbo-bar-issue_hours { background: #9b7fc0; }
|
||||||
.qbo-report-ratios { margin: 8px 4px; line-height: 1.7; }
|
.qbo-report-ratios { margin: 8px 4px; line-height: 1.7; }
|
||||||
|
.qbo-report-cpi { margin: 10px 4px 4px; }
|
||||||
|
.qbo-report-cpi .qbo-cpi-label { font-weight: 600; margin-right: 6px; }
|
||||||
|
.qbo-report-cpi .qbo-cpi { font-size: 1.3em; padding: 3px 12px; }
|
||||||
|
.qbo-report-cpi em.info { display: block; margin-top: 4px; }
|
||||||
|
.qbo-cpi { display: inline-block; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: #eceef1; color: #393a3d; }
|
||||||
|
.qbo-cpi-poor { background: #fdecea; color: #b71c1c; }
|
||||||
|
.qbo-cpi-under { background: #fff4d6; color: #8a6100; }
|
||||||
|
.qbo-cpi-good { background: #e6f4e4; color: #108000; }
|
||||||
|
table.qbo-report-months td.cpi, table.qbo-report-months th.cpi { text-align: center; }
|
||||||
.qbo-report-range { color: #666; margin: 4px 0 10px; }
|
.qbo-report-range { color: #666; margin: 4px 0 10px; }
|
||||||
.qbo-report-syncing ul { display: inline-block; text-align: left; margin: 6px 0 0; }
|
.qbo-report-syncing ul { display: inline-block; text-align: left; margin: 6px 0 0; }
|
||||||
table.qbo-report-months td, table.qbo-report-months th { text-align: right; white-space: nowrap; }
|
table.qbo-report-months td, table.qbo-report-months th { text-align: right; white-space: nowrap; }
|
||||||
|
|||||||
@@ -240,8 +240,11 @@ en:
|
|||||||
label_invoice_balance: "Balance due %{balance}"
|
label_invoice_balance: "Balance due %{balance}"
|
||||||
label_invoice_date: "Invoice date"
|
label_invoice_date: "Invoice date"
|
||||||
label_invoice_no: "Invoice no."
|
label_invoice_no: "Invoice no."
|
||||||
label_invoice_paid: "Paid"
|
label_invoice_status_paid: "Paid"
|
||||||
label_invoice_partially_paid: "Partially paid"
|
label_invoice_status_partial: "Partially paid"
|
||||||
|
label_invoice_status_overdue: "Overdue"
|
||||||
|
label_invoice_status_open: "Open"
|
||||||
|
label_invoice_status_voided: "Voided"
|
||||||
label_message_on_invoice: "Message displayed on invoice"
|
label_message_on_invoice: "Message displayed on invoice"
|
||||||
label_new_invoice: "New invoice"
|
label_new_invoice: "New invoice"
|
||||||
label_open_estimates: "Open estimates"
|
label_open_estimates: "Open estimates"
|
||||||
@@ -326,7 +329,9 @@ en:
|
|||||||
label_report_invoiced_of_estimated: "Invoiced vs. estimated"
|
label_report_invoiced_of_estimated: "Invoiced vs. estimated"
|
||||||
label_report_collected_of_invoiced: "Collected vs. invoiced"
|
label_report_collected_of_invoiced: "Collected vs. invoiced"
|
||||||
label_report_open_balance: "Still owed on these invoices"
|
label_report_open_balance: "Still owed on these invoices"
|
||||||
label_report_invoiced_of_spent: "Invoiced vs. spent hours"
|
label_report_cpi: "Cost performance index (CPI)"
|
||||||
|
label_report_cpi_short: "CPI"
|
||||||
|
text_report_cpi: "Invoiced hours ÷ spent hours. 1.00 or more (green): every hour worked was billed; below 1 (yellow): some time wasn't billed; below 0.80 (red): a fifth or more wasn't."
|
||||||
label_report_spent_of_estimated: "Spent vs. issues' estimated hours"
|
label_report_spent_of_estimated: "Spent vs. issues' estimated hours"
|
||||||
text_report_syncing: "QuickBooks is still syncing, so these figures are incomplete until it finishes. This page refreshes every 30 seconds."
|
text_report_syncing: "QuickBooks is still syncing, so these figures are incomplete until it finishes. This page refreshes every 30 seconds."
|
||||||
text_qbo_sync_running: "syncing, %{count} read so far (started %{time})"
|
text_qbo_sync_running: "syncing, %{count} read so far (started %{time})"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
name 'Redmine QBO plugin'
|
name 'Redmine QBO plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'A pluging for Redmine to connect with QuickBooks Online: customers, time activities for billable hours when an issue is closed, and estimates, invoices and payments written in Redmine'
|
description 'A pluging for Redmine to connect with QuickBooks Online: customers, time activities for billable hours when an issue is closed, and estimates, invoices and payments written in Redmine'
|
||||||
version '2026.11.3'
|
version '2026.11.4'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
settings default: {empty: true}, partial: 'qbo/settings'
|
settings default: {empty: true}, partial: 'qbo/settings'
|
||||||
|
|||||||
@@ -79,6 +79,26 @@ module RedmineQboBilling
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Cost performance index: invoiced hours / spent hours (e.g. 0.85), or nil without spent time. Below
|
||||||
|
# CPI_WARNING (0.8) is poor, below 1 is under, 1 or more is on or over (more billed than worked).
|
||||||
|
CPI_WARNING = 0.8
|
||||||
|
|
||||||
|
def self.cpi(invoice_hours, spent_hours)
|
||||||
|
spent = spent_hours.to_f
|
||||||
|
spent.positive? ? (invoice_hours.to_f / spent).round(2) : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# :poor (below 0.8), :under (below 1) or :good (1 or more); nil without a CPI
|
||||||
|
def self.cpi_level(cpi)
|
||||||
|
return nil if cpi.nil?
|
||||||
|
return :poor if cpi < CPI_WARNING
|
||||||
|
cpi < 1 ? :under : :good
|
||||||
|
end
|
||||||
|
|
||||||
|
def cpi
|
||||||
|
self.class.cpi(hours[:invoice_hours], hours[:spent_hours])
|
||||||
|
end
|
||||||
|
|
||||||
# Percentages comparing the figures (nil when there's nothing to compare against)
|
# Percentages comparing the figures (nil when there's nothing to compare against)
|
||||||
def ratios
|
def ratios
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2026 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
module RedmineQboBilling
|
||||||
|
# An invoice's status, worked out from its total, balance and due date the way QuickBooks' invoice list
|
||||||
|
# shows it (QuickBooks keeps no status field on invoices):
|
||||||
|
# :voided - nothing to pay at all (a voided invoice has a zero total)
|
||||||
|
# :paid - nothing left owing
|
||||||
|
# :partial - some of it paid
|
||||||
|
# :overdue - money owing and past the due date
|
||||||
|
# :open - money owing, not yet due
|
||||||
|
# nil when the balance isn't known (e.g. an invoice synced before balances were kept).
|
||||||
|
module InvoiceStatus
|
||||||
|
STATUSES = %i[voided paid partial overdue open].freeze
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def status(total:, balance:, due_date: nil, today: Date.current)
|
||||||
|
return nil if balance.nil? || balance.to_s.strip.empty?
|
||||||
|
|
||||||
|
total = to_d(total)
|
||||||
|
balance = to_d(balance)
|
||||||
|
return :voided if total.zero? && balance.zero?
|
||||||
|
return :paid if balance <= 0
|
||||||
|
return :overdue if due_date && due_date < today
|
||||||
|
balance < total ? :partial : :open
|
||||||
|
end
|
||||||
|
|
||||||
|
def label(status)
|
||||||
|
status ? I18n.t("label_invoice_status_#{status}") : ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_d(value)
|
||||||
|
BigDecimal(value.to_s.presence || '0')
|
||||||
|
rescue ArgumentError
|
||||||
|
BigDecimal('0')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in new issue
Block a user