diff --git a/app/Classes/Modules/Exports/Services/ExportsAnalyticBillingTransactions.php b/app/Classes/Modules/Exports/Services/ExportsAnalyticBillingTransactions.php new file mode 100644 index 00000000..1798af4f --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsAnalyticBillingTransactions.php @@ -0,0 +1,89 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'Booking Id', + 'Service Type', + 'Payment Method', + 'Company Id', + 'Customer Segment', + 'Company Create Date', + 'Company Type', + 'Supplier Id', + 'Customer Payment', + 'Customer Rate', + 'Customer Service Charge', + 'Customer Payment Date', + 'Original Amount', + 'Supplier Payment', + 'Supplier Rate', + 'Supplier Service Charge', + 'Supplier Payment Date' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function collection() + { + return Transaction::where('type', 3)->get(); + } + + /** + * @param $transaction + * @return array + */ + public function map($transaction): array + { + + $bill = $transaction; + $payment = $transaction->owner; + $booking = $payment->owner; + $company = $booking->company; + + return [ + $booking->id, + $booking->service->name, + PaymentMethodType::PAYMENT_METHODS_ID[$payment->payment_method], + $company->id, + $company->segments->implode('name', ', '), + $company->created_at, + $company->type === 0 ? 'Personal' : 'Company', + $bill->issuerCompany->name, + $payment->amount, + $payment->currency_rate, + $payment->service_charge, + $payment->created_at, + $payment->original_amount, + $bill->amount, + $bill->currency_rate, + $bill->service_charge, + $bill->created_at + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsTransactions.php b/app/Classes/Modules/Exports/Services/ExportsTransactions.php index 013286d1..b7f0e5ad 100644 --- a/app/Classes/Modules/Exports/Services/ExportsTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsTransactions.php @@ -26,7 +26,7 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping, Sho */ public function query() { - return Transaction::where('type', TransactionType::BILL); + return Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::BILL])->where('owner_type', '!=',Wallet::class); } /** @@ -61,9 +61,18 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping, Sho 6 => 'EXPIRED' ]; - $booking = $transaction->owner->owner; + + $booking = $transaction->owner; + if(!($booking instanceof Booking)){ + $booking = $booking->owner; + } + + $company = $booking->company; + + if(!$company instanceof Company) dd($transaction); + return [ - $booking ? $booking->company->reference : '', + $company->reference, $booking ? $booking->marking : '', $transaction->bill_no, $transaction->owner_id, diff --git a/app/Classes/ValueObjects/Constants/CompanyType.php b/app/Classes/ValueObjects/Constants/CompanyType.php index 61918925..135aa700 100644 --- a/app/Classes/ValueObjects/Constants/CompanyType.php +++ b/app/Classes/ValueObjects/Constants/CompanyType.php @@ -8,4 +8,9 @@ final class CompanyType { public const COMPANY_BUSINESS = 1; + public const COMPANY_TYPE_ID = [ + self::PERSONAL_BUSINESS => 'PERSONAL_BUSINESS', + self::COMPANY_BUSINESS => 'COMPANY_BUSINESS', + ]; + } diff --git a/app/Http/Controllers/Exports/ExportAnalyticToExcelController.php b/app/Http/Controllers/Exports/ExportAnalyticToExcelController.php index 135e570d..2a93a991 100644 --- a/app/Http/Controllers/Exports/ExportAnalyticToExcelController.php +++ b/app/Http/Controllers/Exports/ExportAnalyticToExcelController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsAnalyticBookingTransactions; +use App\Classes\Modules\Exports\Services\ExportsAnalyticBillingTransactions; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -27,4 +28,10 @@ class ExportAnalyticToExcelController ob_end_clean(); return $response; } + + public function billingData(ExportsAnalyticBillingTransactions $exportsAnalyticBillingTransactions, Request $request){ + $response = $exportsAnalyticBillingTransactions->download('billingData.csv', Excel::CSV, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } } \ No newline at end of file diff --git a/package.json b/package.json index ced333fa..5d4b92bf 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ }, "devDependencies": { "axios": "^0.21.0", + "chromatic": "^6.5.4", "cross-env": "^7.0.2", "del": "^6.0.0", "fancy-log": "^1.3.0", diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index cde4d84d..76a202a1 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -7,7 +7,14 @@
2
Purchase Order
-

In order for us to process your order, you will need to provide us with your purchase order information.

+

In order for us to process your order, you will need to provide us with your purchase order information.

+
+ +
+
+
+

Any Purchase Orders that aren't submitted within 60 days will be closed for editing.

+
diff --git a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue index 4ec71edd..c3b1a6de 100644 --- a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue @@ -47,7 +47,7 @@
- +
diff --git a/routes/web.php b/routes/web.php index db739cc4..740737ff 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,6 +97,7 @@ Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callba Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/analytic/booking', 'Exports\ExportAnalyticToExcelController@bookingData'); +Route::get('/export/analytic/bills', 'Exports\ExportAnalyticToExcelController@billingData'); Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']);