Invoiceplane: Difference between revisions

Onny (talk | contribs)
Invoice templates: Update example template
Onny (talk | contribs)
Add dev env example
 
Line 103: Line 103:


Access your Invoiceplane instance again in your browser and rerun the setup. After upgrading the tables you can login as usual. It is now recommended to change both variables in the config file above back to <code>true</code>.
Access your Invoiceplane instance again in your browser and rerun the setup. After upgrading the tables you can login as usual. It is now recommended to change both variables in the config file above back to <code>true</code>.
== Tips and tricks ==
=== Invoice template development ===
Following <code>flake.nix</code> file helps you spawning a virtual machine running a development environment of Invoiceplane. The local directory <code>/home/user/my_invoiceplane_template</code> containing a modified invoice or quote template will be mounted into the Invoiceplane web app, allowing to change the template and directly render the invoice PDF in the local web server at http://localhost:8080<syntaxhighlight lang="nix">
{
  description = "Invoiceplane invoice template development shell";
  inputs.nixpkgs.url = "nixpkgs/nixos-24.11";
  outputs = { self, nixpkgs, ... }@inputs:
  let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    start =
      pkgs.writeShellScriptBin "start" ''
        set -e
        export QEMU_NET_OPTS="hostfwd=tcp::8080-:80"
        ${pkgs.nixos-shell}/bin/nixos-shell --flake .
      '';
  in {
    nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs.inputs = inputs;
      pkgs = import nixpkgs {
overlays = [
          (self: super: {
            invoiceplane = super.invoiceplane.overrideAttrs (oldAttrs: rec {
              installPhase = oldAttrs.installPhase + ''
                rm -r $out/application/views/invoice_templates/pdf
                ln -sf /var/lib/invoiceplane/localhost/pdf $out/application/views/invoice_templates/pdf
              '';
            });
          })
        ];
      };
      modules = [
        ({ lib, config, pkgs, ... }: {
  services.invoiceplane.sites."localhost" = {
    enable = true;
    settings.IP_URL = "http://localhost:8080";
  };
          nixos-shell.mounts.extraMounts = {
            "/var/lib/invoiceplane/localhost/pdf" = {
              target = /home/user/my_invoiceplane_template;
              cache = "none";
            };
          };
          system.stateVersion = "24.11";
          services.getty.autologinUser = "root";
        })
      ];
    };
    packages = { inherit start; };
    defaultPackage.x86_64-linux = start;
  };
}
</syntaxhighlight>To run the web server simply execute following command in the same directory as the <code>flake.nix</code> file<syntaxhighlight lang="shell">
nix run
</syntaxhighlight>


== See also ==
== See also ==