akaunting 3.1
This commit is contained in:
parent
503cfa2118
commit
f15f8c68d8
710
LICENSE.txt
710
LICENSE.txt
|
|
@ -1,674 +1,78 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
|
||||
“Business Source License” is a trademark of MariaDB Corporation Ab.
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Parameters
|
||||
|
||||
Preamble
|
||||
Licensor: Akaunting, Inc.
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
Licensed Work: Akaunting
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
Additional Use Grant: You may make production use of the Licensed Work, provided
|
||||
you do not use it in any of the following ways:
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
(1) Use the Licensed Work with a total of more than two users or
|
||||
one company or one thousand invoices.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
(2) Remove the name, logo, copyright, or other branding material
|
||||
from the Licensed Work to create a "rebranded" or "white labeled"
|
||||
version to distribute as part of any commercial or non-profit
|
||||
product or service.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
(3) Use the Licensed Work for an Accounting Service. An
|
||||
"Accounting Service" is a commercial offering that allows third
|
||||
parties (other than your employees and contractors) to access
|
||||
the functionality of the Licensed Work so that such third
|
||||
parties directly benefit from the accounting or invoicing
|
||||
features of the Licensed Work.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
Change Date: Four years from the date the Licensed Work is published.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
Change License: GPLv3
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
For information about alternative licensing arrangements for the Licensed Work,
|
||||
please visit: https://akaunting.com/plans-on-premise
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
Notice
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
Business Source License 1.1
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
Terms
|
||||
|
||||
0. Definitions.
|
||||
The Licensor hereby grants you the right to copy, modify, create derivative
|
||||
works, redistribute, and make non-production use of the Licensed Work. The
|
||||
Licensor may make an Additional Use Grant, above, permitting limited production use.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
Effective on the Change Date, or the fourth anniversary of the first publicly
|
||||
available distribution of a specific version of the Licensed Work under this
|
||||
License, whichever comes first, the Licensor hereby grants you rights under
|
||||
the terms of the Change License, and the rights granted in the paragraph
|
||||
above terminate.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
If your use of the Licensed Work does not comply with the requirements
|
||||
currently in effect as described in this License, you must purchase a
|
||||
commercial license from the Licensor, its affiliated entities, or authorized
|
||||
resellers, or you must refrain from using the Licensed Work.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
All copies of the original and modified Licensed Work, and derivative works
|
||||
of the Licensed Work, are subject to this License. This License applies
|
||||
separately for each version of the Licensed Work and the Change Date may vary
|
||||
for each version of the Licensed Work released by Licensor.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
You must conspicuously display this License on each original or modified copy
|
||||
of the Licensed Work. If you receive the Licensed Work in original or
|
||||
modified form from a third party, the terms and conditions set forth in this
|
||||
License apply to your use of that work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
Any use of the Licensed Work in violation of this License will automatically
|
||||
terminate your rights under this License for the current and all other
|
||||
versions of the Licensed Work.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
This License does not grant you any right in any trademark or logo of
|
||||
Licensor or its affiliates (provided that you may use a trademark or logo of
|
||||
Licensor as expressly required by this License).
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
||||
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
||||
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
||||
TITLE.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
[](https://github.com/akaunting/akaunting/actions)
|
||||
[](LICENSE.txt)
|
||||
|
||||
Akaunting is a free, open source and online accounting software designed for small businesses and freelancers. It is built with modern technologies such as Laravel, VueJS, Tailwind, RESTful API etc. Thanks to its modular structure, Akaunting provides an awesome App Store for users and developers.
|
||||
Online accounting software designed for small businesses and freelancers. Akaunting is built with modern technologies such as Laravel, VueJS, Tailwind, RESTful API etc. Thanks to its modular structure, Akaunting provides an awesome App Store for users and developers.
|
||||
|
||||
* [Home](https://akaunting.com) - The house of Akaunting
|
||||
* [Forum](https://akaunting.com/forum) - Ask for support
|
||||
|
|
@ -67,4 +67,4 @@ Please review [our security policy](https://github.com/akaunting/akaunting/secur
|
|||
|
||||
## License
|
||||
|
||||
Akaunting is released under the [GPLv3 license](LICENSE.txt).
|
||||
Akaunting is released under the [BSL license](LICENSE.txt).
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ use App\Jobs\Common\UpdateContact;
|
|||
use App\Jobs\Banking\DeleteTransaction;
|
||||
use App\Traits\Jobs;
|
||||
use App\Traits\Relationships;
|
||||
use App\Traits\Translations;
|
||||
use App\Utilities\Export;
|
||||
use App\Utilities\Import;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
abstract class BulkAction
|
||||
{
|
||||
use Jobs, Relationships;
|
||||
use Jobs, Relationships, Translations;
|
||||
|
||||
public $model = false;
|
||||
|
||||
|
|
@ -85,6 +86,52 @@ abstract class BulkAction
|
|||
return $request->get('selected', []);
|
||||
}
|
||||
|
||||
public function getUpdateRequest($request)
|
||||
{
|
||||
foreach ($request->all() as $key => $value) {
|
||||
if (empty($value)) {
|
||||
unset($request[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a response based on request type like HTML, JSON, or anything else.
|
||||
*
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function response($view, $data = [])
|
||||
{
|
||||
$method = request()->get('handle', 'edit');
|
||||
|
||||
$handle = $this->actions[$method]['handle'] ?? 'update';
|
||||
$url = route('bulk-actions.action', $this->path);
|
||||
|
||||
$html = view('components.index.bulkaction.modal', [
|
||||
'url' => $url,
|
||||
'handle' => $handle,
|
||||
'selected' => $data['selected'] ?? $this->getSelectedInput(request()),
|
||||
'html' => view($view, $data)->render(),
|
||||
])->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => '',
|
||||
'data' => [
|
||||
'title' => $this->findTranslation($this->text),
|
||||
'path' => $url,
|
||||
'handle' => $handle,
|
||||
],
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\Jobs;
|
||||
use App\Utilities\Date;
|
||||
|
|
@ -54,7 +53,7 @@ abstract class Factory extends BaseFactory
|
|||
|
||||
public function setUser(): void
|
||||
{
|
||||
$this->user = User::first();
|
||||
$this->user = user_model_class()::first();
|
||||
}
|
||||
|
||||
public function setCompany(): void
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Abstracts\Http\Response;
|
|||
use App\Traits\Jobs;
|
||||
use App\Traits\Permissions;
|
||||
use App\Traits\Relationships;
|
||||
use App\Traits\SearchString;
|
||||
use App\Utilities\Export;
|
||||
use App\Utilities\Import;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -17,7 +18,7 @@ use Illuminate\Routing\Controller as BaseController;
|
|||
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, Jobs, Permissions, Relationships, ValidatesRequests;
|
||||
use AuthorizesRequests, Jobs, Permissions, Relationships, SearchString, ValidatesRequests;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
|
|
@ -96,4 +97,29 @@ abstract class Controller extends BaseController
|
|||
{
|
||||
return Export::toExcel($class, $translation, $extension);
|
||||
}
|
||||
|
||||
public function setActiveTabForDocuments(): void
|
||||
{
|
||||
if (request()->get('list_records') == 'all') {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = $this->getSearchStringValue('status');
|
||||
|
||||
if (empty($status)) {
|
||||
$search = config('type.document.' . $this->type . '.route.params.unpaid.search');
|
||||
|
||||
request()->offsetSet('search', $search);
|
||||
request()->offsetSet('programmatic', '1');
|
||||
} else {
|
||||
$unpaid = str_replace('status:', '', config('type.document.' . $this->type . '.route.params.unpaid.search'));
|
||||
$draft = str_replace('status:', '', config('type.document.' . $this->type . '.route.params.draft.search'));
|
||||
|
||||
if (($status == $unpaid) || ($status == $draft)) {
|
||||
return;
|
||||
}
|
||||
|
||||
request()->offsetSet('list_records', 'all');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use App\Models\Setting\Category;
|
|||
use App\Traits\Contacts;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\SearchString;
|
||||
use App\Utilities\Date;
|
||||
|
||||
abstract class Report
|
||||
{
|
||||
|
|
@ -36,40 +35,37 @@ abstract class Report
|
|||
|| ($event->class->model->settings->group != $group);
|
||||
}
|
||||
|
||||
public function getYears()
|
||||
public function setDateFilter($event)
|
||||
{
|
||||
$now = Date::now();
|
||||
$financial_year = $this->getFinancialYear();
|
||||
|
||||
$financial_start = setting('localisation.financial_start');
|
||||
$setting = explode('-', $financial_start);
|
||||
$financial_start_day = ! empty($setting[0]) ? $setting[0] : '01';
|
||||
$start_date = request()->get('start_date', $financial_year->copy()->getStartDate()->toDateString());
|
||||
$end_date = request()->get('end_date', $financial_year->copy()->getEndDate()->toDateString());
|
||||
$default_value = $start_date . '-to-' . $end_date;
|
||||
|
||||
$format = ($financial_start == '01-01')
|
||||
? $this->getYearlyDateFormat()
|
||||
: (($financial_start_day != '01') ? $this->getDailyDateFormat() : $this->getMonthlyDateFormat());
|
||||
|
||||
$years = [];
|
||||
|
||||
$y = $now->addYears(2);
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$financial_year = $this->getFinancialYear($y->year);
|
||||
|
||||
if ($financial_start == '01-01') {
|
||||
$title = $financial_year->getStartDate()->copy()->format($format);
|
||||
} else {
|
||||
$start = $financial_year->getStartDate()->copy()->format($format);
|
||||
$end = $financial_year->getEndDate()->copy()->format($format);
|
||||
|
||||
$title = $start . ' - ' . $end;
|
||||
$event->class->filters['date_range'] = $this->getDateRange();
|
||||
$event->class->filters['keys']['date_range'] = 'date_range';
|
||||
$event->class->filters['defaults']['date_range'] = $default_value;
|
||||
$event->class->filters['operators']['date_range'] = [
|
||||
'equal' => true,
|
||||
'not_equal' => false,
|
||||
'range' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$years[$y->year] = $title;
|
||||
public function getDateRange()
|
||||
{
|
||||
$date_range = [];
|
||||
|
||||
$y->subYear();
|
||||
$shortcuts = $this->getDatePickerShortcuts();
|
||||
|
||||
foreach ($shortcuts as $text => $shortcut) {
|
||||
$date_range[$shortcut['start'] . '-to-' . $shortcut['end']] = $text;
|
||||
}
|
||||
|
||||
return $years;
|
||||
$date_range['custom'] = trans('general.date_range.custom');
|
||||
|
||||
return $date_range;
|
||||
}
|
||||
|
||||
public function getAccounts($limit = false)
|
||||
|
|
@ -143,23 +139,33 @@ abstract class Report
|
|||
];
|
||||
}
|
||||
|
||||
public function getPeriod()
|
||||
{
|
||||
return [
|
||||
'weekly' => trans('general.weekly'),
|
||||
'monthly' => trans('general.monthly'),
|
||||
'quarterly' => trans('general.quarterly'),
|
||||
'yearly' => trans('general.yearly'),
|
||||
];
|
||||
}
|
||||
|
||||
public function applyDateFilter($event)
|
||||
{
|
||||
$event->model->monthsOfYear($event->args['date_field']);
|
||||
$event->model->dateFilter($event->args['date_field']);
|
||||
}
|
||||
|
||||
public function applySearchStringFilter($event)
|
||||
{
|
||||
$input = request('search', '');
|
||||
|
||||
// Remove year as it's handled based on financial start
|
||||
$search_year = 'year:' . $this->getSearchStringValue('year', '', $input);
|
||||
$input = str_replace($search_year, '', $input);
|
||||
|
||||
// Remove basis as it's handled based on report itself
|
||||
$search_basis = 'basis:' . $this->getSearchStringValue('basis', 'accrual', $input);
|
||||
$input = str_replace($search_basis, '', $input);
|
||||
|
||||
// Remove period as it's handled based on report itself
|
||||
$search_period = 'period:' . $this->getSearchStringValue('period', 'quarterly', $input);
|
||||
$input = str_replace($search_period, '', $input);
|
||||
|
||||
$event->model->usingSearchString($input);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ abstract class Model extends Eloquent implements Ownable
|
|||
*/
|
||||
public function owner()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Auth\User', 'created_by', 'id')->withDefault(['name' => trans('general.na')]);
|
||||
return $this->belongsTo(user_model_class(), 'created_by', 'id')->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ use App\Events\Report\FilterShowing;
|
|||
use App\Events\Report\GroupApplying;
|
||||
use App\Events\Report\GroupShowing;
|
||||
use App\Events\Report\RowsShowing;
|
||||
use App\Events\Report\TotalCalculating;
|
||||
use App\Events\Report\TotalCalculated;
|
||||
use App\Exports\Common\Reports as Export;
|
||||
use App\Models\Common\Report as Model;
|
||||
use App\Models\Document\Document;
|
||||
|
|
@ -255,6 +257,22 @@ abstract class Report
|
|||
return view($this->views['print'])->with('class', $this);
|
||||
}
|
||||
|
||||
public function pdf()
|
||||
{
|
||||
$view = view($this->views['print'])->with('class', $this)->render();
|
||||
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
$pdf->setPaper('A4', 'landscape');
|
||||
|
||||
$file_name = $this->model->name . ' - ' . company()->name . '.pdf';
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
return ExportHelper::toExcel(new Export($this->views[$this->type], $this), $this->model->name);
|
||||
|
|
@ -262,7 +280,7 @@ abstract class Report
|
|||
|
||||
public function setColumnWidth()
|
||||
{
|
||||
if (!$period = $this->getSetting('period')) {
|
||||
if (! $period = $this->getPeriod()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -278,6 +296,9 @@ abstract class Report
|
|||
case 'monthly':
|
||||
$width = 'col-1 w-20';
|
||||
break;
|
||||
case 'weekly':
|
||||
$width = 'col-1 w-20';
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($width)) {
|
||||
|
|
@ -306,7 +327,7 @@ abstract class Report
|
|||
|
||||
public function setYear()
|
||||
{
|
||||
$this->year = $this->getSearchStringValue('year', Date::now()->year);
|
||||
$this->year = request()->filled('start_date') ? Date::parse(request('start_date'))->year : Date::now()->year;
|
||||
}
|
||||
|
||||
public function setViews()
|
||||
|
|
@ -346,34 +367,20 @@ abstract class Report
|
|||
|
||||
public function setDates()
|
||||
{
|
||||
if (! $period = $this->getSetting('period')) {
|
||||
if (! $period = $this->getPeriod()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$function = 'sub' . ucfirst(str_replace('ly', '', $period));
|
||||
[$start, $end] = $this->getStartAndEndDates($this->year);
|
||||
|
||||
$start = $this->getFinancialStart($this->year)->copy()->$function();
|
||||
|
||||
for ($j = 1; $j <= 12; $j++) {
|
||||
switch ($period) {
|
||||
case 'yearly':
|
||||
$start->addYear();
|
||||
|
||||
$j += 11;
|
||||
|
||||
break;
|
||||
case 'quarterly':
|
||||
$start->addQuarter();
|
||||
|
||||
$j += 2;
|
||||
|
||||
break;
|
||||
default:
|
||||
$start->addMonth();
|
||||
|
||||
break;
|
||||
}
|
||||
$counter = match ($period) {
|
||||
'weekly' => $end->diffInWeeks($start),
|
||||
'quarterly' => $end->diffInQuarters($start),
|
||||
'yearly' => $end->diffInYears($start),
|
||||
default => $end->diffInMonths($start),
|
||||
};
|
||||
|
||||
for ($j = 0; $j <= $counter; $j++) {
|
||||
$date = $this->getFormattedDate($start);
|
||||
|
||||
$this->dates[] = $date;
|
||||
|
|
@ -381,6 +388,13 @@ abstract class Report
|
|||
foreach ($this->tables as $table_key => $table_name) {
|
||||
$this->footer_totals[$table_key][$date] = 0;
|
||||
}
|
||||
|
||||
match ($period) {
|
||||
'weekly' => $start->addWeek(),
|
||||
'quarterly' => $start->addQuarter(),
|
||||
'yearly' => $start->addYear(),
|
||||
default => $start->addMonth(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -403,6 +417,8 @@ abstract class Report
|
|||
|
||||
public function setTotals($items, $date_field, $check_type = false, $table = 'default', $with_tax = true)
|
||||
{
|
||||
event(new TotalCalculating($this, $items, $date_field, $check_type, $table, $with_tax));
|
||||
|
||||
$group_field = $this->getSetting('group') . '_id';
|
||||
|
||||
foreach ($items as $item) {
|
||||
|
|
@ -439,6 +455,8 @@ abstract class Report
|
|||
$this->footer_totals[$table][$date] -= $amount;
|
||||
}
|
||||
}
|
||||
|
||||
event(new TotalCalculated($this, $items, $date_field, $check_type, $table, $with_tax));
|
||||
}
|
||||
|
||||
public function setArithmeticTotals($items, $date_field, $operator = 'add', $table = 'default', $amount_field = 'amount')
|
||||
|
|
@ -522,15 +540,15 @@ abstract class Report
|
|||
{
|
||||
$formatted_date = null;
|
||||
|
||||
switch ($this->getSetting('period')) {
|
||||
switch ($this->getPeriod()) {
|
||||
case 'yearly':
|
||||
$financial_year = $this->getFinancialYear($this->year);
|
||||
|
||||
if ($date->greaterThanOrEqualTo($financial_year->getStartDate()) && $date->lessThanOrEqualTo($financial_year->getEndDate())) {
|
||||
if (setting('localisation.financial_denote') == 'begins') {
|
||||
$formatted_date = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat());
|
||||
$formatted_date = $financial_year->copy()->getStartDate()->format($this->getYearlyDateFormat());
|
||||
} else {
|
||||
$formatted_date = $financial_year->getEndDate()->copy()->format($this->getYearlyDateFormat());
|
||||
$formatted_date = $financial_year->copy()->getEndDate()->format($this->getYearlyDateFormat());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -543,8 +561,23 @@ abstract class Report
|
|||
continue;
|
||||
}
|
||||
|
||||
$start = $quarter->getStartDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||
$end = $quarter->getEndDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||
$start = $quarter->copy()->getStartDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||
$end = $quarter->copy()->getEndDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||
|
||||
$formatted_date = $start . ' - ' . $end;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'weekly':
|
||||
$weeks = $this->getFinancialWeeks($this->year);
|
||||
|
||||
foreach ($weeks as $week) {
|
||||
if ($date->lessThan($week->getStartDate()) || $date->greaterThan($week->getEndDate())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$start = $week->copy()->getStartDate()->format($this->getDailyDateFormat($this->year));
|
||||
$end = $week->copy()->getEndDate()->format($this->getDailyDateFormat($this->year));
|
||||
|
||||
$formatted_date = $start . ' - ' . $end;
|
||||
}
|
||||
|
|
@ -582,6 +615,11 @@ abstract class Report
|
|||
return $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||
}
|
||||
|
||||
public function getPeriod()
|
||||
{
|
||||
return $this->getSearchStringValue('period', $this->getSetting('period'));
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
return [
|
||||
|
|
@ -616,6 +654,7 @@ abstract class Report
|
|||
'title' => trans('general.period'),
|
||||
'icon' => 'calendar',
|
||||
'values' => [
|
||||
'weekly' => trans('general.weekly'),
|
||||
'monthly' => trans('general.monthly'),
|
||||
'quarterly' => trans('general.quarterly'),
|
||||
'yearly' => trans('general.yearly'),
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ abstract class Form extends Component
|
|||
/** @var bool */
|
||||
public $hideSectionAddress;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSectionPersons;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionGeneralTitle;
|
||||
|
||||
|
|
@ -130,6 +133,12 @@ abstract class Form extends Component
|
|||
/** @var bool */
|
||||
public $hideCountry;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionPersonsTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionPersonsDescription;
|
||||
|
||||
/** @var string */
|
||||
public $cancelRoute;
|
||||
/* -- Content End -- */
|
||||
|
|
@ -142,7 +151,7 @@ abstract class Form extends Component
|
|||
public function __construct(
|
||||
string $type, $model = false, $contact = false,
|
||||
string $formId = 'contact', $formRoute = '', $formMethod = '',
|
||||
bool $hideSectionGeneral = false, bool $hideSectionBilling = false, bool $hideSectionAddress = false,
|
||||
bool $hideSectionGeneral = false, bool $hideSectionBilling = false, bool $hideSectionAddress = false, bool $hideSectionPersons = false,
|
||||
string $textSectionGeneralTitle = '', string $textSectionGeneralDescription = '',
|
||||
bool $hideName = false, string $textName = '', string $classNameFromGroupClass = '',
|
||||
bool $hideEmail = false, string $textEmail = '',
|
||||
|
|
@ -160,6 +169,7 @@ abstract class Form extends Component
|
|||
bool $hideZipCode = false, string $textZipCode = '',
|
||||
bool $hideState = false, string $textState = '',
|
||||
bool $hideCountry = false,
|
||||
string $textSectionPersonsTitle = '', string $textSectionPersonsDescription = '',
|
||||
string $cancelRoute = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
|
|
@ -175,6 +185,7 @@ abstract class Form extends Component
|
|||
$this->hideSectionGeneral = $hideSectionGeneral;
|
||||
$this->hideSectionBilling = $hideSectionBilling;
|
||||
$this->hideSectionAddress = $hideSectionAddress;
|
||||
$this->hideSectionPersons = $hideSectionPersons;
|
||||
|
||||
/* -- General Start -- */
|
||||
$this->textSectionGeneralTitle = $this->getTextSectionGeneralTitle($type, $textSectionGeneralTitle);
|
||||
|
|
@ -229,6 +240,11 @@ abstract class Form extends Component
|
|||
$this->hideState = $hideTaxNumber;
|
||||
/* -- Address End -- */
|
||||
|
||||
/* -- Persons Start -- */
|
||||
$this->textSectionPersonsTitle = $this->getTextSectionPersonsTitle($type, $textSectionPersonsTitle);
|
||||
$this->textSectionPersonsDescription = $this->getTextSectionPersonsDescription($type, $textSectionPersonsDescription);
|
||||
/* -- Persons End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
$this->cancelRoute = $this->getCancelRoute($type, $cancelRoute);
|
||||
/* -- Buttons End -- */
|
||||
|
|
@ -439,6 +455,37 @@ abstract class Form extends Component
|
|||
return 'customers.form_description.address';
|
||||
}
|
||||
|
||||
/* -- Persons Start -- */
|
||||
protected function getTextSectionPersonsTitle($type, $textSectionPersonsTitle)
|
||||
{
|
||||
if (! empty($textSectionPersonsTitle)) {
|
||||
return $textSectionPersonsTitle;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_contact_persons_title', 'contact_persons');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.contact_persons';
|
||||
}
|
||||
|
||||
protected function getTextSectionPersonsDescription($type, $textSectionPersonsDescription)
|
||||
{
|
||||
if (! empty($textSectionPersonsDescription)) {
|
||||
return $textSectionPersonsDescription;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_contact_persons_description');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'customers.form_description.contact_persons';
|
||||
}
|
||||
|
||||
protected function getTextAddress($type, $textAddress)
|
||||
{
|
||||
if (! empty($textAddress)) {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ abstract class Show extends Component
|
|||
|
||||
public $hideUser;
|
||||
|
||||
public $hidePersons;
|
||||
|
||||
public $hideBottomRight;
|
||||
/* -- Profile End -- */
|
||||
|
||||
|
|
@ -112,7 +114,7 @@ abstract class Show extends Component
|
|||
bool $hideButtonDelete = false, $routeButtonDelete = '', $textDeleteModal = '',
|
||||
bool $hideTopLeft = false, bool $hideAvatar = false, bool $hideEmail = false, bool $hidePhone = false,
|
||||
bool $hideTopRight = false, bool $hideOverdue = false, bool $hideOpen = false, bool $hidePaid = false,
|
||||
bool $hideBottomLeft = false, bool $hideAddress = false, bool $hideTaxNumber = false , bool $hideWebsite = false, bool $hideReference = false, bool $hideUser = false,
|
||||
bool $hideBottomLeft = false, bool $hideAddress = false, bool $hideTaxNumber = false , bool $hideWebsite = false, bool $hideReference = false, bool $hideUser = false, bool $hidePersons = false,
|
||||
bool $hideBottomRight = false
|
||||
) {
|
||||
/* -- Main Start -- */
|
||||
|
|
@ -169,6 +171,7 @@ abstract class Show extends Component
|
|||
$this->hideWebsite = $hideWebsite;
|
||||
$this->hideReference = $hideReference;
|
||||
$this->hideUser = $hideUser;
|
||||
$this->hidePersons = $hidePersons;
|
||||
|
||||
$this->hideContent = $hideBottomRight;
|
||||
/* -- Profile End -- */
|
||||
|
|
|
|||
|
|
@ -2,18 +2,16 @@
|
|||
|
||||
namespace App\Abstracts\View\Components\Documents;
|
||||
|
||||
use Akaunting\Module\Module;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Events\Common\BulkActionsAdding;
|
||||
use App\Traits\Documents;
|
||||
use App\Traits\Modules;
|
||||
use App\Traits\SearchString;
|
||||
use App\Traits\ViewComponents;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
abstract class Index extends Component
|
||||
{
|
||||
use Documents, Modules, ViewComponents;
|
||||
use Documents, Modules, SearchString, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'document';
|
||||
public const DEFAULT_TYPE = 'invoice';
|
||||
|
|
@ -43,6 +41,12 @@ abstract class Index extends Component
|
|||
/** @var string */
|
||||
public $routeTabRecurring;
|
||||
|
||||
/** @var string */
|
||||
public $routeParamsTabUnpaid;
|
||||
|
||||
/** @var string */
|
||||
public $routeParamsTabDraft;
|
||||
|
||||
/** @var string */
|
||||
public $textPage;
|
||||
|
||||
|
|
@ -113,6 +117,9 @@ abstract class Index extends Component
|
|||
/** @var string */
|
||||
public $tabActive;
|
||||
|
||||
/** @var string */
|
||||
public $tabSuffix;
|
||||
|
||||
/** @var bool */
|
||||
public $hideRecurringTemplates;
|
||||
|
||||
|
|
@ -217,14 +224,14 @@ abstract class Index extends Component
|
|||
*/
|
||||
public function __construct(
|
||||
string $type, string $alias = '', $documents = [], string $group = '', string $page = '', string $textTabDocument = '', string $textPage = '',
|
||||
string $routeTabDocument = '', string $routeTabRecurring = '',
|
||||
string $routeTabDocument = '', string $routeTabRecurring = '', string $routeParamsTabUnpaid = '', string $routeParamsTabDraft = '',
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
bool $hideAcceptPayment = false, bool $checkPermissionCreate = true,
|
||||
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false,
|
||||
string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
|
||||
bool $hideEmptyPage = false, array $emptyPageButtons = [], string $imageEmptyPage = '', string $textEmptyPage = '', string $urlDocsPath = '',
|
||||
bool $hideSummary = false, array $summaryItems = [],
|
||||
bool $withoutTabs = false, string $tabActive = '', bool $hideRecurringTemplates = false,
|
||||
bool $withoutTabs = false, string $tabActive = '', string $tabSuffix = '', bool $hideRecurringTemplates = false,
|
||||
bool $hideSearchString = false, bool $hideBulkAction = false,
|
||||
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '', string $classBulkAction = '',
|
||||
bool $hideDueAt = false, bool $hideIssuedAt = false, string $classDueAtAndIssueAt = '', string $textDueAt = '', string $textIssuedAt = '',
|
||||
|
|
@ -249,6 +256,8 @@ abstract class Index extends Component
|
|||
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
||||
|
||||
$this->routeTabDocument = $this->getRouteTabDocument($type, $routeTabDocument);
|
||||
$this->routeParamsTabUnpaid = $this->getRouteParamsTabUnpaid($type, $routeParamsTabUnpaid);
|
||||
$this->routeParamsTabDraft = $this->getRouteParamsTabDraft($type, $routeParamsTabDraft);
|
||||
$this->routeTabRecurring = $this->getRouteTabRecurring($type, $routeTabRecurring);
|
||||
/* -- Main End -- */
|
||||
|
||||
|
|
@ -284,6 +293,7 @@ abstract class Index extends Component
|
|||
|
||||
/* Container Start */
|
||||
$this->withoutTabs = $withoutTabs;
|
||||
$this->tabSuffix = $this->getTabSuffix($type, $tabSuffix);
|
||||
$this->tabActive = $this->getTabActive($type, $tabActive);
|
||||
|
||||
$this->hideRecurringTemplates = $hideRecurringTemplates;
|
||||
|
|
@ -429,7 +439,26 @@ abstract class Index extends Component
|
|||
return $tabActive;
|
||||
}
|
||||
|
||||
return $type;
|
||||
return $type . '-' . $this->tabSuffix;
|
||||
}
|
||||
|
||||
public function getTabSuffix($type, $tabSuffix)
|
||||
{
|
||||
if (! empty($tabSuffix)) {
|
||||
return $tabSuffix;
|
||||
}
|
||||
|
||||
if (request()->get('list_records') == 'all') {
|
||||
return 'all';
|
||||
}
|
||||
|
||||
$status = $this->getSearchStringValue('status');
|
||||
|
||||
if ($status == 'draft') {
|
||||
return 'draft';
|
||||
}
|
||||
|
||||
return 'unpaid';
|
||||
}
|
||||
|
||||
protected function getRouteTabDocument($type, $routeTabDocument)
|
||||
|
|
@ -447,6 +476,36 @@ abstract class Index extends Component
|
|||
return 'invoices.index';
|
||||
}
|
||||
|
||||
protected function getRouteParamsTabUnpaid($type, $routeParamsTabUnpaid)
|
||||
{
|
||||
if (! empty($routeParamsTabUnpaid)) {
|
||||
return $routeParamsTabUnpaid;
|
||||
}
|
||||
|
||||
$params = $this->getRouteParamsFromConfig($type, 'unpaid');
|
||||
|
||||
if (! empty($params)) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
return ['search' => 'status:sent,viewed,partial'];
|
||||
}
|
||||
|
||||
protected function getRouteParamsTabDraft($type, $routeParamsTabDraft)
|
||||
{
|
||||
if (! empty($routeParamsTabDraft)) {
|
||||
return $routeParamsTabDraft;
|
||||
}
|
||||
|
||||
$params = $this->getRouteParamsFromConfig($type, 'draft');
|
||||
|
||||
if (! empty($params)) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
return ['search' => 'status:draft'];
|
||||
}
|
||||
|
||||
protected function getRouteTabRecurring($type, $routeTabDocument)
|
||||
{
|
||||
if (! empty($routeTabDocument)) {
|
||||
|
|
|
|||
|
|
@ -110,6 +110,9 @@ abstract class Show extends Component
|
|||
/** @var string */
|
||||
public $cancelledRoute;
|
||||
|
||||
/** @var string */
|
||||
public $restoreRoute;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCustomize;
|
||||
|
||||
|
|
@ -328,7 +331,7 @@ abstract class Show extends Component
|
|||
bool $hideCreate = false, string $createRoute = '', string $textCreate = '', bool $hideButtonStatuses = false, bool $hideEdit = false, string $editRoute = '', string $showRoute = '',
|
||||
bool $hideMoreActions = false, bool $hideDuplicate = false, string $duplicateRoute = '', bool $hidePrint = false, string $printRoute = '',
|
||||
bool $hideShare = false, string $shareRoute = '', string $signedUrl = '', bool $hideEmail = false, string $emailRoute = '', string $textEmail = '', bool $hidePdf = false, string $pdfRoute = '',
|
||||
bool $hideCancel = false, string $cancelledRoute = '', bool $hideCustomize = false, string $permissionCustomize = '', string $customizeRoute = '',
|
||||
bool $hideCancel = false, string $cancelledRoute = '', string $restoreRoute = '', bool $hideCustomize = false, string $permissionCustomize = '', string $customizeRoute = '',
|
||||
bool $hideEnd = false, string $endRoute = '',
|
||||
bool $hideDelete = false, bool $checkReconciled = true, string $deleteRoute = '', string $textDeleteModal = '',
|
||||
bool $hideDivider1 = false, bool $hideDivider2 = false, bool $hideDivider3 = false, bool $hideDivider4 = false,
|
||||
|
|
@ -392,6 +395,7 @@ abstract class Show extends Component
|
|||
|
||||
$this->hideCancel = $hideCancel;
|
||||
$this->cancelledRoute = $this->getCancelledRoute($type, $cancelledRoute);
|
||||
$this->restoreRoute = $this->getRestoreRoute($type, $restoreRoute);
|
||||
|
||||
$this->hideCustomize = $hideCustomize;
|
||||
$this->permissionCustomize = $this->getPermissionCustomize($type, $permissionCustomize);
|
||||
|
|
@ -664,6 +668,24 @@ abstract class Show extends Component
|
|||
return 'invoices.cancelled';
|
||||
}
|
||||
|
||||
protected function getRestoreRoute($type, $restoreRoute)
|
||||
{
|
||||
if (! empty($restoreRoute)) {
|
||||
return $restoreRoute;
|
||||
}
|
||||
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'restore', $parameter);
|
||||
|
||||
if (! empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'invoices.restore';
|
||||
}
|
||||
|
||||
protected function getPermissionCustomize($type, $permissionCustomize)
|
||||
{
|
||||
if (! empty($permissionCustomize)) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ abstract class Form extends Component
|
|||
}
|
||||
|
||||
if (empty($valueKey)) {
|
||||
return '';
|
||||
return $value;
|
||||
}
|
||||
|
||||
// set model value.
|
||||
|
|
|
|||
|
|
@ -284,6 +284,9 @@ abstract class Show extends Component
|
|||
/** @var bool */
|
||||
public $hideChildren;
|
||||
|
||||
/** @var bool */
|
||||
public $hideConnect;
|
||||
|
||||
/** @var bool */
|
||||
public $hideTransfer;
|
||||
|
||||
|
|
@ -331,7 +334,7 @@ abstract class Show extends Component
|
|||
string $textRelatedTransansaction = '', string $textRelatedDocumentNumber = '', string $textRelatedContact = '', string $textRelatedDocumentDate = '', string $textRelatedDocumentAmount = '', string $textRelatedAmount = '',
|
||||
string $routeDocumentShow = '', string $routeTransactionShow = '', string $textButtonAddNew = '',
|
||||
|
||||
bool $hideSchedule = false, bool $hideChildren = false, bool $hideTransfer = false, bool $hideAttachment = false, $attachment = [],
|
||||
bool $hideSchedule = false, bool $hideChildren = false, bool $hideConnect = false, bool $hideTransfer = false, bool $hideAttachment = false, $attachment = [],
|
||||
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false, bool $hideCreated = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
|
|
@ -388,6 +391,9 @@ abstract class Show extends Component
|
|||
// Hide Children
|
||||
$this->hideChildren = $hideChildren;
|
||||
|
||||
// Hide Connect
|
||||
$this->hideConnect = $hideConnect;
|
||||
|
||||
// Hide Transfer
|
||||
$this->hideTransfer = $hideTransfer;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ namespace App\Abstracts;
|
|||
|
||||
use App\Models\Common\Report;
|
||||
use App\Traits\Charts;
|
||||
use App\Traits\DateTime;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Reports;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Widget
|
||||
{
|
||||
use Charts;
|
||||
use Charts, DateTime;
|
||||
|
||||
public $model;
|
||||
|
||||
|
|
@ -98,16 +98,9 @@ abstract class Widget
|
|||
return view($name, array_merge(['class' => $this], (array) $data));
|
||||
}
|
||||
|
||||
public function applyFilters($model, $args = ['date_field' => 'paid_at'])
|
||||
public function applyFilters($query, $args = ['date_field' => 'paid_at'])
|
||||
{
|
||||
if (empty(request()->get('start_date', null))) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
$start_date = request()->get('start_date') . ' 00:00:00';
|
||||
$end_date = request()->get('end_date') . ' 23:59:59';
|
||||
|
||||
return $model->whereBetween($args['date_field'], [$start_date, $end_date]);
|
||||
return $this->scopeDateFilter($query, $args['date_field']);
|
||||
}
|
||||
|
||||
public function calculateDocumentTotals($model)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,20 @@
|
|||
namespace App\BulkActions\Auth;
|
||||
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Events\Auth\LandingPageShowing;
|
||||
use App\Jobs\Auth\DeleteUser;
|
||||
use App\Jobs\Auth\UpdateUser;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Auth\Role;
|
||||
|
||||
class Users extends BulkAction
|
||||
{
|
||||
public $model = User::class;
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = user_model_class();
|
||||
}
|
||||
|
||||
public $text = 'general.users';
|
||||
|
||||
|
|
@ -19,6 +26,14 @@ class Users extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-auth-users',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -39,6 +54,48 @@ class Users extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
$roles = Role::all()->reject(function ($r) {
|
||||
$status = $r->hasPermission('read-client-portal');
|
||||
|
||||
if ($r->name == 'employee') {
|
||||
$status = true;
|
||||
}
|
||||
|
||||
return $status;
|
||||
})->pluck('display_name', 'id');
|
||||
|
||||
$u = new \stdClass();
|
||||
$u->landing_pages = [];
|
||||
|
||||
event(new LandingPageShowing($u));
|
||||
|
||||
$landing_pages = $u->landing_pages;
|
||||
|
||||
return $this->response('bulk-actions.auth.users.edit', compact('selected', 'roles', 'landing_pages'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$users = $this->getSelectedRecords($request, 'contact');
|
||||
|
||||
foreach ($users as $user) {
|
||||
try {
|
||||
$request->merge([
|
||||
'enabled' => $user->enabled,
|
||||
'uploaded_logo' => $user->logo,
|
||||
]); //
|
||||
|
||||
$this->dispatch(new UpdateUser($user, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$users = $this->getSelectedRecords($request, 'contact');
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ class Accounts extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-banking-accounts',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -39,6 +47,31 @@ class Accounts extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.banking.accounts.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$accounts = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
try {
|
||||
$request->merge([
|
||||
'enabled' => $account->enabled,
|
||||
'currency_code' => ($request->get('currency_code')) ?? $account->currency_code,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateAccount($account, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$accounts = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@ namespace App\BulkActions\Banking;
|
|||
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Exports\Banking\Transactions as Export;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Traits\Transactions as TransactionsTrait;
|
||||
|
||||
class Transactions extends BulkAction
|
||||
{
|
||||
use TransactionsTrait;
|
||||
|
||||
public $model = Transaction::class;
|
||||
|
||||
public $text = 'general.transactions';
|
||||
|
|
@ -18,6 +22,14 @@ class Transactions extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-banking-transactions',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'delete' => [
|
||||
'icon' => 'delete',
|
||||
'name' => 'general.delete',
|
||||
|
|
@ -32,6 +44,56 @@ class Transactions extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
$real_type = 'income';
|
||||
$contact_type = 'customer';
|
||||
$account_currency_code = 'USD';
|
||||
|
||||
$types = [];
|
||||
$transactions = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$r_type = $this->getRealTypeTransaction($transaction->type);
|
||||
|
||||
if (in_array($r_type, $types)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$types[] = $r_type;
|
||||
|
||||
$real_type = $r_type;
|
||||
$contact_type = $transaction->contact->type;
|
||||
$account_currency_code = $transaction->account->currency_code;
|
||||
}
|
||||
|
||||
$category_and_contact = count($types) > 1 ? false : true;
|
||||
|
||||
return $this->response('bulk-actions.banking.transactions.edit', compact('selected' , 'category_and_contact', 'real_type', 'contact_type', 'account_currency_code'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$transactions = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
try {
|
||||
$request->merge([
|
||||
'type' => $transaction->type,
|
||||
'uploaded_attachment' => $transaction->attachment,
|
||||
])->except([
|
||||
|
||||
]);
|
||||
|
||||
$this->dispatch(new UpdateTransaction($transaction, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($request)
|
||||
{
|
||||
$this->deleteTransactions($request);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,17 @@
|
|||
|
||||
namespace App\BulkActions\Common;
|
||||
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Jobs\Common\DeleteCompany;
|
||||
use App\Jobs\Common\UpdateCompany;
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\Users;
|
||||
|
||||
class Companies extends BulkAction
|
||||
{
|
||||
use Users;
|
||||
|
||||
public $model = Company::class;
|
||||
|
||||
public $text = 'general.companies';
|
||||
|
|
@ -19,6 +23,14 @@ class Companies extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-common-companies',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -33,6 +45,42 @@ class Companies extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
$money_currencies = MoneyCurrency::getCurrencies();
|
||||
|
||||
$currencies = [];
|
||||
|
||||
foreach ($money_currencies as $key => $item) {
|
||||
$currencies[$key] = $key . ' - ' . $item['name'];
|
||||
}
|
||||
|
||||
return $this->response('bulk-actions.common.companies.edit', compact('selected', 'currencies'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$companies = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($companies as $company) {
|
||||
try {
|
||||
if ($this->isNotUserCompany($company->id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$request->merge([
|
||||
'enabled' => $company->enabled,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateCompany($company, $this->getUpdateRequest($request), company_id()));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function enable($request)
|
||||
{
|
||||
$companies = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\BulkActions\Common;
|
|||
use App\Abstracts\BulkAction;
|
||||
use App\Exports\Common\Items as Export;
|
||||
use App\Jobs\Common\DeleteItem;
|
||||
use App\Jobs\Common\UpdateItem;
|
||||
use App\Models\Common\Item;
|
||||
|
||||
class Items extends BulkAction
|
||||
|
|
@ -19,6 +20,14 @@ class Items extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-common-items',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -49,6 +58,26 @@ class Items extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.common.items.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$items = $this->getSelectedRecords($request, 'taxes');
|
||||
|
||||
foreach ($items as $item) {
|
||||
try {
|
||||
$this->dispatch(new UpdateItem($item, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($request)
|
||||
{
|
||||
$items = $this->getSelectedRecords($request, 'taxes');
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use App\Exports\Purchases\Bills\Bills as Export;
|
|||
use App\Jobs\Banking\CreateBankingDocumentTransaction;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Jobs\Document\DeleteDocument;
|
||||
use App\Jobs\Document\UpdateDocument;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class Bills extends BulkAction
|
||||
|
|
@ -23,6 +24,14 @@ class Bills extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-purchases-bills',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'received' => [
|
||||
'icon' => 'send',
|
||||
'name' => 'bills.mark_received',
|
||||
|
|
@ -49,6 +58,41 @@ class Bills extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.purchases.bills.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$bills = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
try {
|
||||
$discount = $bill->totals->where('code', 'discount')->makeHidden('title')->pluck('amount')->first();
|
||||
|
||||
// for extra total rows..
|
||||
$totals = $bill->totals()->whereNotIn('code', ['sub_total', 'total', 'tax', 'discount'])->get()->toArray();
|
||||
|
||||
$request->merge([
|
||||
'items' => $bill->items->toArray(),
|
||||
'uploaded_attachment' => $bill->attachment,
|
||||
'category_id' => ($request->get('category_id')) ?? $bill->category_id,
|
||||
'discount' => $discount,
|
||||
'totals' => $totals,
|
||||
])->except([
|
||||
|
||||
]);
|
||||
|
||||
$this->dispatch(new UpdateDocument($bill, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function received($request)
|
||||
{
|
||||
$bills = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\BulkActions\Purchases;
|
|||
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Exports\Purchases\Vendors as Export;
|
||||
use App\Jobs\Common\UpdateContact;
|
||||
use App\Models\Common\Contact;
|
||||
|
||||
class Vendors extends BulkAction
|
||||
|
|
@ -18,6 +19,14 @@ class Vendors extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-purchases-vendors',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -44,6 +53,31 @@ class Vendors extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.purchases.vendors.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$vendors = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($vendors as $vendor) {
|
||||
try {
|
||||
$request->merge([
|
||||
'enabled' => $vendor->enabled,
|
||||
'uploaded_logo' => $vendor->logo,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateContact($vendor, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$this->disableContacts($request);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\BulkActions\Sales;
|
|||
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Exports\Sales\Customers as Export;
|
||||
use App\Jobs\Common\UpdateContact;
|
||||
use App\Models\Common\Contact;
|
||||
|
||||
class Customers extends BulkAction
|
||||
|
|
@ -18,6 +19,14 @@ class Customers extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-sales-customers',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -44,6 +53,31 @@ class Customers extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.sales.customers.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$customers = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
try {
|
||||
$request->merge([
|
||||
'enabled' => $customer->enabled,
|
||||
'uploaded_logo' => $customer->logo,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateContact($customer, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$this->disableContacts($request);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use App\Events\Document\DocumentCreated;
|
|||
use App\Events\Document\DocumentMarkedSent;
|
||||
use App\Events\Document\PaymentReceived;
|
||||
use App\Exports\Sales\Invoices\Invoices as Export;
|
||||
use App\Jobs\Document\UpdateDocument;
|
||||
use App\Jobs\Document\DeleteDocument;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
|
|
@ -23,6 +24,14 @@ class Invoices extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-sales-invoices',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'sent' => [
|
||||
'icon' => 'send',
|
||||
'name' => 'invoices.mark_sent',
|
||||
|
|
@ -49,6 +58,41 @@ class Invoices extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
return $this->response('bulk-actions.sales.invoices.edit', compact('selected'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$invoices = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
try {
|
||||
$discount = $invoice->totals->where('code', 'discount')->makeHidden('title')->pluck('amount')->first();
|
||||
|
||||
// for extra total rows..
|
||||
$totals = $invoice->totals()->whereNotIn('code', ['sub_total', 'total', 'tax', 'discount'])->get()->toArray();
|
||||
|
||||
$request->merge([
|
||||
'items' => $invoice->items->toArray(),
|
||||
'uploaded_attachment' => $invoice->attachment,
|
||||
'category_id' => ($request->get('category_id')) ?? $invoice->category_id,
|
||||
'discount' => $discount,
|
||||
'totals' => $totals,
|
||||
])->except([
|
||||
|
||||
]);
|
||||
|
||||
$this->dispatch(new UpdateDocument($invoice, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function sent($request)
|
||||
{
|
||||
$invoices = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ use App\Abstracts\BulkAction;
|
|||
use App\Jobs\Setting\DeleteCategory;
|
||||
use App\Jobs\Setting\UpdateCategory;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Traits\Categories as Helper;
|
||||
|
||||
class Categories extends BulkAction
|
||||
{
|
||||
use Helper;
|
||||
|
||||
public $model = Category::class;
|
||||
|
||||
public $text = 'general.categories';
|
||||
|
|
@ -19,6 +22,14 @@ class Categories extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-settings-categories',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -39,17 +50,29 @@ class Categories extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function getSelectedRecords($request, $relationships = null)
|
||||
public function edit($request)
|
||||
{
|
||||
if (empty($relationships)) {
|
||||
$model = $this->model::query();
|
||||
} else {
|
||||
$relationships = Arr::wrap($relationships);
|
||||
$selected = $this->getSelectedInput($request);
|
||||
$types = $this->getCategoryTypes();
|
||||
|
||||
$model = $this->model::with($relationships);
|
||||
return $this->response('bulk-actions.settings.categories.edit', compact('selected', 'types'));
|
||||
}
|
||||
|
||||
return $model->getWithoutChildren()->find($this->getSelectedInput($request));
|
||||
public function update($request)
|
||||
{
|
||||
$categories = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
try {
|
||||
$request->merge([
|
||||
'enabled' => $category->enabled,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateCategory($category, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
|
|
@ -77,4 +100,17 @@ class Categories extends BulkAction
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSelectedRecords($request, $relationships = null)
|
||||
{
|
||||
if (empty($relationships)) {
|
||||
$model = $this->model::query();
|
||||
} else {
|
||||
$relationships = Arr::wrap($relationships);
|
||||
|
||||
$model = $this->model::with($relationships);
|
||||
}
|
||||
|
||||
return $model->getWithoutChildren()->find($this->getSelectedInput($request));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ class Currencies extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-settings-currencies',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -39,6 +47,39 @@ class Currencies extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
$precisions = (object) [
|
||||
'0' => '0',
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
];
|
||||
|
||||
return $this->response('bulk-actions.settings.currencies.edit', compact('selected', 'precisions'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$currencies = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
try {
|
||||
$request->merge([
|
||||
'code' => $currency->code,
|
||||
'enabled' => $currency->enabled,
|
||||
]); // for update job authorize..
|
||||
|
||||
$this->dispatch(new UpdateCurrency($currency, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$currencies = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ class Taxes extends BulkAction
|
|||
];
|
||||
|
||||
public $actions = [
|
||||
'edit' => [
|
||||
'icon' => 'edit',
|
||||
'name' => 'general.edit',
|
||||
'message' => '',
|
||||
'permission' => 'update-settings-taxes',
|
||||
'type' => 'modal',
|
||||
'handle' => 'update',
|
||||
],
|
||||
'enable' => [
|
||||
'icon' => 'check_circle',
|
||||
'name' => 'general.enable',
|
||||
|
|
@ -39,6 +47,40 @@ class Taxes extends BulkAction
|
|||
],
|
||||
];
|
||||
|
||||
public function edit($request)
|
||||
{
|
||||
$selected = $this->getSelectedInput($request);
|
||||
|
||||
$types = [
|
||||
'fixed' => trans('taxes.fixed'),
|
||||
'normal' => trans('taxes.normal'),
|
||||
'inclusive' => trans('taxes.inclusive'),
|
||||
'withholding' => trans('taxes.withholding'),
|
||||
'compound' => trans('taxes.compound'),
|
||||
];
|
||||
|
||||
$disable_options = [];
|
||||
|
||||
if ($compound = Tax::compound()->first()) {
|
||||
$disable_options = ['compound'];
|
||||
}
|
||||
|
||||
return $this->response('bulk-actions.settings.taxes.edit', compact('selected', 'types', 'disable_options'));
|
||||
}
|
||||
|
||||
public function update($request)
|
||||
{
|
||||
$taxes = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($taxes as $tax) {
|
||||
try {
|
||||
$this->dispatch(new UpdateTax($tax, $this->getUpdateRequest($request)));
|
||||
} catch (\Exception $e) {
|
||||
flash($e->getMessage())->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
{
|
||||
$taxes = $this->getSelectedRecords($request);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Company;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ class InstallRefresh extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = User::first();
|
||||
$user = user_model_class()::first();
|
||||
$company = Company::first();
|
||||
|
||||
$this->info('Resetting migrations');
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class Kernel extends ConsoleKernel
|
|||
$schedule->command('reminder:bill')->dailyAt($schedule_time);
|
||||
$schedule->command('recurring:check')->dailyAt($schedule_time)->runInBackground();
|
||||
$schedule->command('storage-temp:clear')->dailyAt('17:00');
|
||||
$schedule->command('model:prune')->dailyAt('17:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TransactionSending extends Event
|
||||
{
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct($transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Document;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DocumentRestored
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $document;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
*/
|
||||
public function __construct($document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Events\Email;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Contact;
|
||||
|
||||
class InvalidEmailDetected extends Event
|
||||
|
|
@ -40,7 +39,7 @@ class InvalidEmailDetected extends Event
|
|||
|
||||
public function setUser()
|
||||
{
|
||||
$user = User::email($this->email)->enabled()->first();
|
||||
$user = user_model_class()::email($this->email)->enabled()->first();
|
||||
|
||||
if (empty($user)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Report;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TotalCalculated extends Event
|
||||
{
|
||||
public $class;
|
||||
|
||||
public $model;
|
||||
|
||||
public $date_field;
|
||||
|
||||
public $check_type;
|
||||
|
||||
public $table;
|
||||
|
||||
public $with_tax;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $class
|
||||
* @param $model
|
||||
* @param $date_field
|
||||
* @param $check_type
|
||||
* @param $table
|
||||
* @param $with_tax
|
||||
*/
|
||||
public function __construct($class, $model, $date_field, $check_type, $table, $with_tax)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->model = $model;
|
||||
$this->date_field = $date_field;
|
||||
$this->check_type = $check_type;
|
||||
$this->table = $table;
|
||||
$this->with_tax = $with_tax;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Report;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TotalCalculating extends Event
|
||||
{
|
||||
public $class;
|
||||
|
||||
public $model;
|
||||
|
||||
public $date_field;
|
||||
|
||||
public $check_type;
|
||||
|
||||
public $table;
|
||||
|
||||
public $with_tax;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $class
|
||||
* @param $model
|
||||
* @param $date_field
|
||||
* @param $check_type
|
||||
* @param $table
|
||||
* @param $with_tax
|
||||
*/
|
||||
public function __construct($class, $model, $date_field, $check_type, $table, $with_tax)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->model = $model;
|
||||
$this->date_field = $date_field;
|
||||
$this->check_type = $check_type;
|
||||
$this->table = $table;
|
||||
$this->with_tax = $with_tax;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ use App\Http\Resources\Auth\User as Resource;
|
|||
use App\Jobs\Auth\CreateUser;
|
||||
use App\Jobs\Auth\DeleteUser;
|
||||
use App\Jobs\Auth\UpdateUser;
|
||||
use App\Models\Auth\User;
|
||||
|
||||
class Users extends ApiController
|
||||
{
|
||||
|
|
@ -19,7 +18,7 @@ class Users extends ApiController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::with('companies', 'permissions', 'roles')->collect();
|
||||
$users = user_model_class()::with('companies', 'permissions', 'roles')->collect();
|
||||
|
||||
return Resource::collection($users);
|
||||
}
|
||||
|
|
@ -35,13 +34,13 @@ class Users extends ApiController
|
|||
{
|
||||
// Check if we're querying by id or email
|
||||
if (is_numeric($id)) {
|
||||
$user = User::with('companies', 'permissions', 'roles')->find($id);
|
||||
$user = user_model_class()::with('companies', 'permissions', 'roles')->find($id);
|
||||
} else {
|
||||
$user = User::with('companies', 'permissions', 'roles')->where('email', $id)->first();
|
||||
$user = user_model_class()::with('companies', 'permissions', 'roles')->where('email', $id)->first();
|
||||
}
|
||||
|
||||
if (! $user instanceof User) {
|
||||
return $this->errorInternal('No query results for model [' . User::class . '] ' . $id);
|
||||
if (! $user instanceof user_model_class()) {
|
||||
return $this->errorInternal('No query results for model [' . user_model_class() . '] ' . $id);
|
||||
}
|
||||
|
||||
return new Resource($user);
|
||||
|
|
@ -64,12 +63,14 @@ class Users extends ApiController
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param $user
|
||||
* @param $user_id
|
||||
* @param $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(User $user, Request $request)
|
||||
public function update($user_id, Request $request)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$user = $this->dispatch(new UpdateUser($user, $request));
|
||||
|
||||
return new Resource($user->fresh());
|
||||
|
|
@ -78,12 +79,14 @@ class Users extends ApiController
|
|||
/**
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(User $user)
|
||||
public function enable($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$user = $this->dispatch(new UpdateUser($user, request()->merge(['enabled' => 1])));
|
||||
|
||||
return new Resource($user->fresh());
|
||||
|
|
@ -92,12 +95,14 @@ class Users extends ApiController
|
|||
/**
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(User $user)
|
||||
public function disable($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$user = $this->dispatch(new UpdateUser($user, request()->merge(['enabled' => 0])));
|
||||
|
||||
return new Resource($user->fresh());
|
||||
|
|
@ -106,14 +111,16 @@ class Users extends ApiController
|
|||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(User $user)
|
||||
public function destroy($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
try {
|
||||
$this->dispatch(new DeleteUser($user));
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use App\Jobs\Auth\CreateUser;
|
|||
use App\Jobs\Auth\DeleteUser;
|
||||
use App\Jobs\Auth\UpdateUser;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\User;
|
||||
use App\Traits\Cloud;
|
||||
use App\Traits\Uploads;
|
||||
use Illuminate\Http\Request as BaseRequest;
|
||||
|
|
@ -37,7 +36,7 @@ class Users extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::with('media', 'roles')->collect();
|
||||
$users = user_model_class()::with('media', 'roles')->collect();
|
||||
|
||||
return $this->response('auth.users.index', compact('users'));
|
||||
}
|
||||
|
|
@ -47,8 +46,10 @@ class Users extends Controller
|
|||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(User $user)
|
||||
public function show($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$u = new \stdClass();
|
||||
$u->role = $user->roles()->first();
|
||||
$u->landing_pages = [];
|
||||
|
|
@ -124,12 +125,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(User $user)
|
||||
public function edit($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
if (user()->cannot('read-auth-users') && ($user->id != user()->id)) {
|
||||
abort(403);
|
||||
}
|
||||
|
|
@ -187,13 +190,15 @@ class Users extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(User $user, Request $request)
|
||||
public function update($user_id, Request $request)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
if (user()->cannot('update-auth-users') && ($user->id != user()->id)) {
|
||||
abort(403);
|
||||
}
|
||||
|
|
@ -220,12 +225,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Enable the specified resource.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function enable(User $user)
|
||||
public function enable($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$response = $this->ajaxDispatch(new UpdateUser($user, request()->merge(['enabled' => 1])));
|
||||
|
||||
if ($response['success']) {
|
||||
|
|
@ -238,12 +245,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Disable the specified resource.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function disable(User $user)
|
||||
public function disable($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$response = $this->ajaxDispatch(new UpdateUser($user, request()->merge(['enabled' => 0])));
|
||||
|
||||
if ($response['success']) {
|
||||
|
|
@ -256,12 +265,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(User $user)
|
||||
public function destroy($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$response = $this->ajaxDispatch(new DeleteUser($user));
|
||||
|
||||
$response['redirect'] = route('users.index');
|
||||
|
|
@ -282,12 +293,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Mark upcoming bills notifications are read and redirect to bills page.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function readUpcomingBills(User $user)
|
||||
public function readUpcomingBills($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
// Mark bill notifications as read
|
||||
foreach ($user->unreadNotifications as $notification) {
|
||||
// Not a bill notification
|
||||
|
|
@ -304,12 +317,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Mark overdue invoices notifications are read and redirect to invoices page.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function readOverdueInvoices(User $user)
|
||||
public function readOverdueInvoices($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
// Mark invoice notifications as read
|
||||
foreach ($user->unreadNotifications as $notification) {
|
||||
// Not an invoice notification
|
||||
|
|
@ -334,13 +349,13 @@ class Users extends Controller
|
|||
if (! empty($column) && ! empty($value)) {
|
||||
switch ($column) {
|
||||
case 'id':
|
||||
$user = User::find((int) $value);
|
||||
$user = user_model_class()::find((int) $value);
|
||||
break;
|
||||
case 'email':
|
||||
$user = User::where('email', $value)->first();
|
||||
$user = user_model_class()::where('email', $value)->first();
|
||||
break;
|
||||
default:
|
||||
$user = User::where($column, $value)->first();
|
||||
$user = user_model_class()::where($column, $value)->first();
|
||||
}
|
||||
|
||||
$data = $user;
|
||||
|
|
@ -358,12 +373,14 @@ class Users extends Controller
|
|||
/**
|
||||
* Process request for reinviting the specified resource.
|
||||
*
|
||||
* @param User $user
|
||||
* @param $user_id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function invite(User $user)
|
||||
public function invite($user_id)
|
||||
{
|
||||
$user = user_model_class()::find($user_id);
|
||||
|
||||
$response = $this->ajaxDispatch(new CreateInvitation($user, company()));
|
||||
|
||||
if ($response['success']) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class Accounts extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('accounts.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.accounts', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.accounts', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class Reconciliations extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('reconciliations.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.reconciliations', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.reconciliations', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class RecurringTransactions extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('recurring-transactions.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.recurring_transactions', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.recurring_transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use App\Notifications\Banking\Transaction as Notification;
|
|||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions as TransactionsTrait;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class Transactions extends Controller
|
||||
{
|
||||
|
|
@ -85,6 +86,8 @@ class Transactions extends Controller
|
|||
*/
|
||||
public function show(Transaction $transaction)
|
||||
{
|
||||
$transaction->load('taxes');
|
||||
|
||||
$title = $transaction->isIncome() ? trans_choice('general.receipts', 1) : trans('transactions.payment_made');
|
||||
$real_type = $this->getRealTypeTransaction($transaction->type);
|
||||
|
||||
|
|
@ -109,13 +112,16 @@ class Transactions extends Controller
|
|||
|
||||
$currency = Currency::where('code', $account_currency_code)->first();
|
||||
|
||||
$taxes = Tax::enabled()->orderBy('name')->get();
|
||||
|
||||
return view('banking.transactions.create', compact(
|
||||
'type',
|
||||
'real_type',
|
||||
'number',
|
||||
'contact_type',
|
||||
'account_currency_code',
|
||||
'currency'
|
||||
'currency',
|
||||
'taxes'
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +139,7 @@ class Transactions extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('transactions.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.transactions', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
@ -203,6 +209,8 @@ class Transactions extends Controller
|
|||
|
||||
$currency = Currency::where('code', $transaction->currency_code)->first();
|
||||
|
||||
$taxes = Tax::enabled()->orderBy('name')->get();
|
||||
|
||||
$date_format = $this->getCompanyDateFormat();
|
||||
|
||||
return view('banking.transactions.edit', compact(
|
||||
|
|
@ -210,6 +218,7 @@ class Transactions extends Controller
|
|||
'contact_type',
|
||||
'transaction',
|
||||
'currency',
|
||||
'taxes',
|
||||
'date_format'
|
||||
));
|
||||
}
|
||||
|
|
@ -254,7 +263,7 @@ class Transactions extends Controller
|
|||
{
|
||||
$response = $this->ajaxDispatch(new DeleteTransaction($transaction));
|
||||
|
||||
$response['redirect'] = url()->previous();
|
||||
$response['redirect'] = route('transactions.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.deleted', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class Transfers extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('transfers.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.transfers', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.transfers', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ namespace App\Http\Controllers\Common;
|
|||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Common\BulkAction as Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BulkActions extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
|
@ -47,7 +47,10 @@ class BulkActions extends Controller
|
|||
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
||||
}
|
||||
|
||||
if (isset($bulk_actions->actions[$handle]['permission']) && !user()->can($bulk_actions->actions[$handle]['permission'])) {
|
||||
if (
|
||||
isset($bulk_actions->actions[$handle]['permission'])
|
||||
&& ! user()->can($bulk_actions->actions[$handle]['permission'])
|
||||
) {
|
||||
flash(trans('errors.message.403'))->error()->important();
|
||||
|
||||
return response()->json([
|
||||
|
|
@ -78,25 +81,45 @@ class BulkActions extends Controller
|
|||
|
||||
$level = $not_passed > 0 ? 'info' : 'success';
|
||||
|
||||
if (
|
||||
(
|
||||
isset($bulk_actions->actions[$handle]['type'])
|
||||
&& $bulk_actions->actions[$handle]['type'] != 'modal'
|
||||
)
|
||||
|| ! isset($bulk_actions->actions[$handle]['type'])
|
||||
|| $not_passed > 0
|
||||
) {
|
||||
flash($message)->{$level}();
|
||||
}
|
||||
|
||||
if (! empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
|
||||
if (
|
||||
! empty($result)
|
||||
&& ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)
|
||||
) {
|
||||
return $result;
|
||||
} elseif (! empty($result) && ($result instanceof RedirectResponse)) {
|
||||
} else if (
|
||||
! empty($result)
|
||||
&& ($result instanceof RedirectResponse)
|
||||
) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'redirect' => $result->getTargetUrl(),
|
||||
'error' => false,
|
||||
'data' => [],
|
||||
'message' => ''
|
||||
'message' => $message,
|
||||
]);
|
||||
} else if (
|
||||
! empty($result)
|
||||
&& ($result instanceof JsonResponse)
|
||||
) {
|
||||
return $result;
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'redirect' => true,
|
||||
'error' => false,
|
||||
'data' => [],
|
||||
'message' => ''
|
||||
'message' => $message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Common\Company as Request;
|
||||
use App\Jobs\Common\CreateCompany;
|
||||
|
|
@ -10,7 +11,6 @@ use App\Jobs\Common\UpdateCompany;
|
|||
use App\Models\Common\Company;
|
||||
use App\Traits\Uploads;
|
||||
use App\Traits\Users;
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
|
||||
class Companies extends Controller
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ class Companies extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('companies.switch', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.companies', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.companies', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ class Dashboards extends Controller
|
|||
$date_picker_shortcuts = $this->getDatePickerShortcuts();
|
||||
|
||||
if (! request()->has('start_date')) {
|
||||
request()->merge(['start_date' => $date_picker_shortcuts[trans('reports.this_year')]['start']]);
|
||||
request()->merge(['end_date' => $date_picker_shortcuts[trans('reports.this_year')]['end']]);
|
||||
request()->merge(['start_date' => $date_picker_shortcuts[trans('general.date_range.this_year')]['start']]);
|
||||
request()->merge(['end_date' => $date_picker_shortcuts[trans('general.date_range.this_year')]['end']]);
|
||||
}
|
||||
|
||||
return view('common.dashboards.show', compact('dashboard', 'widgets', 'user_dashboards', 'date_picker_shortcuts'));
|
||||
|
|
@ -112,7 +112,7 @@ class Dashboards extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('dashboards.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.dashboards', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.dashboards', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class Items extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('items.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.items', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.items', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Traits\Plans as PlansTrait;
|
||||
|
||||
class Plans extends Controller
|
||||
{
|
||||
use PlansTrait;
|
||||
|
||||
/**
|
||||
* Check for plan changes.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$this->clearPlansCache();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ class Reports extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('reports.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.reports', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.reports', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
@ -221,6 +221,21 @@ class Reports extends Controller
|
|||
return Utility::getClassInstance($report)->print();
|
||||
}
|
||||
|
||||
/**
|
||||
* Download PDF file of the report.
|
||||
*
|
||||
* @param Report $report
|
||||
* @return Response
|
||||
*/
|
||||
public function pdf(Report $report)
|
||||
{
|
||||
if (Utility::cannotShow($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return Utility::getClassInstance($report)->pdf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the report.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Accounts extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateAccount($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.accounts', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.accounts', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class Categories extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateCategory($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.categories', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.categories', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ class Currencies extends Controller
|
|||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$currency = config('money.currencies.' . $request->get('code'));
|
||||
$currency = currency($request->get('code'));
|
||||
|
||||
$request['precision'] = (int) $currency['precision'];
|
||||
$request['symbol'] = $currency['symbol'];
|
||||
$request['symbol_first'] = $currency['symbol_first'] ? 1 : 0;
|
||||
$request['decimal_mark'] = $currency['decimal_mark'];
|
||||
$request['thousands_separator'] = $currency['thousands_separator'];
|
||||
$request['precision'] = (int) $currency->getPrecision();
|
||||
$request['symbol'] = $currency->getSymbol();
|
||||
$request['symbol_first'] = $currency->isSymbolFirst() ? 1 : 0;
|
||||
$request['decimal_mark'] = $currency->getDecimalMark();
|
||||
$request['thousands_separator'] = $currency->getThousandsSeparator();
|
||||
|
||||
$request['enabled'] = 1;
|
||||
$request['default_currency'] = false;
|
||||
|
|
@ -78,7 +78,7 @@ class Currencies extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateCurrency($request->all()));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.currencies', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -57,10 +57,9 @@ class Customers extends Controller
|
|||
$request['enabled'] = 1;
|
||||
|
||||
$response = $this->ajaxDispatch(new CreateContact($request));
|
||||
$this->ajaxDispatch(new UpdateContact($customer, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.customers', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.customers', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Abstracts\Http\Controller;
|
|||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use App\Jobs\Banking\CreateBankingDocumentTransaction;
|
||||
use App\Jobs\Banking\UpdateBankingDocumentTransaction;
|
||||
use App\Jobs\Banking\DeleteTransaction;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Currency;
|
||||
|
|
@ -13,7 +14,7 @@ use App\Utilities\Modules;
|
|||
use App\Traits\Uploads;
|
||||
use App\Traits\Transactions;
|
||||
use Date;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DocumentTransactions extends Controller
|
||||
{
|
||||
|
|
@ -69,6 +70,8 @@ class DocumentTransactions extends Controller
|
|||
'payment' => [
|
||||
'text' => trans('invoices.accept_payments'),
|
||||
'class' => 'long-texts',
|
||||
'before_text' => trans('general.get_paid_faster'),
|
||||
'class' => 'px-6 py-1.5 text-xs bg-gray-200 hover:bg-purple-200 font-medium rounded-lg leading-6 long-texts',
|
||||
'url' => route('apps.categories.show', [
|
||||
'alias' => 'payment-method',
|
||||
'utm_source' => $document->type . '_payment',
|
||||
|
|
@ -76,6 +79,10 @@ class DocumentTransactions extends Controller
|
|||
'utm_campaign' => 'payment_method',
|
||||
])
|
||||
],
|
||||
'send' => [
|
||||
'text' => trans('general.save_and_send'),
|
||||
'class' => 'disabled:bg-green-100'
|
||||
],
|
||||
'confirm' => [
|
||||
'text' => trans('general.save'),
|
||||
'class' => 'disabled:bg-green-100'
|
||||
|
|
@ -113,7 +120,7 @@ class DocumentTransactions extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateBankingDocumentTransaction($document, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = url()->previous();
|
||||
$response['redirect'] = $this->getRedirectUrl($document, $request);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
|
|
@ -151,8 +158,14 @@ class DocumentTransactions extends Controller
|
|||
],
|
||||
'payment' => [
|
||||
'text' => trans('invoices.accept_payments'),
|
||||
'class' => 'long-texts',
|
||||
'url' => route('apps.categories.show', 'payment-method')
|
||||
'before_text' => trans('general.get_paid_faster'),
|
||||
'class' => 'px-6 py-1.5 text-xs bg-gray-200 hover:bg-purple-200 font-medium rounded-lg leading-6 long-texts',
|
||||
'url' => route('apps.categories.show', [
|
||||
'alias' => 'payment-method',
|
||||
'utm_source' => $document->type . '_payment',
|
||||
'utm_medium' => 'app',
|
||||
'utm_campaign' => 'payment_method',
|
||||
])
|
||||
],
|
||||
'confirm' => [
|
||||
'text' => trans('general.save'),
|
||||
|
|
@ -196,7 +209,9 @@ class DocumentTransactions extends Controller
|
|||
$route = $alias . '.' . $route;
|
||||
}
|
||||
|
||||
$response['redirect'] = route($route . '.show', $document->id);
|
||||
$redirect = route($route . '.show', $document->id);
|
||||
|
||||
$response['redirect'] = $this->getRedirectUrl($document, $request, $redirect);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
|
|
@ -207,4 +222,58 @@ class DocumentTransactions extends Controller
|
|||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(Document $document, Transaction $transaction)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new DeleteTransaction($transaction));
|
||||
|
||||
$route = config('type.document.' . $document->type . '.route.prefix');
|
||||
|
||||
if ($alias = config('type.document.' . $document->type . '.alias')) {
|
||||
$route = $alias . '.' . $route;
|
||||
}
|
||||
|
||||
$response['redirect'] = route($route . '.show', $document->id);
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.deleted', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
protected function getRedirectUrl($document, $request, $url = null)
|
||||
{
|
||||
$redirect = $url ?? url()->previous();
|
||||
|
||||
if ($request->has('sendtransaction')) {
|
||||
$paramaters = [
|
||||
$document->type => $document->id,
|
||||
'sendtransaction' => true,
|
||||
];
|
||||
|
||||
$quin = '?';
|
||||
|
||||
if (Str::contains($redirect, '?')) {
|
||||
$quin = '&';
|
||||
}
|
||||
|
||||
$redirect .= $quin . http_build_query($paramaters);
|
||||
}
|
||||
|
||||
return $redirect;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,13 @@ class InvoiceEmails extends Controller
|
|||
|
||||
public function create(Document $invoice): JsonResponse
|
||||
{
|
||||
$contacts = $invoice->contact->withPersons();
|
||||
|
||||
$notification = new Notification($invoice, 'invoice_new_customer', true);
|
||||
|
||||
$store_route = 'modals.invoices.emails.store';
|
||||
|
||||
$html = view('modals.invoices.email', compact('invoice', 'notification', 'store_route'))->render();
|
||||
$html = view('modals.invoices.email', compact('invoice', 'contacts', 'notification', 'store_route'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class Items extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateItem($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.items', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.items', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Taxes extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateTax($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.taxes', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class TransactionEmails extends Controller
|
|||
|
||||
public function create(Transaction $transaction): JsonResponse
|
||||
{
|
||||
$contacts = $transaction->contact->withPersons();
|
||||
|
||||
$email_template = config('type.transaction.' . $transaction->type . '.email_template');
|
||||
|
||||
if (request()->get('email_template')) {
|
||||
|
|
@ -47,7 +49,7 @@ class TransactionEmails extends Controller
|
|||
|
||||
$store_route = 'modals.transactions.emails.store';
|
||||
|
||||
$html = view('modals.transactions.email', compact('transaction', 'notification', 'store_route'))->render();
|
||||
$html = view('modals.transactions.email', compact('transaction', 'contacts', 'notification', 'store_route'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class Vendors extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateContact($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.vendors', 1)]);
|
||||
$response['message'] = trans('messages.success.created', ['type' => trans_choice('general.vendors', 1)]);
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ namespace App\Http\Controllers\Modules;
|
|||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Module\Module as Request;
|
||||
use App\Traits\Plans;
|
||||
|
||||
class ApiKey extends Controller
|
||||
{
|
||||
use Plans;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
|
@ -32,6 +34,8 @@ class ApiKey extends Controller
|
|||
|
||||
setting()->save();
|
||||
|
||||
$this->clearPlansCache();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace App\Http\Controllers\Portal;
|
|||
use App\Models\Document\Document;
|
||||
use App\Traits\Charts;
|
||||
use App\Traits\DateTime;
|
||||
use Date;
|
||||
use App\Utilities\Date;
|
||||
|
||||
class Dashboard
|
||||
{
|
||||
|
|
@ -25,15 +25,10 @@ class Dashboard
|
|||
return redirect(user()->getLandingPageOfUser());
|
||||
}
|
||||
|
||||
$financial_start = $this->getFinancialStart()->format('Y-m-d');
|
||||
$financial_year = $this->getFinancialYear();
|
||||
|
||||
// check and assign year start
|
||||
if (($year_start = Date::today()->startOfYear()->format('Y-m-d')) !== $financial_start) {
|
||||
$year_start = $financial_start;
|
||||
}
|
||||
|
||||
$start = Date::parse(request('start_date', $year_start));
|
||||
$end = Date::parse(request('end_date', Date::parse($year_start)->addYear(1)->subDays(1)->format('Y-m-d')));
|
||||
$start = Date::parse(request('start_date', $financial_year->copy()->getStartDate()->toDateString()));
|
||||
$end = Date::parse(request('end_date', $financial_year->copy()->getEndDate()->toDateString()));
|
||||
|
||||
//$invoices = Document::invoice()->accrued()->where('contact_id', $contact->id)->get();
|
||||
$invoices = Document::invoice()->accrued()->whereBetween('due_at', [$start, $end])->where('contact_id', $contact->id)->get();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers\Portal;
|
|||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Portal\Profile as Request;
|
||||
use App\Models\Auth\User;
|
||||
use App\Traits\Uploads;
|
||||
|
||||
class Profile extends Controller
|
||||
|
|
@ -41,7 +40,7 @@ class Profile extends Controller
|
|||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(User $user, Request $request)
|
||||
public function update($user_id, Request $request)
|
||||
{
|
||||
$user = user();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@ class Bills extends Controller
|
|||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type = Document::BILL_TYPE;
|
||||
public string $type = Document::BILL_TYPE;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
|
@ -30,6 +27,8 @@ class Bills extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->setActiveTabForDocuments();
|
||||
|
||||
$bills = Document::bill()->with('contact', 'items', 'item_taxes', 'last_history', 'transactions', 'totals', 'histories', 'media')->collect(['issued_at' => 'desc']);
|
||||
|
||||
return $this->response('purchases.bills.index', compact('bills'));
|
||||
|
|
@ -71,7 +70,7 @@ class Bills extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('bills.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.bills', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.bills', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
@ -240,6 +239,24 @@ class Bills extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the bill.
|
||||
*
|
||||
* @param Document $bill
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function restoreBill(Document $bill)
|
||||
{
|
||||
event(new \App\Events\Document\DocumentRestored($bill));
|
||||
|
||||
$message = trans('documents.messages.restored', ['type' => trans_choice('general.bills', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the bill.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class RecurringBills extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('recurring-bills.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.recurring_bills', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.recurring_bills', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Vendors extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('vendors.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.vendors', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.vendors', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Customers extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('customers.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.customers', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.customers', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@ class Invoices extends Controller
|
|||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type = Document::INVOICE_TYPE;
|
||||
public string $type = Document::INVOICE_TYPE;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
|
@ -31,6 +28,8 @@ class Invoices extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->setActiveTabForDocuments();
|
||||
|
||||
$invoices = Document::invoice()->with('contact', 'items', 'item_taxes', 'last_history', 'transactions', 'totals', 'histories', 'media')->collect(['document_number'=> 'desc']);
|
||||
|
||||
return $this->response('sales.invoices.index', compact('invoices'));
|
||||
|
|
@ -78,7 +77,7 @@ class Invoices extends Controller
|
|||
|
||||
$response['redirect'] = route('invoices.show', $paramaters);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.invoices', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
@ -159,7 +158,13 @@ class Invoices extends Controller
|
|||
$response = $this->ajaxDispatch(new UpdateDocument($invoice, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('invoices.show', $response['data']->id);
|
||||
$paramaters = ['invoice' => $response['data']->id];
|
||||
|
||||
if ($request->has('senddocument')) {
|
||||
$paramaters['senddocument'] = true;
|
||||
}
|
||||
|
||||
$response['redirect'] = route('invoices.show', $paramaters);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
|
|
@ -247,6 +252,24 @@ class Invoices extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the invoice.
|
||||
*
|
||||
* @param Document $invoice
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function restoreInvoice(Document $invoice)
|
||||
{
|
||||
event(new \App\Events\Document\DocumentRestored($invoice));
|
||||
|
||||
$message = trans('documents.messages.restored', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of invoice.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class RecurringInvoices extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('recurring-invoices.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.recurring_invoices', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.recurring_invoices', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Categories extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('categories.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.categories', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.categories', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class Currencies extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('currencies.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.currencies', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
@ -235,12 +235,12 @@ class Currencies extends Controller
|
|||
if ($code) {
|
||||
$currencies = Currency::all()->pluck('rate', 'code');
|
||||
|
||||
$currency = config('money.currencies.' . $code);
|
||||
$currency = (object) currency($code)->toArray()[$code];
|
||||
|
||||
$currency['rate'] = isset($currencies[$code]) ? $currencies[$code] : null;
|
||||
$currency['symbol_first'] = ! empty($currency['symbol_first']) ? 1 : 0;
|
||||
$currency->rate = isset($currencies[$code]) ? $currencies[$code] : null;
|
||||
$currency->symbol_first = ! empty($currency->symbol_first) ? 1 : 0;
|
||||
|
||||
$json = (object) $currency;
|
||||
$json = $currency;
|
||||
}
|
||||
|
||||
return response()->json($json);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class Taxes extends Controller
|
|||
if ($response['success']) {
|
||||
$response['redirect'] = route('taxes.index');
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.taxes', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class Currencies extends Controller
|
|||
$response = $this->ajaxDispatch(new CreateCurrency($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);
|
||||
$message = trans('messages.success.created', ['type' => trans_choice('general.currencies', 1)]);
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class Kernel extends HttpKernel
|
|||
'wizard.redirect',
|
||||
'menu.admin',
|
||||
'permission:read-admin-panel',
|
||||
'plan.limits',
|
||||
],
|
||||
|
||||
'wizard' => [
|
||||
|
|
@ -173,6 +174,7 @@ class Kernel extends HttpKernel
|
|||
'company.identify' => \App\Http\Middleware\IdentifyCompany::class,
|
||||
'dropzone' => \App\Http\Middleware\Dropzone::class,
|
||||
'header.x' => \App\Http\Middleware\AddXHeader::class,
|
||||
'plan.limits' => \App\Http\Middleware\RedirectIfHitPlanLimits::class,
|
||||
'menu.admin' => \App\Http\Middleware\AdminMenu::class,
|
||||
'menu.portal' => \App\Http\Middleware\PortalMenu::class,
|
||||
'date.format' => \App\Http\Middleware\DateFormat::class,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class AddXHeader
|
|||
|
||||
// Check if we should add header
|
||||
if (method_exists($response, 'header')) {
|
||||
$response->header('X-Akaunting', 'Free Accounting Software');
|
||||
$response->header('X-Akaunting', 'Online Accounting Software');
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class Money
|
|||
|
||||
$amount = $item['price'];
|
||||
|
||||
if (strpos($item['price'], config('money.currencies.' . $currency_code . '.symbol')) !== false) {
|
||||
if (strpos($item['price'], currency($currency_code)->getSymbol()) !== false) {
|
||||
$amount = $this->getAmount($item['price'], $currency_code);
|
||||
}
|
||||
|
||||
|
|
@ -101,8 +101,8 @@ class Money
|
|||
protected function getAmount($money_format, $currency_code)
|
||||
{
|
||||
try {
|
||||
if (config('money.currencies.' . $currency_code . '.decimal_mark') !== '.') {
|
||||
$money_format = Str::replaceFirst('.', config('money.currencies.' . $currency_code . '.decimal_mark'), $money_format);
|
||||
if (currency($currency_code)->getDecimalMark() !== '.') {
|
||||
$money_format = Str::replaceFirst('.', currency($currency_code)->getDecimalMark(), $money_format);
|
||||
}
|
||||
|
||||
$amount = money($money_format, $currency_code, false)->getAmount();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Traits\Plans;
|
||||
use Closure;
|
||||
|
||||
class RedirectIfHitPlanLimits
|
||||
{
|
||||
use Plans;
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$segments = $request->segments();
|
||||
$last_segment = end($segments);
|
||||
|
||||
if (! $request->isMethod(strtolower('GET')) || ! in_array($last_segment, ['create'])) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if ($request->ajax()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if ($request->is(company_id() . '/apps/*')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (! $this->getUserLimitOfPlan()->action_status) {
|
||||
return redirect()->route('users.index');
|
||||
}
|
||||
|
||||
if (! $this->getCompanyLimitOfPlan()->action_status) {
|
||||
return redirect()->route('companies.index');
|
||||
}
|
||||
|
||||
if (! $this->getInvoiceLimitOfPlan()->action_status) {
|
||||
return redirect()->route('invoices.index');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ class RedirectIfNoApiKey
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request"
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,7 +36,15 @@ class User extends FormRequest
|
|||
|
||||
if ($this->getMethod() == 'PATCH') {
|
||||
// Updating user
|
||||
$id = is_numeric($this->user) ? $this->user : $this->user->getAttribute('id');
|
||||
if (is_numeric($this->user)) {
|
||||
$id = $this->user;
|
||||
$user = user_model_class()::find($id);
|
||||
|
||||
$this->user = $user;
|
||||
} else {
|
||||
$id = $this->user->getAttribute('id');
|
||||
}
|
||||
|
||||
$companies = $this->user->can('read-common-companies') ? 'required' : '';
|
||||
$roles = $this->user->can('read-auth-roles') ? 'required|string' : '';
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class ContactPerson extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'type' => 'required|string',
|
||||
'contact_id' => 'required|integer',
|
||||
'name' => 'nullable|string',
|
||||
'email' => 'nullable|email:rfc,dns',
|
||||
'phone' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ class CustomMail extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'to' => 'required|email',
|
||||
'to' => 'required|array|max:' . config('app.throttles.email.minute'),
|
||||
'subject' => 'required|string',
|
||||
'body' => 'required|string',
|
||||
'attachments.*' => 'nullable|boolean',
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Http\Resources\Common\Contact;
|
|||
use App\Http\Resources\Setting\Category;
|
||||
use App\Http\Resources\Setting\Currency;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Banking\TransactionTax;
|
||||
|
||||
class Transaction extends JsonResource
|
||||
{
|
||||
|
|
@ -45,6 +46,7 @@ class Transaction extends JsonResource
|
|||
'category' => new Category($this->category),
|
||||
'currency' => new Currency($this->currency),
|
||||
'contact' => new Contact($this->contact),
|
||||
'taxes' => [static::$wrap => TransactionTax::collection($this->taxes)],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Banking;
|
||||
|
||||
use App\Http\Resources\Setting\Tax;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TransactionTax extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company_id' => $this->company_id,
|
||||
'transaction_id' => $this->transaction_id,
|
||||
'tax_id' => $this->tax_id,
|
||||
'name' => $this->name,
|
||||
'amount' => $this->amount,
|
||||
'amount_formatted' => money($this->amount, $this->currency_code)->format(),
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
|
||||
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
|
||||
'tax' => new Tax($this->tax),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Resources\Common;
|
||||
|
||||
use App\Http\Resources\Common\ContactPerson;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class Contact extends JsonResource
|
||||
|
|
@ -32,6 +33,7 @@ class Contact extends JsonResource
|
|||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
|
||||
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
|
||||
'contact_persons' => [static::$wrap => ContactPerson::collection($this->contact_persons)],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Common;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ContactPerson extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company_id' => $this->company_id,
|
||||
'type' => $this->type,
|
||||
'contact_id' => $this->contact_id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
|
||||
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Traits\Plans;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PlanLimits
|
||||
{
|
||||
use Plans;
|
||||
|
||||
public function compose(View $view): void
|
||||
{
|
||||
$message = '';
|
||||
$route_name = request()->route()->getName();
|
||||
|
||||
$user_routes = [
|
||||
'users.index',
|
||||
'users.show',
|
||||
'users.create',
|
||||
];
|
||||
|
||||
if (in_array($route_name, $user_routes)) {
|
||||
$user_limit = $this->getUserLimitOfPlan();
|
||||
|
||||
if (! $user_limit->view_status) {
|
||||
$message = $user_limit->message;
|
||||
}
|
||||
}
|
||||
|
||||
$company_routes = [
|
||||
'companies.index',
|
||||
'companies.show',
|
||||
'companies.create',
|
||||
];
|
||||
|
||||
if (in_array($route_name, $company_routes)) {
|
||||
$company_limit = $this->getCompanyLimitOfPlan();
|
||||
|
||||
if (! $company_limit->view_status) {
|
||||
$message = $company_limit->message;
|
||||
}
|
||||
}
|
||||
|
||||
$invoice_routes = [
|
||||
'invoices.index',
|
||||
'invoices.show',
|
||||
'invoices.create',
|
||||
];
|
||||
|
||||
if (in_array($route_name, $invoice_routes)) {
|
||||
$invoice_limit = $this->getInvoiceLimitOfPlan();
|
||||
|
||||
if (! $invoice_limit->view_status) {
|
||||
$message = $invoice_limit->message;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($message)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! setting('apps.api_key')) {
|
||||
$view->getFactory()->startPush('header_start', view('components.alert.call')->with([
|
||||
'type' => 'error',
|
||||
'title' => trans('general.action_required'),
|
||||
'message' => trans('messages.error.empty_apikey', ['url' => route('apps.api-key.create')]),
|
||||
]));
|
||||
}
|
||||
|
||||
$view->getFactory()->startPush('header_start', view('components.alert.call')->with([
|
||||
'type' => 'warning',
|
||||
'title' => trans('general.action_required'),
|
||||
'message' => $message,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Imports\Sales;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Auth\User;
|
||||
use App\Http\Requests\Common\Contact as Request;
|
||||
use App\Models\Common\Contact as Model;
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ class Customers extends Import
|
|||
$row['user_id'] = null;
|
||||
|
||||
if (isset($row['can_login']) && isset($row['email'])) {
|
||||
$row['user_id'] = User::where('email', $row['email'])->first()?->id ?? null;
|
||||
$row['user_id'] = user_model_class()::where('email', $row['email'])->first()?->id ?? null;
|
||||
}
|
||||
|
||||
return $row;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App\Imports\Sales\RecurringInvoices\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Common\Recurring as Model;
|
||||
use Modules\BackupRestore\Abstracts\Import;
|
||||
|
||||
class Recurring extends Import
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,14 +8,18 @@ use App\Events\Auth\UserCreating;
|
|||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Auth\User;
|
||||
use App\Traits\Plans;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): User
|
||||
use Plans;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
event(new UserCreating($this->request));
|
||||
|
||||
\DB::transaction(function () {
|
||||
|
|
@ -23,7 +27,7 @@ class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate
|
|||
$this->request->merge(['password' => Str::random(40)]);
|
||||
}
|
||||
|
||||
$this->model = User::create($this->request->input());
|
||||
$this->model = user_model_class()::create($this->request->input());
|
||||
|
||||
// Upload picture
|
||||
if ($this->request->file('picture')) {
|
||||
|
|
@ -76,11 +80,24 @@ class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate
|
|||
}
|
||||
});
|
||||
|
||||
$this->clearPlansCache();
|
||||
|
||||
event(new UserCreated($this->model, $this->request));
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this action is applicable.
|
||||
*/
|
||||
public function authorize(): void
|
||||
{
|
||||
$limit = $this->getAnyActionLimitOfPlan();
|
||||
if (! $limit->action_status) {
|
||||
throw new \Exception($limit->message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function shouldSendInvitation()
|
||||
{
|
||||
if (app()->runningUnitTests()) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ use App\Abstracts\Job;
|
|||
use App\Events\Auth\UserDeleted;
|
||||
use App\Events\Auth\UserDeleting;
|
||||
use App\Interfaces\Job\ShouldDelete;
|
||||
use App\Traits\Plans;
|
||||
|
||||
class DeleteUser extends Job implements ShouldDelete
|
||||
{
|
||||
use Plans;
|
||||
|
||||
public function handle(): bool
|
||||
{
|
||||
$this->authorize();
|
||||
|
|
@ -23,6 +26,8 @@ class DeleteUser extends Job implements ShouldDelete
|
|||
$this->model->flushCache();
|
||||
});
|
||||
|
||||
$this->clearPlansCache();
|
||||
|
||||
event(new UserDeleted($this->model));
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ use App\Abstracts\Job;
|
|||
use App\Events\Auth\UserUpdated;
|
||||
use App\Events\Auth\UserUpdating;
|
||||
use App\Interfaces\Job\ShouldUpdate;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Company;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class UpdateUser extends Job implements ShouldUpdate
|
||||
{
|
||||
public function handle(): User
|
||||
public function handle()
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
|||
$this->request['company_id'] = $this->model->company_id;
|
||||
$this->request['currency_code'] = $currency_code;
|
||||
$this->request['paid_at'] = isset($this->request['paid_at']) ? $this->request['paid_at'] : Date::now()->toDateTimeString();
|
||||
$this->request['currency_rate'] = config('money.currencies.' . $currency_code . '.rate');
|
||||
$this->request['currency_rate'] = isset($this->request['currency_rate']) ? $this->request['currency_rate'] : currency($currency_code)->getRate();
|
||||
$this->request['account_id'] = isset($this->request['account_id']) ? $this->request['account_id'] : setting('default.account');
|
||||
$this->request['document_id'] = isset($this->request['document_id']) ? $this->request['document_id'] : $this->model->id;
|
||||
$this->request['contact_id'] = isset($this->request['contact_id']) ? $this->request['contact_id'] : $this->model->contact_id;
|
||||
|
|
@ -83,7 +83,7 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
|||
$code = $this->request['currency_code'];
|
||||
$rate = $this->request['currency_rate'];
|
||||
|
||||
$precision = config('money.currencies.' . $code . '.precision');
|
||||
$precision = currency($code)->getPrecision();
|
||||
|
||||
$amount = $this->request['amount'] = round($this->request['amount'], $precision);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use App\Events\Banking\TransactionCreating;
|
|||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Banking\CreateTransactionTaxes;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class CreateTransaction extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
|
|
@ -34,6 +35,8 @@ class CreateTransaction extends Job implements HasOwner, HasSource, ShouldCreate
|
|||
}
|
||||
}
|
||||
|
||||
$this->dispatch(new CreateTransactionTaxes($this->model, $this->request));
|
||||
|
||||
// Recurring
|
||||
$this->model->createRecurring($this->request->all());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Banking\TransactionTax;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class CreateTransactionTaxes extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
protected $transaction;
|
||||
|
||||
protected $request;
|
||||
|
||||
public function __construct(Transaction $transaction, $request)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->request = $request;
|
||||
|
||||
parent::__construct($transaction, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return mixed
|
||||
* @todo type hint after upgrading to PHP 8
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (empty($this->request['tax_ids'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
\DB::transaction(function () {
|
||||
$transaction_taxes = $this->getTaxesCalculated();
|
||||
|
||||
foreach ($transaction_taxes as $transaction_tax) {
|
||||
TransactionTax::create($transaction_tax);
|
||||
}
|
||||
});
|
||||
|
||||
return $this->transaction->taxes;
|
||||
}
|
||||
|
||||
public function getTaxesCalculated()
|
||||
{
|
||||
$tax_total = 0;
|
||||
$transaction_taxes = [];
|
||||
|
||||
$transaction_amount = (double) $this->request['amount'];
|
||||
|
||||
$trx_params = [
|
||||
'company_id' => $this->transaction->company_id,
|
||||
'type' => $this->transaction->type,
|
||||
'transaction_id' => $this->transaction->id,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
];
|
||||
|
||||
// New variables by tax type & tax sorting
|
||||
foreach ((array) $this->request['tax_ids'] as $tax_id) {
|
||||
$tax = Tax::find($tax_id);
|
||||
|
||||
// If tax not found, skip
|
||||
if (! $tax) {
|
||||
continue;
|
||||
}
|
||||
|
||||
${$tax->type . 's'}[] = $tax;
|
||||
}
|
||||
|
||||
if (isset($inclusives)) {
|
||||
foreach ($inclusives as $inclusive) {
|
||||
$tax_amount = $transaction_amount - ($transaction_amount / (1 + $inclusive->rate / 100));
|
||||
|
||||
$transaction_taxes[] = $trx_params + [
|
||||
'tax_id' => $inclusive->id,
|
||||
'name' => $inclusive->name,
|
||||
'amount' => $tax_amount,
|
||||
];
|
||||
|
||||
$tax_total += $tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($fixeds)) {
|
||||
foreach ($fixeds as $tax) {
|
||||
$tax_amount = $tax->rate * (double) 1;
|
||||
|
||||
$transaction_taxes[] = $trx_params + [
|
||||
'tax_id' => $tax->id,
|
||||
'name' => $tax->name,
|
||||
'amount' => $tax_amount,
|
||||
];
|
||||
|
||||
$tax_total += $tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($normals)) {
|
||||
foreach ($normals as $tax) {
|
||||
$tax_amount = $transaction_amount * ($tax->rate / 100);
|
||||
|
||||
$transaction_taxes[] = $trx_params + [
|
||||
'tax_id' => $tax->id,
|
||||
'name' => $tax->name,
|
||||
'amount' => $tax_amount,
|
||||
];
|
||||
|
||||
$tax_total += $tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($withholdings)) {
|
||||
foreach ($withholdings as $tax) {
|
||||
$tax_amount = -($transaction_amount * ($tax->rate / 100));
|
||||
|
||||
$transaction_taxes[] = $trx_params + [
|
||||
'tax_id' => $tax->id,
|
||||
'name' => $tax->name,
|
||||
'amount' => $tax_amount,
|
||||
];
|
||||
|
||||
$tax_total += $tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($compounds)) {
|
||||
foreach ($compounds as $compound) {
|
||||
$tax_amount = ($transaction_amount / 100) * $compound->rate;
|
||||
|
||||
$transaction_taxes[] = $trx_params + [
|
||||
'tax_id' => $compound->id,
|
||||
'name' => $compound->name,
|
||||
'amount' => $tax_amount,
|
||||
];
|
||||
|
||||
$tax_total += $tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
return $transaction_taxes;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ class CreateTransfer extends Job implements HasOwner, HasSource, ShouldCreate
|
|||
$currency_rate = $this->request->get($type . '_account_rate');
|
||||
|
||||
if (empty($currency_rate)) {
|
||||
$currency_rate = config('money.currencies.' . $this->getCurrencyCode($type) . '.rate');
|
||||
$currency_rate = currency($this->getCurrencyCode($type))->getRate();
|
||||
}
|
||||
|
||||
return $currency_rate;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class DeleteTransaction extends Job implements ShouldDelete
|
|||
event(new TransactionDeleting($this->model));
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->model->recurring()->delete();
|
||||
$this->deleteRelationships($this->model, ['recurring', 'taxes']);
|
||||
|
||||
$this->model->delete();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ class MatchBankingDocumentTransaction extends Job
|
|||
$this->checkAmount();
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->transaction = $this->dispatch(new UpdateTransaction($this->transaction, ['document_id' => $this->model->id]));
|
||||
$this->transaction = $this->dispatch(new UpdateTransaction($this->transaction, [
|
||||
'document_id' => $this->model->id,
|
||||
'type' => $this->transaction->type, // Set missing type get default income typr for UpdateTransaction job.
|
||||
]));
|
||||
|
||||
$this->model->save();
|
||||
|
||||
|
|
@ -42,7 +45,7 @@ class MatchBankingDocumentTransaction extends Job
|
|||
$code = $this->transaction->currency_code;
|
||||
$rate = $this->transaction->currency_rate;
|
||||
|
||||
$precision = config('money.currencies.' . $code . '.precision');
|
||||
$precision = currency($code)->getPrecision();
|
||||
|
||||
$amount = $this->transaction->amount = round($this->transaction->amount, $precision);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Banking\TransactionSending;
|
||||
use App\Events\Banking\TransactionSent;
|
||||
use App\Http\Requests\Common\CustomMail as Request;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
|
@ -22,14 +23,43 @@ class SendTransactionAsCustomMail extends Job
|
|||
{
|
||||
$transaction = Transaction::find($this->request->get('transaction_id'));
|
||||
|
||||
$custom_mail = $this->request->only(['to', 'subject', 'body']);
|
||||
event(new TransactionSending($transaction));
|
||||
|
||||
$mail_request = $this->request->only(['to', 'subject', 'body']);
|
||||
|
||||
if ($this->request->get('user_email', false)) {
|
||||
$custom_mail['cc'] = user()->email;
|
||||
$mail_request['cc'] = user()->email;
|
||||
}
|
||||
|
||||
// Notify the contact
|
||||
$transaction->contact->notify(new Notification($transaction, $this->template_alias, true, $custom_mail));
|
||||
$attachments = collect($this->request->get('attachments', []))
|
||||
->filter(fn($value) => $value == true)
|
||||
->keys()
|
||||
->all();
|
||||
|
||||
$attach_pdf = in_array('pdf', $attachments);
|
||||
|
||||
$contacts = $transaction->contact->withPersons();
|
||||
|
||||
$counter = 1;
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
if (! in_array($contact->email, $mail_request['to'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$custom_mail = [
|
||||
'subject' => $mail_request['subject'],
|
||||
'body' => $mail_request['body'],
|
||||
];
|
||||
|
||||
if (($counter == 1) && ! empty($mail_request['cc'])) {
|
||||
$custom_mail['cc'] = $mail_request['cc'];
|
||||
}
|
||||
|
||||
$contact->notify(new Notification($transaction, $this->template_alias, $attach_pdf, $custom_mail, $attachments));
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
event(new TransactionSent($transaction));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class SplitTransaction extends Job implements ShouldUpdate
|
|||
$total_amount += $item['amount'];
|
||||
}
|
||||
|
||||
$precision = config('money.currencies.' . $this->model->currency_code . '.precision');
|
||||
$precision = currency($this->model->currency_code)->getPrecision();
|
||||
|
||||
$compare = bccomp($total_amount, $this->model->amount, $precision);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||
$this->request['company_id'] = $this->model->company_id;
|
||||
$this->request['currency_code'] = $currency_code;
|
||||
$this->request['paid_at'] = isset($this->request['paid_at']) ? $this->request['paid_at'] : Date::now()->toDateTimeString();
|
||||
$this->request['currency_rate'] = config('money.currencies.' . $currency_code . '.rate');
|
||||
$this->request['currency_rate'] = currency($currency_code)->getRate();
|
||||
$this->request['account_id'] = isset($this->request['account_id']) ? $this->request['account_id'] : setting('default.account');
|
||||
$this->request['document_id'] = isset($this->request['document_id']) ? $this->request['document_id'] : $this->model->id;
|
||||
$this->request['contact_id'] = isset($this->request['contact_id']) ? $this->request['contact_id'] : $this->model->contact_id;
|
||||
|
|
@ -82,7 +82,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||
$code = $this->request['currency_code'];
|
||||
$rate = $this->request['currency_rate'];
|
||||
|
||||
$precision = config('money.currencies.' . $code . '.precision');
|
||||
$precision = currency($code)->getPrecision();
|
||||
|
||||
$amount = $this->request['amount'] = round($this->request['amount'], $precision);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Abstracts\Job;
|
|||
use App\Events\Banking\TransactionUpdated;
|
||||
use App\Events\Banking\TransactionUpdating;
|
||||
use App\Interfaces\Job\ShouldUpdate;
|
||||
use App\Jobs\Banking\CreateTransactionTaxes;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class UpdateTransaction extends Job implements ShouldUpdate
|
||||
|
|
@ -38,6 +39,10 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
|||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
$this->deleteRelationships($this->model, ['taxes'], true);
|
||||
|
||||
$this->dispatch(new CreateTransactionTaxes($this->model, $this->request));
|
||||
|
||||
// Recurring
|
||||
$this->model->updateRecurring($this->request->all());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class UpdateTransfer extends Job implements ShouldUpdate
|
|||
$currency_rate = $this->request->get($type . '_account_rate');
|
||||
|
||||
if (empty($currency_rate)) {
|
||||
$currency_rate = config('money.currencies.' . $this->getCurrencyCode($type) . '.rate');
|
||||
$currency_rate = currency($this->getCurrencyCode($type))->getRate();
|
||||
}
|
||||
|
||||
return $currency_rate;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Jobs\Common;
|
||||
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Common\CompanyCreated;
|
||||
use App\Events\Common\CompanyCreating;
|
||||
|
|
@ -11,14 +12,18 @@ use App\Interfaces\Job\ShouldCreate;
|
|||
use App\Models\Banking\Account;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Setting\Currency;
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Traits\Plans;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use OutOfBoundsException;
|
||||
|
||||
class CreateCompany extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
use Plans;
|
||||
|
||||
public function handle(): Company
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$current_company_id = company_id();
|
||||
|
||||
event(new CompanyCreating($this->request));
|
||||
|
|
@ -39,11 +44,24 @@ class CreateCompany extends Job implements HasOwner, HasSource, ShouldCreate
|
|||
company($current_company_id)->makeCurrent();
|
||||
}
|
||||
|
||||
$this->clearPlansCache();
|
||||
|
||||
event(new CompanyCreated($this->model, $this->request));
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this action is applicable.
|
||||
*/
|
||||
public function authorize(): void
|
||||
{
|
||||
$limit = $this->getAnyActionLimitOfPlan();
|
||||
if (! $limit->action_status) {
|
||||
throw new \Exception($limit->message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function callSeeds(): void
|
||||
{
|
||||
// Set custom locale
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue