|
@@ -147,24 +147,40 @@ class Account extends Model
|
147
|
147
|
return $this->hasMany(JournalEntry::class, 'account_id');
|
148
|
148
|
}
|
149
|
149
|
|
150
|
|
- public static function getAccountsReceivableAccount(): self
|
|
150
|
+ public static function getAccountsReceivableAccount(?int $companyId = null): self
|
151
|
151
|
{
|
152
|
|
- return self::where('name', 'Accounts Receivable')->firstOrFail();
|
|
152
|
+ return self::where('name', 'Accounts Receivable')
|
|
153
|
+ ->when($companyId, function (Builder $query) use ($companyId) {
|
|
154
|
+ $query->where('company_id', $companyId);
|
|
155
|
+ })
|
|
156
|
+ ->firstOrFail();
|
153
|
157
|
}
|
154
|
158
|
|
155
|
|
- public static function getAccountsPayableAccount(): self
|
|
159
|
+ public static function getAccountsPayableAccount(?int $companyId = null): self
|
156
|
160
|
{
|
157
|
|
- return self::where('name', 'Accounts Payable')->firstOrFail();
|
|
161
|
+ return self::where('name', 'Accounts Payable')
|
|
162
|
+ ->when($companyId, function (Builder $query) use ($companyId) {
|
|
163
|
+ $query->where('company_id', $companyId);
|
|
164
|
+ })
|
|
165
|
+ ->firstOrFail();
|
158
|
166
|
}
|
159
|
167
|
|
160
|
|
- public static function getSalesDiscountAccount(): self
|
|
168
|
+ public static function getSalesDiscountAccount(?int $companyId = null): self
|
161
|
169
|
{
|
162
|
|
- return self::where('name', 'Sales Discount')->firstOrFail();
|
|
170
|
+ return self::where('name', 'Sales Discount')
|
|
171
|
+ ->when($companyId, function (Builder $query) use ($companyId) {
|
|
172
|
+ $query->where('company_id', $companyId);
|
|
173
|
+ })
|
|
174
|
+ ->firstOrFail();
|
163
|
175
|
}
|
164
|
176
|
|
165
|
|
- public static function getPurchaseDiscountAccount(): self
|
|
177
|
+ public static function getPurchaseDiscountAccount(?int $companyId = null): self
|
166
|
178
|
{
|
167
|
|
- return self::where('name', 'Purchase Discount')->firstOrFail();
|
|
179
|
+ return self::where('name', 'Purchase Discount')
|
|
180
|
+ ->when($companyId, function (Builder $query) use ($companyId) {
|
|
181
|
+ $query->where('company_id', $companyId);
|
|
182
|
+ })
|
|
183
|
+ ->firstOrFail();
|
168
|
184
|
}
|
169
|
185
|
|
170
|
186
|
protected static function newFactory(): Factory
|