diff --git a/app/Classes/General/Eloquent/Filters/PendingPayment.php b/app/Classes/General/Eloquent/Filters/PendingPayment.php
new file mode 100644
index 00000000..ab055987
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/PendingPayment.php
@@ -0,0 +1,24 @@
+whereHas('service', function($service){
+ $service->whereHas('constants', function($query) {
+ $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_billable', true);
+ });
+ })->whereDoesntHave('transactions', function($transaction){
+ return $transaction->where('type', TransactionType::PURCHASE_ORDER)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/PurchaseOrderApproval.php b/app/Classes/General/Eloquent/Filters/PurchaseOrderApproval.php
new file mode 100644
index 00000000..45277c97
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/PurchaseOrderApproval.php
@@ -0,0 +1,29 @@
+whereHas('service', function($service){
+ $service->whereHas('constants', function($query) {
+ $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_billable', true);
+ });
+ })->whereHas('transactions', function($transaction){
+ return $transaction->where('type', TransactionType::PURCHASE_ORDER)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION]);
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php
index 3f394557..ff4796cc 100644
--- a/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php
+++ b/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php
@@ -8,6 +8,7 @@ use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Classes\Modules\Documents\Services\ApprovesDocument;
use App\Classes\Modules\Documents\Services\FetchesDocument;
use App\Classes\Modules\Documents\Services\RejectsDocument;
+use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
@@ -34,15 +35,20 @@ class ApprovePurchaseOrderLogic extends AbstractControllerLogic
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
+ /** @var CreateInvoiceTransactionProcessor */
+ private $createInvoiceTransactionProcessor;
+
/**
* ApprovePurchaseOrderLogic constructor.
* @param FetchesBooking $fetchesBooking
* @param UpdatesTransactionStatus $updatesTransactionStatus
+ * @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
*/
- public function __construct(FetchesBooking $fetchesBooking, UpdatesTransactionStatus $updatesTransactionStatus)
+ public function __construct(FetchesBooking $fetchesBooking, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor)
{
$this->fetchesBooking = $fetchesBooking;
$this->updatesTransactionStatus = $updatesTransactionStatus;
+ $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor;
}
/**
@@ -57,6 +63,8 @@ class ApprovePurchaseOrderLogic extends AbstractControllerLogic
$this->updatesTransactionStatus->execute($booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(), ApprovalStatus::APPROVED);
+ $this->createInvoiceTransactionProcessor->execute($booking);
+
return $this->response([]);
}
diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php
new file mode 100644
index 00000000..398c99e9
--- /dev/null
+++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php
@@ -0,0 +1,21 @@
+transactions()->payments()->transferred()
+ ->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
+ $booking->transactions()->payments()->transferred()->sum('original_amount');
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php
index 35389f36..7a551257 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php
@@ -123,11 +123,9 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic
'currency_vendor_order'
);
- foreach ($transactions as $key => $row) {
- /** @var Document $document */
- $document = $this->createsDocument->execute($row, $object);
- $this->createsFile->execute($document, $object);
- }
+ /** @var Document $document */
+ $document = $this->createsDocument->execute($supplier, $object);
+ $this->createsFile->execute($document, $object);
return $this->response([]);
}
diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php
index 09bc5982..54370591 100644
--- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php
+++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php
@@ -2,6 +2,8 @@
namespace App\Classes\Modules\Transactions\Processors;
+use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount;
+use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
@@ -15,11 +17,12 @@ use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
+use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Models\Booking;
use App\Models\Document;
-use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
+use App\Models\SegmentConstant;
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
class CreateInvoiceTransactionProcessor
@@ -36,6 +39,12 @@ class CreateInvoiceTransactionProcessor
/** @var CalculatesBookingPaidAmount */
private $calculatesBookingPaidAmount;
+ /** @var CalculatesBookingTransferredAmount */
+ private $calculatesBookingTransferredAmount;
+
+ /** @var FetchesServiceConfigurations */
+ private $fetchesServiceConfigurations;
+
/** @var CalculatesBookingCurrencyAverageRate */
private $calculatesBookingCurrencyAverageRate;
@@ -52,18 +61,27 @@ class CreateInvoiceTransactionProcessor
private $updatesBookingStatus;
/**
- * CreateInvoiceTransactionLogic constructor.
+ * CreateInvoiceTransactionProcessor constructor.
* @param ListsTransactions $listsTransactions
* @param CreatesTransaction $createsTransaction
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CalculatesBookingPaidAmount $calculatesBookingPaidAmount
+ * @param CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount
+ * @param FetchesServiceConfigurations $fetchesServiceConfigurations
+ * @param CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate
+ * @param FetchesCompany $fetchesCompany
+ * @param CreatesDocument $createsDocument
+ * @param CreatesFiles $createsFile
+ * @param UpdatesBookingStatus $updatesBookingStatus
*/
- public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus)
+ public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus)
{
$this->listsTransactions = $listsTransactions;
- $this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
+ $this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->calculatesBookingPaidAmount = $calculatesBookingPaidAmount;
+ $this->calculatesBookingTransferredAmount = $calculatesBookingTransferredAmount;
+ $this->fetchesServiceConfigurations = $fetchesServiceConfigurations;
$this->calculatesBookingCurrencyAverageRate = $calculatesBookingCurrencyAverageRate;
$this->fetchesCompany = $fetchesCompany;
$this->createsDocument = $createsDocument;
@@ -71,6 +89,7 @@ class CreateInvoiceTransactionProcessor
$this->updatesBookingStatus = $updatesBookingStatus;
}
+
/**
* @param Booking $booking
* @return void
@@ -78,128 +97,133 @@ class CreateInvoiceTransactionProcessor
*/
public function execute(Booking $booking)
{
+ $payment_amount = $this->calculatesBookingTransferredAmount->execute($booking, $booking->fix_currency_id);
+ $booking_amount = $booking->fix_amount;
+
+ if ((float) $booking_amount !== (float) $payment_amount) {
+ return;
+ }
+
$po_order_transaction = $booking->transactions()
->where('type', TransactionType::PURCHASE_ORDER)
- ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
+ ->complete()
->first();
- if ($po_order_transaction) {
- $payment_amount = $this->calculatesBookingPaidAmount->execute($booking, $booking->fix_currency_id);
- $booking_amount = $booking->fix_amount;
+ $constants = SegmentConstant::where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->id', $booking->service->id)->first();
- if ((float) $booking_amount === (float) $payment_amount) {
-
- $transaction = $booking->transactions()
- ->where('type', TransactionType::PAYMENT)
- ->first();
-
- $billNumber = $this->generatesTransactionBillNumber->execute('INV-');
-
- $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT);
-
- $total_service_charge = $booking->transactions()
- ->where('type', TransactionType::PAYMENT)
- ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
- ->sum('service_charge');
-
- $total_tax = $booking->transactions()
- ->where('type', TransactionType::PAYMENT)
- ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
- ->sum('tax');
-
- $transaction_object = new TransactionObject(
- $billNumber,
- TransactionType::INVOICE,
- $transaction->issuer,
- $transaction->receiver,
- $transaction->recipient_bank_account_id,
- $transaction->payment_method,
- $payment_amount,
- $booking_amount,
- $transaction->currency_id,
- $transaction->original_currency_id,
- $booking_currency_average_rate,
- $total_tax,
- $total_service_charge,
- null,
- ApprovalStatus::APPROVED
- );
- $invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
-
- $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
-
- $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
- $document_object = new DocumentObject(
- DocumentType::PURCHASE_ORDER,
- [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
- '',
- ApprovalStatus::COMPLETED,
- 'purchase_orders'
- );
- $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
- $this->createsFile->execute($document, $document_object);
-
- $deliver_order_pdf = LaravelMpdf::loadView('pages.pdfs.deliver_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
- $document_object = new DocumentObject(
- DocumentType::DELIVER_ORDER,
- [chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))],
- '',
- ApprovalStatus::COMPLETED,
- 'deliver_orders'
- );
-
- /** @var Document $document */
- $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
- $this->createsFile->execute($document, $document_object);
-
-
- $invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
- $document_object = new DocumentObject(
- DocumentType::INVOICE,
- [chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
- '',
- ApprovalStatus::COMPLETED,
- 'invoices'
- );
- $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
- $this->createsFile->execute($document, $document_object);
-
- $billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
-
- $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
-
- $transaction_object = new TransactionObject(
- $billNumber,
- TransactionType::SUPPLIER_DELIVER,
- $transaction->issuer,
- $transaction->receiver,
- $transaction->recipient_bank_account_id,
- $transaction->payment_method,
- $payment_amount,
- $booking_amount,
- $transaction->currency_id,
- $transaction->original_currency_id,
- $booking_currency_average_rate,
- $total_tax,
- $total_service_charge,
- null,
- ApprovalStatus::APPROVED
- );
- $supplier_deliver_order_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
-
- $supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
- $document_object = new DocumentObject(
- DocumentType::SUPPLIER_DELIVER_ORDER,
- [chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
- '',
- ApprovalStatus::COMPLETED,
- 'supplier_deliver_orders'
- );
- $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
- $this->createsFile->execute($document, $document_object);
-
- $this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
- }
+ if($constants->detail->is_billable && !$po_order_transaction) {
+ return;
}
+
+ $transaction = $booking->transactions()
+ ->where('type', TransactionType::PAYMENT)
+ ->first();
+
+ $billNumber = $this->generatesTransactionBillNumber->execute('INV-');
+
+ $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT);
+
+ $total_service_charge = $booking->transactions()
+ ->where('type', TransactionType::PAYMENT)
+ ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
+ ->sum('service_charge');
+
+ $total_tax = $booking->transactions()
+ ->where('type', TransactionType::PAYMENT)
+ ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
+ ->sum('tax');
+
+ $transaction_object = new TransactionObject(
+ $billNumber,
+ TransactionType::INVOICE,
+ $transaction->issuer,
+ $transaction->receiver,
+ $transaction->recipient_bank_account_id,
+ $transaction->payment_method,
+ $payment_amount,
+ $booking_amount,
+ $transaction->currency_id,
+ $transaction->original_currency_id,
+ $booking_currency_average_rate,
+ $total_tax,
+ $total_service_charge,
+ null,
+ ApprovalStatus::APPROVED
+ );
+ $invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
+
+ $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
+
+ $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
+ $document_object = new DocumentObject(
+ DocumentType::PURCHASE_ORDER,
+ [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
+ '',
+ ApprovalStatus::COMPLETED,
+ 'purchase_orders'
+ );
+ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
+ $this->createsFile->execute($document, $document_object);
+
+ $deliver_order_pdf = LaravelMpdf::loadView('pages.pdfs.deliver_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
+ $document_object = new DocumentObject(
+ DocumentType::DELIVER_ORDER,
+ [chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))],
+ '',
+ ApprovalStatus::COMPLETED,
+ 'delivery_orders'
+ );
+
+ /** @var Document $document */
+ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
+ $this->createsFile->execute($document, $document_object);
+
+
+ $invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
+ $document_object = new DocumentObject(
+ DocumentType::INVOICE,
+ [chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
+ '',
+ ApprovalStatus::COMPLETED,
+ 'invoices'
+ );
+ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
+ $this->createsFile->execute($document, $document_object);
+
+ $billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
+
+ $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
+
+ $transaction_object = new TransactionObject(
+ $billNumber,
+ TransactionType::SUPPLIER_DELIVER,
+ $transaction->issuer,
+ $transaction->receiver,
+ $transaction->recipient_bank_account_id,
+ $transaction->payment_method,
+ $payment_amount,
+ $booking_amount,
+ $transaction->currency_id,
+ $transaction->original_currency_id,
+ $booking_currency_average_rate,
+ $total_tax,
+ $total_service_charge,
+ null,
+ ApprovalStatus::APPROVED
+ );
+ $supplier_deliver_order_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
+
+ $supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
+ $document_object = new DocumentObject(
+ DocumentType::SUPPLIER_DELIVER_ORDER,
+ [chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
+ '',
+ ApprovalStatus::COMPLETED,
+ 'supplier_delivery_orders'
+ );
+ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
+ $this->createsFile->execute($document, $document_object);
+
+ $this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
}
}
diff --git a/app/Http/Resources/BankResource.php b/app/Http/Resources/BankResource.php
index a0bce774..e27126fc 100644
--- a/app/Http/Resources/BankResource.php
+++ b/app/Http/Resources/BankResource.php
@@ -20,6 +20,7 @@ class BankResource extends JsonResource
'type' => $this->type,
'reference' => $this->reference,
'bank_name' => $this->bank_name,
+ 'bank_branch' => $this->bank_name,
'holder_name' => $this->holder_name,
'account_no' => $this->account_no,
'country_id' => $this->country_id,
diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php
index b92cbac0..b91bf7f8 100644
--- a/app/Http/Resources/BookingResource.php
+++ b/app/Http/Resources/BookingResource.php
@@ -38,7 +38,7 @@ class BookingResource extends JsonResource
'conversion_currency' => new CurrencyResource($this->conversionCurrency),
'documents' => [
'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()),
- 'deliver_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
+ 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()),
'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()),
],
diff --git a/app/Http/Resources/DocumentResource.php b/app/Http/Resources/DocumentResource.php
index dbfea08c..7ec1f6fd 100644
--- a/app/Http/Resources/DocumentResource.php
+++ b/app/Http/Resources/DocumentResource.php
@@ -4,6 +4,7 @@ namespace App\Http\Resources;
use App\Models\Company;
use App\Models\Document;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -23,7 +24,8 @@ class DocumentResource extends JsonResource
'status' => (int) $this->status,
'document_type' => $this->document_type,
'owner' => new CompanyResource($this->whenLoaded('owner')),
- 'files' => FileResource::collection($this->files)
+ 'files' => FileResource::collection($this->files),
+ 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:s:i')
];
}
}
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 06093c1f..0e39c289 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -60,7 +60,6 @@ class Transaction extends AbstractModel implements Documentable
{
if($this->booking()->first()->fix_currency_id !== 1) {
$currency_rate = $this->currency()->first()->rates()->where('payment_method_type', $this->payment_method)->first();
- dd($this->payment_method);
return number_format($this->original_amount / $currency_rate->selling, 2);
}
@@ -100,4 +99,13 @@ class Transaction extends AbstractModel implements Documentable
{
return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeTransferred(Builder $query)
+ {
+ return $query->whereIn('status', [ApprovalStatus::COMPLETED]);
+ }
}
diff --git a/resources/assets/vue/components/bookings/elements/CurrencyOrderComponent.vue b/resources/assets/vue/components/bookings/elements/CurrencyOrderComponent.vue
new file mode 100644
index 00000000..5329e0e6
--- /dev/null
+++ b/resources/assets/vue/components/bookings/elements/CurrencyOrderComponent.vue
@@ -0,0 +1,87 @@
+
+ Currency Order Placed
+
Invoice
-Purchase Order
-Delivery Order
-Supplier DO
-Invoice
+Purchase Order
+Delivery Order
+Supplier DO
+