renamed income/expense
This commit is contained in:
50
app/Imports/Sales/Customers.php
Normal file
50
app/Imports/Sales/Customers.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales;
|
||||
|
||||
use App\Models\Common\Contact as Model;
|
||||
use App\Http\Requests\Common\Contact as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class Customers implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'customer';
|
||||
|
||||
// Make enabled field integer
|
||||
if (isset($row['enabled'])) {
|
||||
$row['enabled'] = (int) $row['enabled'];
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'customers',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
26
app/Imports/Sales/Invoices.php
Normal file
26
app/Imports/Sales/Invoices.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales;
|
||||
|
||||
use App\Imports\Sales\Sheets\Invoices as Base;
|
||||
use App\Imports\Sales\Sheets\InvoiceItems;
|
||||
use App\Imports\Sales\Sheets\InvoiceItemTaxes;
|
||||
use App\Imports\Sales\Sheets\InvoiceHistories;
|
||||
use App\Imports\Sales\Sheets\InvoicePayments;
|
||||
use App\Imports\Sales\Sheets\InvoiceTotals;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class Invoices implements WithMultipleSheets
|
||||
{
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
'invoices' => new Base(),
|
||||
'invoice_items' => new InvoiceItems(),
|
||||
'invoice_item_taxes' => new InvoiceItemTaxes(),
|
||||
'invoice_histories' => new InvoiceHistories(),
|
||||
'invoice_payments' => new InvoicePayments(),
|
||||
'invoice_totals' => new InvoiceTotals(),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
app/Imports/Sales/Revenues.php
Normal file
50
app/Imports/Sales/Revenues.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Income;
|
||||
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class Revenues implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'income';
|
||||
|
||||
// Make reconciled field integer
|
||||
if (isset($row['reconciled'])) {
|
||||
$row['reconciled'] = (int) $row['reconciled'];
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'revenues',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Imports/Sales/Sheets/InvoiceHistories.php
Normal file
44
app/Imports/Sales/Sheets/InvoiceHistories.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Sale\InvoiceHistory as Model;
|
||||
use App\Http\Requests\Sale\InvoiceHistory as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceHistories implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_histories',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
app/Imports/Sales/Sheets/InvoiceItemTaxes.php
Normal file
37
app/Imports/Sales/Sheets/InvoiceItemTaxes.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Sale\InvoiceItemTax as Model;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceItemTaxes implements ToModel, WithHeadingRow, WithMapping
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_item_taxes',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Imports/Sales/Sheets/InvoiceItems.php
Normal file
44
app/Imports/Sales/Sheets/InvoiceItems.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Sale\InvoiceItem as Model;
|
||||
use App\Http\Requests\Sale\InvoiceItem as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceItems implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_items',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
50
app/Imports/Sales/Sheets/InvoicePayments.php
Normal file
50
app/Imports/Sales/Sheets/InvoicePayments.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoicePayments implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'income';
|
||||
|
||||
// Make reconciled field integer
|
||||
if (isset($row['reconciled'])) {
|
||||
$row['reconciled'] = (int) $row['reconciled'];
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_payments',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Imports/Sales/Sheets/InvoiceTotals.php
Normal file
44
app/Imports/Sales/Sheets/InvoiceTotals.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Sale\InvoiceTotal as Model;
|
||||
use App\Http\Requests\Sale\InvoiceTotal as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceTotals implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_totals',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Imports/Sales/Sheets/Invoices.php
Normal file
44
app/Imports/Sales/Sheets/Invoices.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Sale\Invoice as Model;
|
||||
use App\Http\Requests\Sale\Invoice as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class Invoices implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoices',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user