Created
June 30, 2021 05:14
-
-
Save phpfour/ff62f9f4db93f8820933f6e3578cb94e to your computer and use it in GitHub Desktop.
Akaunting Data Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: database/seeds/SampleData.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/database/seeds/SampleData.php b/database/seeds/SampleData.php | |
--- a/database/seeds/SampleData.php (revision 5a305a859efbc0568ff19820d21b432713df52ac) | |
+++ b/database/seeds/SampleData.php (date 1624084150026) | |
@@ -37,13 +37,15 @@ | |
Contact::factory()->count($count)->create(); | |
$bar->advance(); | |
- Category::factory()->count($count)->create(); | |
+ // Category::factory()->count($count)->create(); | |
$bar->advance(); | |
- Tax::factory()->count($small_count)->enabled()->create(); | |
+ Tax::factory()->count(3)->enabled()->create(); | |
$bar->advance(); | |
- Item::factory()->count($count)->create(); | |
+ for($i = 0; $i < 15; $i++) { | |
+ Item::factory()->create(); | |
+ } | |
$bar->advance(); | |
Account::factory()->count($small_count)->create(); | |
Index: database/factories/Contact.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/database/factories/Contact.php b/database/factories/Contact.php | |
--- a/database/factories/Contact.php (revision 5a305a859efbc0568ff19820d21b432713df52ac) | |
+++ b/database/factories/Contact.php (date 1624080985630) | |
@@ -35,7 +35,7 @@ | |
'tax_number' => $this->faker->randomNumber(9), | |
'phone' => $this->faker->phoneNumber, | |
'address' => $this->faker->address, | |
- 'website' => 'https://akaunting.com', | |
+ 'website' => $this->faker->domainName, | |
'currency_code' => setting('default.currency'), | |
'reference' => $this->faker->text(5), | |
'enabled' => $this->faker->boolean ? 1 : 0, | |
Index: database/factories/Item.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/database/factories/Item.php b/database/factories/Item.php | |
--- a/database/factories/Item.php (revision 5a305a859efbc0568ff19820d21b432713df52ac) | |
+++ b/database/factories/Item.php (date 1624084543513) | |
@@ -21,17 +21,45 @@ | |
*/ | |
public function definition() | |
{ | |
+ $purchasePrice = $this->faker->randomFloat(2, 100, 500); | |
+ $salePrice = $this->faker->randomFloat(2, 300, 1000); | |
+ | |
+ while ($salePrice < $purchasePrice) { | |
+ $salePrice = $this->faker->randomFloat(2, 300, 1000); | |
+ } | |
+ | |
return [ | |
'company_id' => $this->company->id, | |
- 'name' => $this->faker->text(15), | |
- 'description' => $this->faker->text(100), | |
- 'purchase_price' => $this->faker->randomFloat(2, 10, 20), | |
- 'sale_price' => $this->faker->randomFloat(2, 10, 20), | |
+ 'name' => $this->getRandomName(), | |
+ 'description' => $this->faker->text(25), | |
+ 'purchase_price' => $purchasePrice, | |
+ 'sale_price' => $salePrice, | |
'category_id' => $this->company->categories()->item()->get()->random(1)->pluck('id')->first(), | |
'enabled' => $this->faker->boolean ? 1 : 0, | |
]; | |
} | |
+ private function getRandomName() | |
+ { | |
+ $types = ['Software', 'Consultancy', 'Service']; | |
+ | |
+ $subtypes = [ | |
+ 'Software' => ['Accounting', 'Logistics', 'CRM', 'CMS', 'Publishing', 'Automation'], | |
+ 'Consultancy' => ['Audit', 'Accounting', 'Legal', 'Strategic', 'Business Modelling'], | |
+ 'Service' => ['Transportation', 'Legal', 'Repair', 'Writing', 'Advertising'] | |
+ ]; | |
+ | |
+ $type = $this->faker->randomElement($types); | |
+ $name = sprintf('%s %s', $this->faker->randomElement($subtypes[$type]), $type); | |
+ | |
+ while (\App\Models\Common\Item::query()->where('name', $name)->count() > 0) { | |
+ $type = $this->faker->randomElement($types); | |
+ $name = sprintf('%s %s', $this->faker->randomElement($subtypes[$type]), $type); | |
+ } | |
+ | |
+ return $name; | |
+ } | |
+ | |
/** | |
* Indicate that the model is enabled. | |
* | |
Index: database/factories/Account.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/database/factories/Account.php b/database/factories/Account.php | |
--- a/database/factories/Account.php (revision 5a305a859efbc0568ff19820d21b432713df52ac) | |
+++ b/database/factories/Account.php (date 1624081981530) | |
@@ -23,7 +23,7 @@ | |
{ | |
return [ | |
'company_id' => $this->company->id, | |
- 'name' => $this->faker->text(15), | |
+ 'name' => sprintf('%s Bank', $this->faker->company), | |
'number' => (string) $this->faker->iban(), | |
'currency_code' => $this->company->currencies()->enabled()->get()->random(1)->pluck('code')->first(), | |
'opening_balance' => '0', | |
Index: database/factories/Tax.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/database/factories/Tax.php b/database/factories/Tax.php | |
--- a/database/factories/Tax.php (revision 5a305a859efbc0568ff19820d21b432713df52ac) | |
+++ b/database/factories/Tax.php (date 1624084545518) | |
@@ -23,9 +23,11 @@ | |
{ | |
$types = ['normal', 'inclusive', 'compound', 'fixed', 'withholding']; | |
+ $names = ['Standard', 'Reduced', 'Special', 'VAT']; | |
+ | |
return [ | |
'company_id' => $this->company->id, | |
- 'name' => $this->faker->text(15), | |
+ 'name' => $this->faker->randomElement($names), | |
'rate' => $this->faker->randomFloat(2, 10, 20), | |
'type' => $this->faker->randomElement($types), | |
'enabled' => $this->faker->boolean ? 1 : 0, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment