mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
e5043ed684
@ -1 +1 @@
|
||||
5.8.32
|
||||
5.8.33
|
@ -827,7 +827,14 @@ class BaseExport
|
||||
|
||||
}
|
||||
|
||||
public function applyFilters(Builder $query): Builder
|
||||
/**
|
||||
* Apply Product Filters
|
||||
*
|
||||
* @param Builder $query
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
public function applyProductFilters(Builder $query): Builder
|
||||
{
|
||||
|
||||
if(isset($this->input['product_key'])) {
|
||||
@ -845,7 +852,15 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addClientFilter($query, $clients): Builder
|
||||
/**
|
||||
* Add Client Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $clients
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addClientFilter(Builder $query, string $clients): Builder
|
||||
{
|
||||
if(is_string($clients)) {
|
||||
$clients = explode(',', $clients);
|
||||
@ -863,7 +878,15 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addVendorFilter($query, $vendors): Builder
|
||||
/**
|
||||
* Add Vendor Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $vendors
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addVendorFilter(Builder$query, string $vendors): Builder
|
||||
{
|
||||
|
||||
if(is_string($vendors)) {
|
||||
@ -879,7 +902,15 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addProjectFilter($query, $projects): Builder
|
||||
/**
|
||||
* AddProjectFilter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $projects
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addProjectFilter(Builder $query, string $projects): Builder
|
||||
{
|
||||
|
||||
if(is_string($projects)) {
|
||||
@ -895,7 +926,15 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addCategoryFilter($query, $expense_categories): Builder
|
||||
/**
|
||||
* Add Category Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $expense_categories
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addCategoryFilter(Builder $query, string $expense_categories): Builder
|
||||
{
|
||||
|
||||
if(is_string($expense_categories)) {
|
||||
@ -912,12 +951,229 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addInvoiceStatusFilter($query, $status): Builder
|
||||
/**
|
||||
* Add Payment Status Filters
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addPaymentStatusFilters(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if(in_array('all', $status_parameters)) {
|
||||
if(in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->where(function ($query) use ($status_parameters) {
|
||||
$payment_filters = [];
|
||||
|
||||
if (in_array('pending', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_PENDING;
|
||||
}
|
||||
|
||||
if (in_array('cancelled', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if (in_array('failed', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_FAILED;
|
||||
}
|
||||
|
||||
if (in_array('completed', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_COMPLETED;
|
||||
}
|
||||
|
||||
if (in_array('partially_refunded', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_PARTIALLY_REFUNDED;
|
||||
}
|
||||
|
||||
if (in_array('refunded', $status_parameters)) {
|
||||
$payment_filters[] = Payment::STATUS_REFUNDED;
|
||||
}
|
||||
|
||||
if (count($payment_filters) > 0) {
|
||||
$query->whereIn('status_id', $payment_filters);
|
||||
}
|
||||
|
||||
if(in_array('partially_unapplied', $status_parameters)) {
|
||||
$query->whereColumn('amount', '>', 'applied')->where('refunded', 0);
|
||||
}
|
||||
});
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add RecurringInvoice Status Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addRecurringInvoiceStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0){
|
||||
return $query;
|
||||
}
|
||||
|
||||
$recurring_filters = [];
|
||||
|
||||
if (in_array('active', $status_parameters)) {
|
||||
$recurring_filters[] = RecurringInvoice::STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
if (in_array('paused', $status_parameters)) {
|
||||
$recurring_filters[] = RecurringInvoice::STATUS_PAUSED;
|
||||
}
|
||||
|
||||
if (in_array('completed', $status_parameters)) {
|
||||
$recurring_filters[] = RecurringInvoice::STATUS_COMPLETED;
|
||||
}
|
||||
|
||||
if (count($recurring_filters) >= 1) {
|
||||
return $query->whereIn('status_id', $recurring_filters);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
/**
|
||||
* Add QuoteStatus Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addQuoteStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->where(function ($query) use ($status_parameters) {
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$query->orWhere(function ($q) {
|
||||
$q->where('status_id', Quote::STATUS_SENT)
|
||||
->whereNull('due_date')
|
||||
->orWhere('due_date', '>=', now()->toDateString());
|
||||
});
|
||||
}
|
||||
|
||||
$quote_filters = [];
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$quote_filters[] = Quote::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('approved', $status_parameters)) {
|
||||
$quote_filters[] = Quote::STATUS_APPROVED;
|
||||
}
|
||||
|
||||
if (count($quote_filters) > 0) {
|
||||
$query->orWhereIn('status_id', $quote_filters);
|
||||
}
|
||||
|
||||
if (in_array('expired', $status_parameters)) {
|
||||
$query->orWhere(function ($q) {
|
||||
$q->where('status_id', Quote::STATUS_SENT)
|
||||
->whereNotNull('due_date')
|
||||
->where('due_date', '<=', now()->toDateString());
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('upcoming', $status_parameters)) {
|
||||
$query->orWhere(function ($q) {
|
||||
$q->where('status_id', Quote::STATUS_SENT)
|
||||
->where('due_date', '>=', now()->toDateString())
|
||||
->orderBy('due_date', 'DESC');
|
||||
});
|
||||
}
|
||||
|
||||
if(in_array('converted', $status_parameters)) {
|
||||
$query->orWhere(function ($q) {
|
||||
$q->whereNotNull('invoice_id');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add PurchaseOrder Status Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addPurchaseOrderStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->where(function ($query) use ($status_parameters) {
|
||||
$po_status = [];
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$query->orWhere(function ($q) {
|
||||
$q->where('status_id', PurchaseOrder::STATUS_SENT)
|
||||
->whereNull('due_date')
|
||||
->orWhere('due_date', '>=', now()->toDateString());
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('accepted', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
||||
}
|
||||
|
||||
if (in_array('cancelled', $status_parameters)) {
|
||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if (count($po_status) >= 1) {
|
||||
$query->whereIn('status_id', $po_status);
|
||||
}
|
||||
});
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Invoice Status Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addInvoiceStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if(in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -942,6 +1198,10 @@ class BaseExport
|
||||
$invoice_filters[] = Invoice::STATUS_PARTIAL;
|
||||
}
|
||||
|
||||
if (in_array('cancelled', $status_parameters)) {
|
||||
$invoice_filters[] = Invoice::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if (count($invoice_filters) > 0) {
|
||||
$nested->whereIn('status_id', $invoice_filters);
|
||||
}
|
||||
@ -966,14 +1226,18 @@ class BaseExport
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function addDateRange($query)
|
||||
/**
|
||||
* Add Date Range
|
||||
*
|
||||
* @param Builder $query
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addDateRange(Builder $query): Builder
|
||||
{
|
||||
$query = $this->applyFilters($query);
|
||||
$query = $this->applyProductFilters($query);
|
||||
|
||||
$date_range = $this->input['date_range'];
|
||||
|
||||
nlog($date_range);
|
||||
|
||||
if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key']) > 1) {
|
||||
$this->date_key = $this->input['date_key'];
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class ClientExport extends BaseExport
|
||||
$query = Client::query()->with('contacts')
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
@ -103,10 +103,14 @@ class CreditExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
if($this->input['status'] ?? false) {
|
||||
$query = $this->addCreditStatusFilter($query, $this->input['status']);
|
||||
}
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
@ -162,6 +166,40 @@ class CreditExport extends BaseExport
|
||||
return $this->decorateAdvancedFields($credit, $entity);
|
||||
}
|
||||
|
||||
public function addCreditStatusFilter($query, $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$credit_filters = [];
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$credit_filters[] = Credit::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$credit_filters[] = Credit::STATUS_SENT;
|
||||
}
|
||||
|
||||
if (in_array('partial', $status_parameters)) {
|
||||
$credit_filters[] = Credit::STATUS_PARTIAL;
|
||||
}
|
||||
|
||||
if (in_array('applied', $status_parameters)) {
|
||||
$credit_filters[] = Credit::STATUS_APPLIED;
|
||||
}
|
||||
|
||||
if (count($credit_filters) >= 1) {
|
||||
$query->whereIn('status_id', $credit_filters);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function decorateAdvancedFields(Credit $credit, array $entity): array
|
||||
{
|
||||
// if (in_array('country_id', $this->input['report_keys'])) {
|
||||
|
@ -83,10 +83,14 @@ class ExpenseExport extends BaseExport
|
||||
->with('client')
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
if($this->input['status'] ?? false) {
|
||||
$query = $this->addExpenseStatusFilter($query, $this->input['status']);
|
||||
}
|
||||
|
||||
if(isset($this->input['clients'])) {
|
||||
$query = $this->addClientFilter($query, $this->input['clients']);
|
||||
}
|
||||
@ -152,6 +156,55 @@ class ExpenseExport extends BaseExport
|
||||
return $this->decorateAdvancedFields($expense, $entity);
|
||||
}
|
||||
|
||||
protected function addExpenseStatusFilter($query, $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->where(function ($query) use ($status_parameters) {
|
||||
if (in_array('logged', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->where('amount', '>', 0)
|
||||
->whereNull('invoice_id')
|
||||
->whereNull('payment_date')
|
||||
->where('should_be_invoiced', false);
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('pending', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->where('should_be_invoiced', true)
|
||||
->whereNull('invoice_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('invoiced', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->whereNotNull('invoice_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('paid', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->whereNotNull('payment_date');
|
||||
});
|
||||
}
|
||||
|
||||
if (in_array('unpaid', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->whereNull('payment_date');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function decorateAdvancedFields(Expense $expense, array $entity): array
|
||||
{
|
||||
// if (in_array('expense.currency_id', $this->input['report_keys'])) {
|
||||
|
@ -58,7 +58,7 @@ class InvoiceExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
@ -151,9 +151,9 @@ class InvoiceExport extends BaseExport
|
||||
// $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id);
|
||||
// }
|
||||
|
||||
// if (in_array('invoice.recurring_id', $this->input['report_keys'])) {
|
||||
// $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? '';
|
||||
// }
|
||||
if (in_array('invoice.recurring_id', $this->input['report_keys'])) {
|
||||
$entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? '';
|
||||
}
|
||||
|
||||
if (in_array('invoice.auto_bill_enabled', $this->input['report_keys'])) {
|
||||
$entity['invoice.auto_bill_enabled'] = $invoice->auto_bill_enabled ? ctrans('texts.yes') : ctrans('texts.no');
|
||||
|
@ -71,11 +71,15 @@ class InvoiceItemExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->applyFilters($query);
|
||||
if($this->input['status'] ?? false) {
|
||||
$query = $this->addInvoiceStatusFilter($query, $this->input['status']);
|
||||
}
|
||||
|
||||
$query = $this->applyProductFilters($query);
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
@ -232,9 +236,9 @@ class InvoiceItemExport extends BaseExport
|
||||
// $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id);
|
||||
// }
|
||||
|
||||
// if (in_array('invoice.recurring_id', $this->input['report_keys'])) {
|
||||
// $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? '';
|
||||
// }
|
||||
if (in_array('invoice.recurring_id', $this->input['report_keys'])) {
|
||||
$entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? '';
|
||||
}
|
||||
|
||||
if (in_array('invoice.assigned_user_id', $this->input['report_keys'])) {
|
||||
$entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name() : '';
|
||||
|
@ -61,6 +61,8 @@ class PaymentExport extends BaseExport
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addPaymentStatusFilters($query, $this->input['status'] ?? '');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -31,51 +31,6 @@ class PurchaseOrderExport extends BaseExport
|
||||
|
||||
private Decorator $decorator;
|
||||
|
||||
public array $entity_keys = [
|
||||
'amount' => 'purchase_order.amount',
|
||||
'balance' => 'purchase_order.balance',
|
||||
'vendor' => 'purchase_order.vendor_id',
|
||||
// 'custom_surcharge1' => 'purchase_order.custom_surcharge1',
|
||||
// 'custom_surcharge2' => 'purchase_order.custom_surcharge2',
|
||||
// 'custom_surcharge3' => 'purchase_order.custom_surcharge3',
|
||||
// 'custom_surcharge4' => 'purchase_order.custom_surcharge4',
|
||||
'custom_value1' => 'purchase_order.custom_value1',
|
||||
'custom_value2' => 'purchase_order.custom_value2',
|
||||
'custom_value3' => 'purchase_order.custom_value3',
|
||||
'custom_value4' => 'purchase_order.custom_value4',
|
||||
'date' => 'purchase_order.date',
|
||||
'discount' => 'purchase_order.discount',
|
||||
'due_date' => 'purchase_order.due_date',
|
||||
'exchange_rate' => 'purchase_order.exchange_rate',
|
||||
'footer' => 'purchase_order.footer',
|
||||
'number' => 'purchase_order.number',
|
||||
'paid_to_date' => 'purchase_order.paid_to_date',
|
||||
'partial' => 'purchase_order.partial',
|
||||
'partial_due_date' => 'purchase_order.partial_due_date',
|
||||
'po_number' => 'purchase_order.po_number',
|
||||
'private_notes' => 'purchase_order.private_notes',
|
||||
'public_notes' => 'purchase_order.public_notes',
|
||||
'status' => 'purchase_order.status',
|
||||
'tax_name1' => 'purchase_order.tax_name1',
|
||||
'tax_name2' => 'purchase_order.tax_name2',
|
||||
'tax_name3' => 'purchase_order.tax_name3',
|
||||
'tax_rate1' => 'purchase_order.tax_rate1',
|
||||
'tax_rate2' => 'purchase_order.tax_rate2',
|
||||
'tax_rate3' => 'purchase_order.tax_rate3',
|
||||
'terms' => 'purchase_order.terms',
|
||||
'total_taxes' => 'purchase_order.total_taxes',
|
||||
'currency_id' => 'purchase_order.currency_id',
|
||||
];
|
||||
|
||||
private array $decorate_keys = [
|
||||
'country',
|
||||
'currency_id',
|
||||
'status',
|
||||
'vendor',
|
||||
'project',
|
||||
];
|
||||
|
||||
|
||||
public function __construct(Company $company, array $input)
|
||||
{
|
||||
$this->company = $company;
|
||||
@ -104,10 +59,12 @@ class PurchaseOrderExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('vendor')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addPurchaseOrderStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
@ -167,7 +124,7 @@ class PurchaseOrderExport extends BaseExport
|
||||
if (is_array($parts) && $parts[0] == 'purchase_order' && array_key_exists($parts[1], $transformed_purchase_order)) {
|
||||
$entity[$key] = $transformed_purchase_order[$parts[1]];
|
||||
} else {
|
||||
// nlog($key);
|
||||
nlog($key);
|
||||
$entity[$key] = $this->decorator->transform($key, $purchase_order);
|
||||
// $entity[$key] = '';
|
||||
|
||||
@ -182,16 +139,13 @@ class PurchaseOrderExport extends BaseExport
|
||||
|
||||
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
||||
{
|
||||
if (in_array('country_id', $this->input['report_keys'])) {
|
||||
$entity['country'] = $purchase_order->vendor->country ? ctrans("texts.country_{$purchase_order->vendor->country->name}") : '';
|
||||
|
||||
if (in_array('purchase_order.currency_id', $this->input['report_keys'])) {
|
||||
$entity['purchase_order.currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||
}
|
||||
|
||||
if (in_array('currency_id', $this->input['report_keys'])) {
|
||||
$entity['currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||
}
|
||||
|
||||
if (in_array('vendor_id', $this->input['report_keys'])) {
|
||||
$entity['vendor'] = $purchase_order->vendor->present()->name();
|
||||
if (in_array('purchase_order.vendor_id', $this->input['report_keys'])) {
|
||||
$entity['purchase_order.vendor_id'] = $purchase_order->vendor->present()->name();
|
||||
}
|
||||
|
||||
if (in_array('purchase_order.status', $this->input['report_keys'])) {
|
||||
|
@ -63,10 +63,12 @@ class PurchaseOrderItemExport extends BaseExport
|
||||
$query = PurchaseOrder::query()
|
||||
->withTrashed()
|
||||
->with('vendor')->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addPurchaseOrderStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
@ -190,23 +192,35 @@ class PurchaseOrderItemExport extends BaseExport
|
||||
|
||||
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
||||
{
|
||||
if (in_array('currency_id', $this->input['report_keys'])) {
|
||||
$entity['currency'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||
// if (in_array('currency_id', $this->input['report_keys'])) {
|
||||
// $entity['currency'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||
// }
|
||||
|
||||
// if(array_key_exists('type', $entity)) {
|
||||
// $entity['type'] = $purchase_order->typeIdString($entity['type']);
|
||||
// }
|
||||
|
||||
// if(array_key_exists('tax_category', $entity)) {
|
||||
// $entity['tax_category'] = $purchase_order->taxTypeString($entity['tax_category']);
|
||||
// }
|
||||
|
||||
// if($this->force_keys) {
|
||||
// $entity['vendor'] = $purchase_order->vendor->present()->name();
|
||||
// $entity['vendor_id_number'] = $purchase_order->vendor->id_number;
|
||||
// $entity['vendor_number'] = $purchase_order->vendor->number;
|
||||
// $entity['status'] = $purchase_order->stringStatus($purchase_order->status_id);
|
||||
// }
|
||||
|
||||
if (in_array('purchase_order.currency_id', $this->input['report_keys'])) {
|
||||
$entity['purchase_order.currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||
}
|
||||
|
||||
if(array_key_exists('type', $entity)) {
|
||||
$entity['type'] = $purchase_order->typeIdString($entity['type']);
|
||||
if (in_array('purchase_order.vendor_id', $this->input['report_keys'])) {
|
||||
$entity['purchase_order.vendor_id'] = $purchase_order->vendor->present()->name();
|
||||
}
|
||||
|
||||
if(array_key_exists('tax_category', $entity)) {
|
||||
$entity['tax_category'] = $purchase_order->taxTypeString($entity['tax_category']);
|
||||
}
|
||||
|
||||
if($this->force_keys) {
|
||||
$entity['vendor'] = $purchase_order->vendor->present()->name();
|
||||
$entity['vendor_id_number'] = $purchase_order->vendor->id_number;
|
||||
$entity['vendor_number'] = $purchase_order->vendor->number;
|
||||
$entity['status'] = $purchase_order->stringStatus($purchase_order->status_id);
|
||||
if (in_array('purchase_order.status', $this->input['report_keys'])) {
|
||||
$entity['purchase_order.status'] = $purchase_order->stringStatus($purchase_order->status_id);
|
||||
}
|
||||
|
||||
if (in_array('purchase_order.user_id', $this->input['report_keys'])) {
|
||||
|
@ -65,10 +65,12 @@ class QuoteExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addQuoteStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -66,10 +66,12 @@ class QuoteItemExport extends BaseExport
|
||||
$query = Quote::query()
|
||||
->withTrashed()
|
||||
->with('client')->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addQuoteStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -57,10 +57,12 @@ class RecurringInvoiceExport extends BaseExport
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
$query = $this->addRecurringInvoiceStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class TaskExport extends BaseExport
|
||||
$query = Task::query()
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
@ -203,6 +203,34 @@ class TaskExport extends BaseExport
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Task Status Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addTaskStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if (in_array('invoiced', $status_parameters)) {
|
||||
$query->whereNotNull('invoice_id');
|
||||
}
|
||||
|
||||
if (in_array('uninvoiced', $status_parameters)) {
|
||||
$query->whereNull('invoice_id');
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
private function decorateAdvancedFields(Task $task, array $entity): array
|
||||
{
|
||||
if (in_array('task.status_id', $this->input['report_keys'])) {
|
||||
|
@ -62,7 +62,7 @@ class VendorExport extends BaseExport
|
||||
$query = Vendor::query()->with('contacts')
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0);
|
||||
->where('is_deleted', $this->input['include_deleted']);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
@ -79,7 +79,6 @@ class InvoiceDecorator extends Decorator implements DecoratorInterface
|
||||
return $invoice->partial_due_date ?? '';
|
||||
}
|
||||
|
||||
|
||||
public function assigned_user_id(Invoice $invoice)
|
||||
{
|
||||
return $invoice->assigned_user ? $invoice->assigned_user->present()->name() : '';
|
||||
|
@ -37,7 +37,8 @@ class GenericReportRequest extends Request
|
||||
'start_date' => 'bail|required_if:date_range,custom|nullable|date',
|
||||
'report_keys' => 'present|array',
|
||||
'send_email' => 'required|bool',
|
||||
'document_email_attachment' => 'sometimes|bool'
|
||||
'document_email_attachment' => 'sometimes|bool',
|
||||
'include_deleted' => 'required|bool',
|
||||
// 'status' => 'sometimes|string|nullable|in:all,draft,sent,viewed,paid,unpaid,overdue',
|
||||
];
|
||||
}
|
||||
@ -63,6 +64,8 @@ class GenericReportRequest extends Request
|
||||
$input['end_date'] = null;
|
||||
}
|
||||
|
||||
$input['include_deleted'] = array_key_exists('include_deleted', $input) ? filter_var($input['include_deleted'], FILTER_VALIDATE_BOOLEAN) : false;
|
||||
|
||||
$input['user_id'] = auth()->user()->id;
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -279,13 +279,21 @@ class NinjaMailerJob implements ShouldQueue
|
||||
$this->mailer = 'postmark';
|
||||
$this->client_postmark_secret = config('services.postmark-outlook.token');
|
||||
|
||||
if (property_exists($this->nmo->settings, 'email_from_name') && strlen($this->nmo->settings->email_from_name) > 1) {
|
||||
$email_from_name = $this->nmo->settings->email_from_name;
|
||||
} else {
|
||||
$email_from_name = $this->company->present()->name();
|
||||
}
|
||||
|
||||
$this->nmo
|
||||
->mailable
|
||||
->from('maildelivery@invoice.services', 'Invoice Ninja');
|
||||
->from(config('services.postmark-outlook.from.address'), $email_from_name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
|
||||
nlog("problem switching outlook driver - hosted");
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ class PdfSlot extends Component
|
||||
return render('components.livewire.pdf-slot', [
|
||||
'invitation' => $this->invitation,
|
||||
'entity' => $this->entity,
|
||||
'settings' => $this->settings,
|
||||
'data' => $this->invitation->company->settings,
|
||||
'entity_type' => $this->entity_type,
|
||||
'products' => $this->getProducts(),
|
||||
|
@ -503,15 +503,22 @@ class Email implements ShouldQueue
|
||||
$server = $dns[0]["target"];
|
||||
if(stripos($server, "outlook.com") !== false) {
|
||||
|
||||
if (property_exists($this->email_object->settings, 'email_from_name') && strlen($this->email_object->settings->email_from_name) > 1) {
|
||||
$email_from_name = $this->email_object->settings->email_from_name;
|
||||
} else {
|
||||
$email_from_name = $this->company->present()->name();
|
||||
}
|
||||
|
||||
$this->mailer = 'postmark';
|
||||
$this->client_postmark_secret = config('services.postmark-outlook.token');
|
||||
$this->mailable
|
||||
->from('maildelivery@invoice.services', 'Invoice Ninja');
|
||||
->from(config('services.postmark-outlook.from.address'), $email_from_name);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
nlog("problem switching outlook driver - hosted");
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ class TemplateService
|
||||
return collect($payment->refund_meta)
|
||||
->map(function ($refund) use ($payment) {
|
||||
|
||||
$date = \Carbon\Carbon::parse($refund['date'])->addSeconds($payment->client->timezone_offset());
|
||||
$date = \Carbon\Carbon::parse($refund['date'] ?? $payment->date)->addSeconds($payment->client->timezone_offset());
|
||||
$date = $this->translateDate($date, $payment->client->date_format(), $payment->client->locale());
|
||||
$entity = ctrans('texts.invoice');
|
||||
|
||||
|
745
composer.lock
generated
745
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -17,8 +17,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => env('APP_VERSION', '5.8.32'),
|
||||
'app_tag' => env('APP_TAG', '5.8.32'),
|
||||
'app_version' => env('APP_VERSION', '5.8.33'),
|
||||
'app_tag' => env('APP_TAG', '5.8.33'),
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -35,7 +35,10 @@ return [
|
||||
],
|
||||
|
||||
'postmark-outlook' => [
|
||||
'token' => env('POSTMARK_OUTLOOK_SECRET','')
|
||||
'token' => env('POSTMARK_OUTLOOK_SECRET',''),
|
||||
'from' => [
|
||||
'address' => env('POSTMARK_OUTLOOK_FROM_ADDRESS', '')
|
||||
],
|
||||
],
|
||||
|
||||
'microsoft' => [
|
||||
|
@ -30,7 +30,7 @@
|
||||
@endisset
|
||||
|
||||
@isset($signature)
|
||||
<p>{{ $signature }}</p>
|
||||
<p>{!! nl2br($signature) !!}</p>
|
||||
@endisset
|
||||
</div>
|
||||
@endcomponent
|
@ -48,7 +48,7 @@
|
||||
@endisset
|
||||
|
||||
@isset($signature)
|
||||
<p>{{ nl2br($signature) }}</p>
|
||||
<p>{!! nl2br($signature) !!}</p>
|
||||
@endisset
|
||||
</div>
|
||||
@endcomponent
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
{!! $signature !!}
|
||||
{!! nl2br($signature) !!}
|
||||
</p>
|
||||
@endif
|
||||
|
||||
|
@ -9,9 +9,7 @@
|
||||
@if($signature)
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
{!! $signature !!}
|
||||
</p>
|
||||
<p>{!! nl2br($signature) !!}</p>
|
||||
@endif
|
||||
|
||||
@isset($email_preferences)
|
||||
|
@ -501,6 +501,7 @@ class ReportCsvGenerationTest extends TestCase
|
||||
// 'start_date' => 'bail|required_if:date_range,custom|nullable|date',
|
||||
'report_keys' => [],
|
||||
'send_email' => false,
|
||||
'include_deleted' => false,
|
||||
// 'status' => 'sometimes|string|nullable|in:all,draft,sent,viewed,paid,unpaid,overdue',
|
||||
];
|
||||
|
||||
@ -547,6 +548,7 @@ class ReportCsvGenerationTest extends TestCase
|
||||
'date_range' => 'all',
|
||||
'report_keys' => ["vendor.name", "vendor.city", "vendor.number"],
|
||||
'send_email' => false,
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -638,6 +640,7 @@ class ReportCsvGenerationTest extends TestCase
|
||||
'task.custom_value4',
|
||||
],
|
||||
'send_email' => false,
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -792,6 +795,7 @@ class ReportCsvGenerationTest extends TestCase
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'send_email' => false,
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -873,6 +877,7 @@ class ReportCsvGenerationTest extends TestCase
|
||||
"client.paid_to_date"
|
||||
],
|
||||
'send_email' => false,
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
|
@ -70,6 +70,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -101,6 +102,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -132,6 +134,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -164,6 +167,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -197,6 +201,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -231,6 +236,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -261,6 +267,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -291,6 +298,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -320,6 +328,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -351,6 +360,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -375,6 +385,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -387,6 +398,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => ['client.name','client.balance'],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
|
||||
@ -408,6 +420,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -420,6 +433,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => ['client.name','client.balance','contact.email'],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
|
||||
@ -439,6 +453,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -466,6 +481,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$p = (new PreviewReport($this->company, $data, CreditExport::class, '123'))->handle();
|
||||
@ -484,6 +500,7 @@ class ReportPreviewTest extends TestCase
|
||||
'send_email' => false,
|
||||
'date_range' => 'all',
|
||||
'report_keys' => [],
|
||||
'include_deleted' => false,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
|
Loading…
x
Reference in New Issue
Block a user