paymenr order

This commit is contained in:
2024-11-03 21:30:28 +05:00
parent 1c650710b1
commit 62ea6af082
27 changed files with 27049 additions and 3 deletions

BIN
app/.DS_Store vendored

Binary file not shown.

View File

@@ -0,0 +1,128 @@
<?php
namespace App\Filament\Resources\PaymentOrder;
use App\Filament\Resources\PaymentOrder\PaymentOrderResource\Pages;
use App\Modules\PaymentOrder\Models\PaymentOrder;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class PaymentOrderResource extends Resource
{
protected static ?string $model = PaymentOrder::class;
protected static ?string $navigationIcon = 'heroicon-o-receipt-percent';
public static function form(Form $form): Form
{
return $form
->schema([
Fieldset::make(__('Töleg'))
->schema([
TextInput::make('number')
->integer()
->required(),
TextInput::make('money_amount')
->required()
->label('Pul mocberi'),
TextInput::make('bank_code')
->required()
->label('Bank topary'),
TextInput::make('payment_reason_number')
->integer()
->required()
->label('Toleg maksady nomeri'),
Textarea::make('payment_reason_description')
->label('Toleg maksady')
->autosize(),
]),
Fieldset::make('Toleyji')
->schema([
TextInput::make('t_name')
->label('ady familyasy'),
TextInput::make('t_ssb')
->label('ŞSB'),
TextInput::make('t_bab')
->label('BAB'),
TextInput::make('t_bank')
->label('Banky'),
TextInput::make('t_hb_1')
->label('H/b 1'),
TextInput::make('t_hb_2')
->label('H/b 2'),
]),
Fieldset::make('Alyjy')
->schema([
TextInput::make('a_name')
->label('ady familyasy'),
TextInput::make('a_ssb')
->label('ŞSB'),
TextInput::make('a_bab')
->label('BAB'),
TextInput::make('a_bank')
->label('Banky'),
TextInput::make('a_hb_1')
->label('H/b 1'),
TextInput::make('a_hb_2')
->label('H/b 2'),
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('number'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPaymentOrders::route('/'),
'create' => Pages\CreatePaymentOrder::route('/create'),
'edit' => Pages\EditPaymentOrder::route('/{record}/edit'),
];
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\PaymentOrder\PaymentOrderResource\Pages;
use App\Filament\Resources\PaymentOrder\PaymentOrderResource;
use Filament\Resources\Pages\CreateRecord;
class CreatePaymentOrder extends CreateRecord
{
protected static string $resource = PaymentOrderResource::class;
}

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Filament\Resources\PaymentOrder\PaymentOrderResource\Pages;
use App\Filament\Resources\PaymentOrder\PaymentOrderResource;
use Carbon\Carbon;
use Filament\Actions;
use Filament\Actions\Action;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use PhpOffice\PhpWord\TemplateProcessor;
class EditPaymentOrder extends EditRecord
{
protected static string $resource = PaymentOrderResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
Action::make('sendEmail')
->action(function (array $data) {
$paymentOrder = $this->getRecord();
Carbon::setLocale('tk');
$orderNumber = 1;
$date_written_turkmen = sprintf(
'%s -nji(y) ýylyň %s aýynyň %s',
$paymentOrder->created_at->year,
Str::lower($paymentOrder->created_at->translatedFormat('F')),
$paymentOrder->created_at->format('d')
);
$templateProcessor = new TemplateProcessor(modules_path('PaymentOrder/Resources/Docs/orders.docx'));
$templateProcessor->setValues([
'n' => $paymentOrder->number,
'date_written_turkmen' => $date_written_turkmen,
'p_date' => $paymentOrder->created_at->format('Y-m-d'),
'money_amount' => $paymentOrder->money_amount,
// Bank topary
'b_nm' => $paymentOrder->bank_code,
't_name' => $paymentOrder->t_name,
't_ssb' => $paymentOrder->t_ssb,
't_bab' => $paymentOrder->t_bab,
't_bank' => $paymentOrder->t_bank,
't_hb_1' => $paymentOrder->t_hb_1,
't_hb_2' => $paymentOrder->t_hb_2,
'a_name' => $paymentOrder->a_name,
'a_ssb' => $paymentOrder->a_ssb,
'a_bab' => $paymentOrder->a_bab,
'a_bank' => $paymentOrder->a_bank,
'a_hb_1' => $paymentOrder->a_hb_1,
'a_hb_2' => $paymentOrder->a_hb_2,
]);
$pathToSave = storage_path('app/private/ok.docx');
$templateProcessor->saveAs($pathToSave);
return Storage::disk('private')->download('ok.docx');
}),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\PaymentOrder\PaymentOrderResource\Pages;
use App\Filament\Resources\PaymentOrder\PaymentOrderResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListPaymentOrders extends ListRecords
{
protected static string $resource = PaymentOrderResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -113,8 +113,6 @@ function logDB(): void
/**
* Get latest number
*
* @param string $tableName
*/
function getLatestNumber(string $tableName = 'incoming_letters', string $column = 'number'): int
{
@@ -122,3 +120,4 @@ function getLatestNumber(string $tableName = 'incoming_letters', string $column
return intval($data->max_number) ?? 0;
}

BIN
app/Modules/.DS_Store vendored

Binary file not shown.

BIN
app/Modules/PaymentOrder/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Modules\PaymentOrder\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PaymentOrderController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request): void
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): void
{
//
}
/**
* Display the specified resource.
*/
public function show(Request $request): void
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request): void
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Request $request): void
{
//
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('payment_orders', function (Blueprint $table) {
$table->id();
$table->string('number')->nullable();
$table->string('money_amount')->nullable();
$table->string('payment_reason_number')->nullable();
$table->text('payment_reason_description')->nullable();
$table->string('bank_code')->nullable();
$table->string('t_name')->nullable();
$table->string('t_ssb')->nullable();
$table->string('t_bab')->nullable();
$table->string('t_bank')->nullable();
$table->string('t_hb_1')->nullable();
$table->string('t_hb_2')->nullable();
$table->string('a_name')->nullable();
$table->string('a_ssb')->nullable();
$table->string('a_bab')->nullable();
$table->string('a_bank')->nullable();
$table->string('a_hb_1')->nullable();
$table->string('a_hb_2')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('payment_orders');
}
};

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Modules\PaymentOrder\Models;
use Illuminate\Database\Eloquent\Model;
class PaymentOrder extends Model {}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Modules\PaymentOrder;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class PaymentOrderModule implements ModuleContract
{
use Makeable;
/**
* Module is enabled
*/
protected bool $enabled = true;
/**
* Check if is module enabled
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Disable module
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* Enable module
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* Check if module has a filament resource
*/
public function hasFilamentResource(): bool
{
return true;
}
}

View File

@@ -0,0 +1,5 @@
<?php
namespace App\Modules\PaymentOrder\Repositories;
class PaymentOrderRepository {}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Modules\TurkmenNumberFormatter\Repositories;
class TurkmenNumberFormatter
{
// Define number mappings
private static $units = ['', 'bir', 'iki', 'üç', 'dört', 'bäş', 'alty', 'ýedi', 'sekiz', 'dokuz'];
private static $tens = ['', 'on', 'ýigrimi', 'otuz', 'kyrk', 'elli', 'altmyş', 'ýetmiş', 'segsen', 'togsan'];
private static $hundreds = ['', 'ýüz', 'iki ýüz', 'üç ýüz', 'dört ýüz', 'bäş ýüz', 'alty ýüz', 'ýedi ýüz', 'sekiz ýüz', 'dokuz ýüz'];
private static $largeNumbers = ['', 'müň', 'million', 'milliard', 'trillion'];
/**
* Main method to format a given amount in Turkmen.
*
* @param float $amount The amount to format.
* @return string The amount in written Turkmen format.
*/
public static function format($amount)
{
// Split the amount into whole and fractional parts
[$whole, $fraction] = explode('.', number_format($amount, 2, '.', ''));
// Convert the whole part
$wholeWords = self::convertWholePart($whole);
// Convert the fractional part
$fractionWords = self::convertFractionalPart($fraction);
return trim($wholeWords.' '.$fractionWords);
}
/**
* Convert the whole part of the number.
*
* @param int $whole The whole part of the number.
* @return string The converted whole part in Turkmen.
*/
private static function convertWholePart($whole)
{
$words = '';
$level = 0;
while ($whole > 0) {
$part = $whole % 1000;
$whole = (int) ($whole / 1000);
if ($part > 0) {
$words = self::convertToWords($part).' '.self::$largeNumbers[$level].' '.$words;
}
$level++;
}
return trim($words).' manat';
}
/**
* Convert the fractional part of the number.
*
* @param int $fraction The fractional part of the number.
* @return string The converted fractional part in Turkmen.
*/
private static function convertFractionalPart($fraction)
{
if ($fraction <= 0) {
return '';
}
$fractionTens = (int) ($fraction / 10);
$fractionUnits = $fraction % 10;
$words = '';
$words .= ($fractionTens > 0 ? self::$tens[$fractionTens].' ' : '');
$words .= ($fractionUnits > 0 ? self::$units[$fractionUnits].' ' : '');
return trim($words).' teňňe';
}
/**
* Convert a number up to 999 to Turkmen words.
*
* @param int $num The number to convert.
* @return string The converted number in Turkmen.
*/
private static function convertToWords($num)
{
$words = '';
if ($num >= 100) {
$hundredsPart = (int) ($num / 100);
$num %= 100;
$words .= self::$hundreds[$hundredsPart].' ';
}
if ($num >= 10) {
$tensPart = (int) ($num / 10);
$num %= 10;
$words .= self::$tens[$tensPart].' ';
}
if ($num > 0) {
$words .= self::$units[$num].' ';
}
return trim($words);
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Modules\TurkmenNumberFormatter;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class TurkmenNumberFormatterModule implements ModuleContract
{
use Makeable;
/**
* Module is enabled
*/
protected bool $enabled = true;
/**
* Check if is module enabled
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Disable module
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* Enable module
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* Check if module has a filament resource
*/
public function hasFilamentResource(): bool
{
return false;
}
}