scrubbed all reference to datomic.api
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
(:require
|
||||
[auto-ap.utils :refer [default-pagination-size by]]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.edn :as edn]
|
||||
[config.core :refer [env]]
|
||||
[datomic.client.api :as dc]
|
||||
[mount.core :as mount])
|
||||
[mount.core :as mount]
|
||||
[clojure.java.io :as io])
|
||||
(:import
|
||||
(java.util UUID)))
|
||||
|
||||
@@ -892,3 +894,8 @@
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
(defn transact-schema [conn]
|
||||
(dc/transact conn
|
||||
{:tx-data (edn/read-string (slurp (io/resource "schema.edn")))}))
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
(defn rebuild-search-index []
|
||||
(search/full-index-query
|
||||
(for [result (map first (dc/qseq '[:find (pull ?v [:client/name :client/matches :db/id])
|
||||
(for [result (map first (dc/q '[:find (pull ?v [:client/name :client/matches :db/id])
|
||||
:in $
|
||||
:where [?v :client/code]]
|
||||
(dc/db conn)))
|
||||
|
||||
@@ -99,10 +99,12 @@
|
||||
due (or (and (:vendor/terms vendor)
|
||||
(coerce/to-date
|
||||
(time/plus date (time/days (d-vendors/terms-for-client-id vendor client_id)))))
|
||||
due)
|
||||
due
|
||||
nil)
|
||||
scheduled_payment (or scheduled_payment
|
||||
(and (d-vendors/automatically-paid-for-client-id? vendor client_id)
|
||||
due))
|
||||
due)
|
||||
nil)
|
||||
_ (when-not (:db/id account)
|
||||
(throw (ex-info (str "Vendor '" (:vendor/name vendor) "' does not have a default expense acount.") {:vendor-id vendor_id})))]
|
||||
|
||||
@@ -123,7 +125,9 @@
|
||||
(defn assert-valid-expense-accounts [expense_accounts vendor_id]
|
||||
(doseq [expense-account expense_accounts
|
||||
:let [account (dc/pull (dc/db conn)
|
||||
[:account/location]
|
||||
[:db/id
|
||||
:account/location
|
||||
{:account/invoice-allowance [:db/ident]}]
|
||||
(:account_id expense-account))]]
|
||||
(when (empty? (:location expense-account))
|
||||
(throw (ex-info "Expense account is missing location" {:validation-error "Expense account is missing location"})))
|
||||
@@ -136,8 +140,8 @@
|
||||
{:validation-error err}))))
|
||||
|
||||
(when (and (= :allowance/denied
|
||||
(:account/invoice-allowance account))
|
||||
(not= (pull-ref (dc/db conn) vendor_id :vendor/default-account)
|
||||
(:db/ident (:account/invoice-allowance account)))
|
||||
(not= (pull-ref (dc/db conn) :vendor/default-account vendor_id )
|
||||
(:db/id account)))
|
||||
(let [err (str "Account isn't allowed for invoice use.")]
|
||||
(throw (ex-info err
|
||||
@@ -171,7 +175,7 @@
|
||||
(assert-valid-expense-accounts expense_accounts vendor_id)
|
||||
(assert-invoice-amounts-add-up in)
|
||||
|
||||
(let [transaction-result (transact-with-ledger (add-invoice-transaction in) (:id context))]
|
||||
(let [transaction-result (transact-with-ledger [(add-invoice-transaction in)] (:id context))]
|
||||
(-> (d-invoices/get-by-id (get-in transaction-result [:tempids "invoice"]))
|
||||
(->graphql (:id context)))))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.graphql.transaction-rules
|
||||
(:require
|
||||
[auto-ap.datomic :refer [audit-transact conn merge-query upsert-entity]]
|
||||
[auto-ap.datomic :refer [audit-transact conn merge-query upsert-entity random-tempid]]
|
||||
[auto-ap.datomic.transaction-rules :as tr]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.graphql.utils
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
(defn transaction-rule-account->entity [{:keys [id account_id percentage location]}]
|
||||
#:transaction-rule-account {:percentage percentage
|
||||
:db/id id
|
||||
:db/id (or id (random-tempid))
|
||||
:account account_id
|
||||
:location location})
|
||||
|
||||
|
||||
@@ -280,14 +280,20 @@
|
||||
(finish! [this])
|
||||
(fail! [this error]))
|
||||
|
||||
(def bank-account-pull [:bank-account/code
|
||||
:db/id
|
||||
:bank-account/locations
|
||||
:bank-account/start-date
|
||||
{:client/_bank-accounts [:client/code :client/locked-until :client/locations :db/id]} ])
|
||||
|
||||
(defn start-import-batch [source user]
|
||||
(let [stats (atom {:import-batch/imported 0
|
||||
(let [stats (atom {:import-batch/imported 0
|
||||
:import-batch/suppressed 0
|
||||
:import-batch/error 0
|
||||
:import-batch/not-ready 0
|
||||
:import-batch/extant 0})
|
||||
extant-cache (atom (cache/ttl-cache-factory {} :ttl 60000 ))
|
||||
import-id (get (:tempids (dc/transact conn {:tx-data [{:db/id "import-batch"
|
||||
extant-cache (atom (cache/ttl-cache-factory {} :ttl 60000 ))
|
||||
import-id (get (:tempids (dc/transact conn {:tx-data [{:db/id "import-batch"
|
||||
:import-batch/date (coerce/to-date (t/now))
|
||||
:import-batch/source source
|
||||
:import-batch/status :import-status/started
|
||||
@@ -298,11 +304,7 @@
|
||||
(reify ImportBatch
|
||||
(import-transaction! [_ transaction]
|
||||
(let [bank-account (dc/pull (dc/db conn)
|
||||
[:bank-account/code
|
||||
:db/id
|
||||
:bank-account/locations
|
||||
:bank-account/start-date
|
||||
{:client/_bank-accounts [:client/code :client/locked-until :client/locations :db/id]} ]
|
||||
bank-account-pull
|
||||
(:transaction/bank-account transaction))
|
||||
extant (get (swap! extant-cache cache/through-cache (:transaction/bank-account transaction) get-existing)
|
||||
(:transaction/bank-account transaction))
|
||||
|
||||
@@ -14,7 +14,7 @@ variable "stage" {}
|
||||
data "aws_caller_identity" "current" {}
|
||||
|
||||
resource "aws_ses_receipt_rule_set" "main" {
|
||||
rule_set_name = "default-rule-set"
|
||||
rule_set_name = "default-rule-set-${var.stage}"
|
||||
}
|
||||
|
||||
resource "aws_ses_receipt_rule" "store" {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.3.8",
|
||||
"serial": 47,
|
||||
"serial": 60,
|
||||
"lineage": "cf731bb4-8fb3-47af-6e29-22030e089d96",
|
||||
"outputs": {
|
||||
"aws_access_key_id": {
|
||||
@@ -162,7 +162,7 @@
|
||||
"registry_arn": "arn:aws:servicediscovery:us-east-1:679918342773:service/srv-cmwdohq6dvf3pbjv"
|
||||
}
|
||||
],
|
||||
"tags": null,
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
"task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:2",
|
||||
"timeouts": {
|
||||
@@ -189,8 +189,8 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:2",
|
||||
"container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod-cloud\",\"com.datadoghq.tags.service\":\"integreat-app\"},\"environment\":[{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"integreat-app-cloud\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-cloud.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat-cloud\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
|
||||
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:3",
|
||||
"container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod-cloud\",\"com.datadoghq.tags.service\":\"integreat-app\"},\"environment\":[{\"name\":\"DD_ENV\",\"value\":\"prod-cloud\"},{\"name\":\"DD_SERVICE\",\"value\":\"integreat-app-cloud\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-cloud.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat-cloud\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
|
||||
"cpu": "2048",
|
||||
"ephemeral_storage": [],
|
||||
"execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
|
||||
@@ -206,7 +206,7 @@
|
||||
"requires_compatibilities": [
|
||||
"FARGATE"
|
||||
],
|
||||
"revision": 2,
|
||||
"revision": 3,
|
||||
"runtime_platform": [],
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
@@ -471,7 +471,7 @@
|
||||
"port": 443,
|
||||
"protocol": "HTTPS",
|
||||
"ssl_policy": "ELBSecurityPolicy-2016-08",
|
||||
"tags": null,
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
"timeouts": {
|
||||
"read": null
|
||||
@@ -541,7 +541,7 @@
|
||||
"id": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener-rule/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9/d6c79bc1d166a6d0",
|
||||
"listener_arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9",
|
||||
"priority": 1,
|
||||
"tags": null,
|
||||
"tags": {},
|
||||
"tags_all": {}
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
@@ -905,7 +905,64 @@
|
||||
"type": "aws_ses_receipt_rule",
|
||||
"name": "store",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": []
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"add_header_action": [],
|
||||
"after": null,
|
||||
"arn": "arn:aws:ses:us-east-1:679918342773:receipt-rule-set/default-rule-set:receipt-rule/store-prod-cloud",
|
||||
"bounce_action": [],
|
||||
"enabled": true,
|
||||
"id": "store-prod-cloud",
|
||||
"lambda_action": [],
|
||||
"name": "store-prod-cloud",
|
||||
"recipients": [
|
||||
"invoices@cloud.mail.app.integreatconsult.com"
|
||||
],
|
||||
"rule_set_name": "default-rule-set",
|
||||
"s3_action": [
|
||||
{
|
||||
"bucket_name": "integreat-mail-prod-cloud",
|
||||
"kms_key_arn": "",
|
||||
"object_key_prefix": "",
|
||||
"position": 1,
|
||||
"topic_arn": ""
|
||||
}
|
||||
],
|
||||
"scan_enabled": true,
|
||||
"sns_action": [],
|
||||
"stop_action": [],
|
||||
"tls_policy": "Optional",
|
||||
"workmail_action": []
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA==",
|
||||
"dependencies": [
|
||||
"aws_s3_bucket.invoices",
|
||||
"aws_ses_receipt_rule_set.main",
|
||||
"data.aws_caller_identity.current"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_ses_receipt_rule_set",
|
||||
"name": "main",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:ses:us-east-1:679918342773:receipt-rule-set/default-rule-set-prod-cloud",
|
||||
"id": "default-rule-set-prod-cloud",
|
||||
"rule_set_name": "default-rule-set-prod-cloud"
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.3.8",
|
||||
"serial": 39,
|
||||
"serial": 54,
|
||||
"lineage": "cf731bb4-8fb3-47af-6e29-22030e089d96",
|
||||
"outputs": {
|
||||
"aws_access_key_id": {
|
||||
@@ -71,7 +71,7 @@
|
||||
}
|
||||
],
|
||||
"private_key": null,
|
||||
"status": "PENDING_VALIDATION",
|
||||
"status": "ISSUED",
|
||||
"subject_alternative_names": [],
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
@@ -83,6 +83,103 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_ecs_service",
|
||||
"name": "integreat_app",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"capacity_provider_strategy": [
|
||||
{
|
||||
"base": 0,
|
||||
"capacity_provider": "FARGATE_SPOT",
|
||||
"weight": 5
|
||||
},
|
||||
{
|
||||
"base": 1,
|
||||
"capacity_provider": "FARGATE",
|
||||
"weight": 1
|
||||
}
|
||||
],
|
||||
"cluster": "arn:aws:ecs:us-east-1:679918342773:cluster/default",
|
||||
"deployment_circuit_breaker": [
|
||||
{
|
||||
"enable": false,
|
||||
"rollback": false
|
||||
}
|
||||
],
|
||||
"deployment_controller": [
|
||||
{
|
||||
"type": "ECS"
|
||||
}
|
||||
],
|
||||
"deployment_maximum_percent": 200,
|
||||
"deployment_minimum_healthy_percent": 100,
|
||||
"desired_count": 2,
|
||||
"enable_ecs_managed_tags": false,
|
||||
"enable_execute_command": false,
|
||||
"force_new_deployment": null,
|
||||
"health_check_grace_period_seconds": 600,
|
||||
"iam_role": "aws-service-role",
|
||||
"id": "arn:aws:ecs:us-east-1:679918342773:service/default/integreat_app_prod-cloud",
|
||||
"launch_type": "",
|
||||
"load_balancer": [
|
||||
{
|
||||
"container_name": "integreat-app",
|
||||
"container_port": 3000,
|
||||
"elb_name": "",
|
||||
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:targetgroup/integreat-app-prod-cloud/d176101bfa60e2e3"
|
||||
}
|
||||
],
|
||||
"name": "integreat_app_prod-cloud",
|
||||
"network_configuration": [
|
||||
{
|
||||
"assign_public_ip": true,
|
||||
"security_groups": [
|
||||
"sg-004e5855310c453a3",
|
||||
"sg-02d167406b1082698"
|
||||
],
|
||||
"subnets": [
|
||||
"subnet-5e675761",
|
||||
"subnet-8519fde2",
|
||||
"subnet-89bab8d4"
|
||||
]
|
||||
}
|
||||
],
|
||||
"ordered_placement_strategy": [],
|
||||
"placement_constraints": [],
|
||||
"platform_version": "LATEST",
|
||||
"propagate_tags": "NONE",
|
||||
"scheduling_strategy": "REPLICA",
|
||||
"service_registries": [
|
||||
{
|
||||
"container_name": "",
|
||||
"container_port": 0,
|
||||
"port": 0,
|
||||
"registry_arn": "arn:aws:servicediscovery:us-east-1:679918342773:service/srv-cmwdohq6dvf3pbjv"
|
||||
}
|
||||
],
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
"task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:2",
|
||||
"timeouts": {
|
||||
"delete": null
|
||||
},
|
||||
"wait_for_steady_state": true
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiZGVsZXRlIjoxMjAwMDAwMDAwMDAwfX0=",
|
||||
"dependencies": [
|
||||
"aws_ecs_task_definition.integreat_app",
|
||||
"aws_lb_target_group.integreat_app",
|
||||
"aws_service_discovery_service.service"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_ecs_task_definition",
|
||||
@@ -92,8 +189,8 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:2",
|
||||
"container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod-cloud\",\"com.datadoghq.tags.service\":\"integreat-app\"},\"environment\":[{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"integreat-app-cloud\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-cloud.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat-cloud\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
|
||||
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod-cloud:3",
|
||||
"container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod-cloud\",\"com.datadoghq.tags.service\":\"integreat-app\"},\"environment\":[{\"name\":\"DD_ENV\",\"value\":\"prod-cloud\"},{\"name\":\"DD_SERVICE\",\"value\":\"integreat-app-cloud\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-cloud.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat-cloud\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
|
||||
"cpu": "2048",
|
||||
"ephemeral_storage": [],
|
||||
"execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
|
||||
@@ -109,9 +206,9 @@
|
||||
"requires_compatibilities": [
|
||||
"FARGATE"
|
||||
],
|
||||
"revision": 2,
|
||||
"revision": 3,
|
||||
"runtime_platform": [],
|
||||
"tags": {},
|
||||
"tags": null,
|
||||
"tags_all": {},
|
||||
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
|
||||
"volume": []
|
||||
@@ -345,12 +442,118 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_lb_listener",
|
||||
"name": "https",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"alpn_policy": null,
|
||||
"arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9",
|
||||
"certificate_arn": "arn:aws:acm:us-east-1:679918342773:certificate/a10ec71a-e49b-4dc0-9eb3-3c43575bf125",
|
||||
"default_action": [
|
||||
{
|
||||
"authenticate_cognito": [],
|
||||
"authenticate_oidc": [],
|
||||
"fixed_response": [],
|
||||
"forward": [],
|
||||
"order": 1,
|
||||
"redirect": [],
|
||||
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:targetgroup/integreat-app-prod-cloud/d176101bfa60e2e3",
|
||||
"type": "forward"
|
||||
}
|
||||
],
|
||||
"id": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9",
|
||||
"load_balancer_arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:loadbalancer/app/integreat-app-prod-cloud/ed5b70fcc043ff33",
|
||||
"port": 443,
|
||||
"protocol": "HTTPS",
|
||||
"ssl_policy": "ELBSecurityPolicy-2016-08",
|
||||
"tags": {},
|
||||
"tags_all": {},
|
||||
"timeouts": {
|
||||
"read": null
|
||||
}
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsicmVhZCI6NjAwMDAwMDAwMDAwfX0=",
|
||||
"dependencies": [
|
||||
"aws_acm_certificate.cert",
|
||||
"aws_lb.integreat_app",
|
||||
"aws_lb_target_group.integreat_app"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_lb_listener_rule",
|
||||
"name": "static",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": []
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"action": [
|
||||
{
|
||||
"authenticate_cognito": [],
|
||||
"authenticate_oidc": [],
|
||||
"fixed_response": [],
|
||||
"forward": [],
|
||||
"order": 1,
|
||||
"redirect": [
|
||||
{
|
||||
"host": "s3.amazonaws.com",
|
||||
"path": "/cloud.app.integreatconsult.com/#{path}",
|
||||
"port": "443",
|
||||
"protocol": "HTTPS",
|
||||
"query": "#{query}",
|
||||
"status_code": "HTTP_301"
|
||||
}
|
||||
],
|
||||
"target_group_arn": "",
|
||||
"type": "redirect"
|
||||
}
|
||||
],
|
||||
"arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener-rule/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9/d6c79bc1d166a6d0",
|
||||
"condition": [
|
||||
{
|
||||
"host_header": [],
|
||||
"http_header": [],
|
||||
"http_request_method": [],
|
||||
"path_pattern": [
|
||||
{
|
||||
"values": [
|
||||
"/css/*",
|
||||
"/finance-font/*",
|
||||
"/img/*",
|
||||
"/js/compiled/*",
|
||||
"index.html"
|
||||
]
|
||||
}
|
||||
],
|
||||
"query_string": [],
|
||||
"source_ip": []
|
||||
}
|
||||
],
|
||||
"id": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener-rule/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9/d6c79bc1d166a6d0",
|
||||
"listener_arn": "arn:aws:elasticloadbalancing:us-east-1:679918342773:listener/app/integreat-app-prod-cloud/ed5b70fcc043ff33/5c57593c85467dd9",
|
||||
"priority": 1,
|
||||
"tags": {},
|
||||
"tags_all": {}
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA==",
|
||||
"dependencies": [
|
||||
"aws_acm_certificate.cert",
|
||||
"aws_lb.integreat_app",
|
||||
"aws_lb_listener.https",
|
||||
"aws_lb_target_group.integreat_app"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
(ns auto-ap.ezcater-test
|
||||
(:require [auto-ap.ezcater.core :as sut]
|
||||
[clojure.test :as t]
|
||||
[datomic.api :as d ]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.time-reader]))
|
||||
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate auto-ap.datomic/conn)
|
||||
(f)
|
||||
(d/release auto-ap.datomic/conn)
|
||||
(d/delete-database uri))))
|
||||
(:require
|
||||
[auto-ap.ezcater.core :as sut]
|
||||
[auto-ap.integration.util :refer [wrap-setup]]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :each wrap-setup)
|
||||
|
||||
@@ -138,7 +125,7 @@
|
||||
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
|
||||
sut/commision)))))
|
||||
(t/testing "Should calculate 2.75% ccp fee"
|
||||
(t/is (dollars= 8.25
|
||||
(t/is (dollars= 8.97
|
||||
(-> known-order
|
||||
(assoc :orderSourceType "MARKETPLACE")
|
||||
(assoc-in [:totals :subTotal :subunits] 10000)
|
||||
@@ -151,7 +138,7 @@
|
||||
sut/order->sales-order
|
||||
:sales-order/total))))
|
||||
(t/testing "Should derive adjustments food-total + sales-tax - caterer-total - service fee - ccp fee"
|
||||
(t/is (dollars= -41.8975
|
||||
(t/is (dollars= -42.99
|
||||
(-> known-order
|
||||
sut/order->sales-order
|
||||
:sales-order/discount))))
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
(ns auto-ap.import.transactions-test
|
||||
(:require [auto-ap.datomic :refer [conn uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.import.transactions :as sut]
|
||||
[clojure.test :as t]
|
||||
[datomic.api :as d]
|
||||
[digest :as di]
|
||||
[clj-time.coerce :as coerce]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate auto-ap.datomic/conn)
|
||||
(f)
|
||||
(d/release auto-ap.datomic/conn)
|
||||
(d/delete-database uri))))
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.transactions :as sut]
|
||||
[auto-ap.integration.util :refer [wrap-setup]]
|
||||
[datomic.client.api :as dc]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.test :as t]
|
||||
[digest :as di]))
|
||||
|
||||
(t/use-fixtures :each wrap-setup)
|
||||
|
||||
@@ -85,14 +76,16 @@
|
||||
(t/deftest transaction->txs
|
||||
(t/testing "Should import and code transactions"
|
||||
(t/testing "Should import one transaction"
|
||||
(let [{:strs [bank-account-id client-id]} (:tempids @(d/transact conn [{:db/id "bank-account-id"
|
||||
:bank-account/code "TEST-1"}
|
||||
{:db/id "client-id"
|
||||
:client/code "TEST"
|
||||
:client/locations ["Z" "E"]
|
||||
:client/bank-accounts ["bank-account-id"]}]))
|
||||
(let [{:strs [bank-account-id client-id]} (:tempids (dc/transact conn
|
||||
{:tx-data [{:db/id "bank-account-id"
|
||||
:bank-account/code "TEST-1"}
|
||||
{:db/id "client-id"
|
||||
:client/code "TEST"
|
||||
:client/locations ["Z" "E"]
|
||||
:client/bank-accounts ["bank-account-id"]}]}))
|
||||
_ (println bank-account-id client-id)
|
||||
result (sut/transaction->txs base-transaction
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (= [(assoc base-transaction
|
||||
:transaction/approval-status :transaction-approval-status/unapproved
|
||||
@@ -101,26 +94,25 @@
|
||||
result))))
|
||||
|
||||
(t/testing "Should match an uncleared check"
|
||||
(let [{:strs [bank-account-id payment-id]} (->> [#:payment {:status :payment-status/pending
|
||||
:date #inst "2019-01-01"
|
||||
(let [{:strs [bank-account-id payment-id]} (->> {:tx-data [#:payment {:status :payment-status/pending
|
||||
:date #inst "2019-01-01"
|
||||
:bank-account "bank-account-id"
|
||||
:client "client-id"
|
||||
:client "client-id"
|
||||
:check-number 10001
|
||||
:amount 30.0
|
||||
:db/id "payment-id"}
|
||||
#:bank-account {:name "Bank account"
|
||||
:amount 30.0
|
||||
:db/id "payment-id"}
|
||||
#:bank-account {:name "Bank account"
|
||||
:db/id "bank-account-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"
|
||||
:bank-accounts ["bank-account-id"]}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"
|
||||
:bank-accounts ["bank-account-id"]}]}
|
||||
(dc/transact conn)
|
||||
:tempids)]
|
||||
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/description-original "CHECK 10001"
|
||||
:transaction/amount -30.0)
|
||||
(d/entity (d/db conn ) bank-account-id)
|
||||
(dc/pull (dc/db conn ) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
|
||||
(t/is (= {:db/id payment-id
|
||||
@@ -132,7 +124,7 @@
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/description-original "CHECK 12301"
|
||||
:transaction/amount -30.0)
|
||||
(d/entity (d/db conn ) bank-account-id)
|
||||
(dc/pull (dc/db conn ) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
|
||||
(t/is (= {:db/id payment-id
|
||||
@@ -140,11 +132,11 @@
|
||||
(:transaction/payment transaction-result)))))
|
||||
|
||||
(t/testing "Should not match an already matched check"
|
||||
@(d/transact (d/connect uri) [{:db/id payment-id :payment/status :payment-status/cleared}])
|
||||
(dc/transact conn {:tx-data [{:db/id payment-id :payment/status :payment-status/cleared}]})
|
||||
(let [[result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/description-original "CHECK 10001"
|
||||
:transaction/amount -30.0)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
|
||||
(t/is (= nil
|
||||
@@ -152,21 +144,20 @@
|
||||
|
||||
|
||||
(t/testing "Should match expected-deposits"
|
||||
(let [{:strs [bank-account-id client-id expected-deposit-id]} (->> [#:expected-deposit {:client "client-id"
|
||||
:date #inst "2021-07-01T00:00:00-08:00"
|
||||
:vendor :vendor/ccp-square
|
||||
:total 100.0
|
||||
:location "MF"
|
||||
:status :expected-deposit-status/pending
|
||||
:db/id "expected-deposit-id"}
|
||||
#:bank-account {:name "Bank account"
|
||||
:db/id "bank-account-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"
|
||||
:locations ["MF"]
|
||||
:bank-accounts ["bank-account-id"]}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
(let [{:strs [bank-account-id client-id expected-deposit-id]} (->> {:tx-data [#:expected-deposit {:client "client-id"
|
||||
:date #inst "2021-07-01T00:00:00-08:00"
|
||||
:vendor :vendor/ccp-square
|
||||
:total 100.0
|
||||
:location "MF"
|
||||
:status :expected-deposit-status/pending
|
||||
:db/id "expected-deposit-id"}
|
||||
#:bank-account {:name "Bank account"
|
||||
:db/id "bank-account-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"
|
||||
:locations ["MF"]
|
||||
:bank-accounts ["bank-account-id"]}]}
|
||||
(dc/transact conn)
|
||||
:tempids)]
|
||||
|
||||
|
||||
@@ -174,7 +165,7 @@
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/date #inst "2021-07-03T00:00:00-08:00"
|
||||
:transaction/amount 100.0)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (= expected-deposit-id
|
||||
(:db/id (sut/find-expected-deposit client-id 100.0 (clj-time.coerce/to-date-time #inst "2021-07-03T00:00:00-08:00")))))
|
||||
@@ -186,7 +177,7 @@
|
||||
(t/testing "Should copy vendor from expected-depoisit"
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/vendor :vendor/ccp-square)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (= :vendor/ccp-square
|
||||
(:transaction/vendor transaction-result)))))
|
||||
@@ -195,7 +186,7 @@
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/date #inst "2021-07-03T00:00:00-08:00"
|
||||
:transaction/amount 100.0)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (= [{:transaction-account/account :account/ccp
|
||||
:transaction-account/amount 100.0
|
||||
@@ -206,7 +197,7 @@
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/date #inst "2021-07-13"
|
||||
:transaction/amount 100.0)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (not (:transaction/expected-deposit transaction-result)))))
|
||||
|
||||
@@ -214,7 +205,7 @@
|
||||
(let [[transaction-result] (sut/transaction->txs (assoc base-transaction
|
||||
:transaction/date "2021-07-03"
|
||||
:transaction/amount 100.01)
|
||||
(d/entity (d/db conn) bank-account-id)
|
||||
(dc/pull (dc/db conn) sut/bank-account-pull bank-account-id)
|
||||
noop-rule)]
|
||||
(t/is (not (:transaction/expected-deposit transaction-result)))))))))
|
||||
|
||||
@@ -259,172 +250,170 @@
|
||||
|
||||
(t/deftest match-transaction-to-single-unfulfilled-payments
|
||||
(t/testing "Auto-pay Invoices"
|
||||
(let [{:strs [vendor1-id vendor2-id]} (->> [#:vendor {:name "Autopay vendor 1"
|
||||
:db/id "vendor1-id"}
|
||||
#:vendor {:name "Autopay vendor 2"
|
||||
:db/id "vendor2-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
(let [{:strs [vendor1-id vendor2-id]} (->> {:tx-data [#:vendor {:name "Autopay vendor 1"
|
||||
:db/id "vendor1-id"}
|
||||
#:vendor {:name "Autopay vendor 2"
|
||||
:db/id "vendor2-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)]
|
||||
(t/testing "Should find a single invoice that matches exactly"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
(let [{:strs [client-id]} (->> {:tx-data [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(t/is (= 1 (count invoices-matches)))
|
||||
))
|
||||
|
||||
(t/testing "Should not match paid invoice that isn't a scheduled payment"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice{:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
|
||||
(t/is (= [] invoices-matches))))
|
||||
|
||||
(t/testing "Should not match unpaid invoice"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/unpaid
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/unpaid
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
|
||||
(t/is (= [] invoices-matches))))
|
||||
|
||||
(t/testing "Should not match invoice that already has a payment"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
{:invoice-payment/amount 30.0
|
||||
:invoice-payment/invoice "invoice-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/paid
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:vendor vendor1-id
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice-id"}
|
||||
{:invoice-payment/amount 30.0
|
||||
:invoice-payment/invoice "invoice-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0
|
||||
client-id)]
|
||||
(t/is (= [] invoices-matches))))
|
||||
(t/testing "Should match multiple invoices for same vendor that total to transaction amount"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 15.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 15.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 15.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 15.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(t/is (= 2 (count invoices-matches))
|
||||
(str "Expected " (vec invoices-matches) " to have a singular match of two invoices."))))
|
||||
(t/testing "Should not match if there are multiple candidate matches"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(t/is (= 0 (count invoices-matches))
|
||||
(str "Expected " (vec invoices-matches) " to not match due to multiple possibilities."))))
|
||||
|
||||
(t/testing "Should not match if invoices are for different vendors"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 10.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor2-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 20.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 10.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor2-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 20.0
|
||||
:db/id "invoice2-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)
|
||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||
(t/is (= 0 (count invoices-matches))
|
||||
(str "Expected " (vec invoices-matches) " to only consider invoices for the same vendor."))))
|
||||
|
||||
(t/testing "Should only consider invoices chronologically"
|
||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 10.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-06"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 21.0
|
||||
:db/id "invoice2-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-05"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice3-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)]
|
||||
(let [{:strs [client-id]} (->> {:tx-data
|
||||
[#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-04"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 10.0
|
||||
:db/id "invoice1-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-06"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 21.0
|
||||
:db/id "invoice2-id"}
|
||||
#:invoice {:status :invoice-status/paid
|
||||
:vendor vendor1-id
|
||||
:scheduled-payment #inst "2019-01-05"
|
||||
:date #inst "2019-01-01"
|
||||
:client "client-id"
|
||||
:total 30.0
|
||||
:db/id "invoice3-id"}
|
||||
#:client {:name "Client" :db/id "client-id"}]}
|
||||
(dc/transact conn)
|
||||
:tempids)]
|
||||
(t/is (= 2 (count (sut/match-transaction-to-single-unfulfilled-autopayments -40.0 client-id)))
|
||||
(str "Expected to match with the chronologically adjacent invoice-1 and invoice-3."))
|
||||
(t/is (= [] (sut/match-transaction-to-single-unfulfilled-autopayments -31.0 client-id))
|
||||
|
||||
@@ -1,33 +1,11 @@
|
||||
(ns auto-ap.integration.graphql
|
||||
(:require [auto-ap.graphql :as sut]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[venia.core :as v]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[clj-time.core :as time]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri conn]]))
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate conn)
|
||||
(f)
|
||||
(d/release conn)
|
||||
(d/delete-database uri))))
|
||||
[datomic.client.api :as dc]
|
||||
[auto-ap.integration.util :refer [wrap-setup admin-token user-token]]
|
||||
[auto-ap.datomic :refer [conn]]))
|
||||
|
||||
(defn admin-token []
|
||||
{:user "TEST ADMIN"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
(defn user-token []
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id 1}]})
|
||||
|
||||
(defn new-client [args]
|
||||
(merge {:client/name "Test client"
|
||||
@@ -50,9 +28,10 @@
|
||||
(use-fixtures :each wrap-setup)
|
||||
(deftest transaction-page
|
||||
(testing "transaction page"
|
||||
@(d/transact (d/connect uri)
|
||||
[(new-client {:db/id "client"})
|
||||
(new-transaction {:transaction/client "client"})])
|
||||
(dc/transact conn
|
||||
{:tx-data
|
||||
[(new-client {:db/id "client"})
|
||||
(new-transaction {:transaction/client "client"})]})
|
||||
|
||||
(testing "It should find all transactions"
|
||||
(let [result (:transaction-page (:data (sut/query (admin-token) "{ transaction_page(filters: {client_id: null}) { count, start, data { id } }}")))]
|
||||
@@ -69,18 +48,19 @@
|
||||
|
||||
(deftest invoice-page
|
||||
(testing "invoice page"
|
||||
@(d/transact (d/connect uri)
|
||||
[(new-client {:db/id "client"})
|
||||
(new-invoice {:invoice/client "client"
|
||||
:invoice/status :invoice-status/paid})])
|
||||
(dc/transact conn
|
||||
{:tx-data
|
||||
[(new-client {:db/id "client"})
|
||||
(new-invoice {:invoice/client "client"
|
||||
:invoice/status :invoice-status/paid})]})
|
||||
(testing "It should find all invoices"
|
||||
(let [result (first (:invoice-page (:data (sut/query (admin-token) "{ invoice_page(client_id: null, status:paid) { count, start, invoices { id } }}"))))]
|
||||
(let [result (first (:invoice-page (:data (sut/query (admin-token) "{ invoice_page(filters: {client_id: null, status:paid}) { count, start, invoices { id } }}"))))]
|
||||
(is (= 1 (:count result)))
|
||||
(is (= 0 (:start result)))
|
||||
(is (= 1 (count (:invoices result))))))
|
||||
|
||||
(testing "Users should not see transactions they don't own"
|
||||
(let [result (first (:invoice-page (:data (sut/query (user-token) "{ invoice_page(client_id: null) { count, start, invoices { id } }}"))))]
|
||||
(let [result (first (:invoice-page (:data (sut/query (user-token) "{ invoice_page(filters: {client_id: null}) { count, start, invoices { id } }}"))))]
|
||||
(is (= 0 (:count result)))
|
||||
(is (= 0 (:start result)))
|
||||
(is (= 0 (count (:data result))))))))
|
||||
@@ -112,15 +92,17 @@
|
||||
(is (seqable? (:transaction-rules result))))))
|
||||
|
||||
(deftest upsert-transaction-rule
|
||||
(let [{:strs [vendor-id account-id yodlee-merchant-id]} (-> (d/connect uri)
|
||||
(d/transact
|
||||
[{:vendor/name "Bryce's Meat Co"
|
||||
:db/id "vendor-id"}
|
||||
{:account/name "hello"
|
||||
:db/id "account-id"}
|
||||
{:yodlee-merchant/name "yodlee"
|
||||
:db/id "yodlee-merchant-id"}])
|
||||
deref
|
||||
(let [{:strs [vendor-id account-id yodlee-merchant-id]} (->
|
||||
(dc/transact
|
||||
conn
|
||||
{:tx-data
|
||||
[{:vendor/name "Bryce's Meat Co"
|
||||
:db/id "vendor-id"}
|
||||
{:account/name "hello"
|
||||
:db/id "account-id"}
|
||||
{:yodlee-merchant/name "yodlee"
|
||||
:db/id "yodlee-merchant-id"}]})
|
||||
|
||||
:tempids)]
|
||||
(testing "it should reject rules that don't add up to 100%"
|
||||
(let [q (v/graphql-query {:venia/operation {:operation/type :mutation
|
||||
@@ -211,27 +193,28 @@
|
||||
|
||||
(deftest test-transaction-rule
|
||||
(testing "it should match rules"
|
||||
(let [matching-transaction @(d/transact (d/connect uri)
|
||||
[{:transaction/description-original "matching-desc"
|
||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||
:transaction/client {:client/name "1"
|
||||
:db/id "client-1"}
|
||||
:transaction/bank-account {:db/id "bank-account-1"
|
||||
:bank-account/name "1"}
|
||||
(let [matching-transaction (dc/transact conn
|
||||
{:tx-data
|
||||
[{:transaction/description-original "matching-desc"
|
||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||
:transaction/client {:client/name "1"
|
||||
:db/id "client-1"}
|
||||
:transaction/bank-account {:db/id "bank-account-1"
|
||||
:bank-account/name "1"}
|
||||
|
||||
:transaction/amount 1.00
|
||||
:transaction/id "2019-01-05 matching-desc 1"
|
||||
:db/id "a"}
|
||||
:transaction/amount 1.00
|
||||
:transaction/id "2019-01-05 matching-desc 1"
|
||||
:db/id "a"}
|
||||
|
||||
{:transaction/description-original "nonmatching-desc"
|
||||
:transaction/client {:client/name "2"
|
||||
:db/id "client-2"}
|
||||
:transaction/bank-account {:db/id "bank-account-2"
|
||||
:bank-account/name "2"}
|
||||
:transaction/date #inst "2019-01-15T23:23:00.000-08:00"
|
||||
:transaction/amount 2.00
|
||||
:transaction/id "2019-01-15 nonmatching-desc 2"
|
||||
:db/id "b"}])
|
||||
{:transaction/description-original "nonmatching-desc"
|
||||
:transaction/client {:client/name "2"
|
||||
:db/id "client-2"}
|
||||
:transaction/bank-account {:db/id "bank-account-2"
|
||||
:bank-account/name "2"}
|
||||
:transaction/date #inst "2019-01-15T23:23:00.000-08:00"
|
||||
:transaction/amount 2.00
|
||||
:transaction/id "2019-01-15 nonmatching-desc 2"
|
||||
:db/id "b"}]})
|
||||
{:strs [a b client-1 client-2 bank-account-1 bank-account-2]} (get-in matching-transaction [:tempids])
|
||||
a (str a)
|
||||
b (str b)
|
||||
@@ -269,34 +252,35 @@
|
||||
|
||||
(deftest test-match-transaction-rule
|
||||
(testing "it should apply a rules"
|
||||
(let [{:strs [transaction-id transaction-rule-id uneven-transaction-rule-id]} (-> @(d/transact (d/connect uri)
|
||||
[{:transaction/description-original "matching-desc"
|
||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||
:transaction/client {:client/name "1"
|
||||
:db/id "client-1"}
|
||||
:transaction/bank-account {:db/id "bank-account-1"
|
||||
:bank-account/name "1"}
|
||||
:transaction/amount 1.00
|
||||
:db/id "transaction-id"}
|
||||
(let [{:strs [transaction-id transaction-rule-id uneven-transaction-rule-id]} (-> (dc/transact conn
|
||||
{:tx-data
|
||||
[{:transaction/description-original "matching-desc"
|
||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||
:transaction/client {:client/name "1"
|
||||
:db/id "client-1"}
|
||||
:transaction/bank-account {:db/id "bank-account-1"
|
||||
:bank-account/name "1"}
|
||||
:transaction/amount 1.00
|
||||
:db/id "transaction-id"}
|
||||
|
||||
{:db/id "transaction-rule-id"
|
||||
:transaction-rule/note "transaction rule note"
|
||||
:transaction-rule/description "matching-desc"
|
||||
:transaction-rule/accounts [{:transaction-rule-account/location "A"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 1.0}]}
|
||||
{:db/id "uneven-transaction-rule-id"
|
||||
:transaction-rule/note "transaction rule note"
|
||||
:transaction-rule/description "matching-desc"
|
||||
:transaction-rule/accounts [{:transaction-rule-account/location "A"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.3333333}
|
||||
{:transaction-rule-account/location "B"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.33333333}
|
||||
{:transaction-rule-account/location "c"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.333333}]}])
|
||||
{:db/id "transaction-rule-id"
|
||||
:transaction-rule/note "transaction rule note"
|
||||
:transaction-rule/description "matching-desc"
|
||||
:transaction-rule/accounts [{:transaction-rule-account/location "A"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 1.0}]}
|
||||
{:db/id "uneven-transaction-rule-id"
|
||||
:transaction-rule/note "transaction rule note"
|
||||
:transaction-rule/description "matching-desc"
|
||||
:transaction-rule/accounts [{:transaction-rule-account/location "A"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.3333333}
|
||||
{:transaction-rule-account/location "B"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.33333333}
|
||||
{:transaction-rule-account/location "c"
|
||||
:transaction-rule-account/account {:account/numeric-code 123 :db/id "123"}
|
||||
:transaction-rule-account/percentage 0.333333}]}]})
|
||||
:tempids)
|
||||
rule-test (-> (sut/query (admin-token) (v/graphql-query {:venia/operation {:operation/type :mutation
|
||||
:operation/name "MatchTransactionRules"}
|
||||
|
||||
@@ -1,43 +1,9 @@
|
||||
(ns auto-ap.integration.graphql.accounts
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.graphql.accounts :as sut]
|
||||
[clj-time.core :as time]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate conn)
|
||||
@(d/transact conn (->> (d/q '[:find ?a
|
||||
:where [?a :account/name]]
|
||||
(d/db conn))
|
||||
(map (fn [[a]]
|
||||
{:db/id a
|
||||
:account/applicability :account-applicability/global}))))
|
||||
(f)
|
||||
(d/release conn)
|
||||
(d/delete-database uri))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn admin-token []
|
||||
{:user "TEST ADMIN"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn user-token [client-id]
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id client-id}]})
|
||||
|
||||
[auto-ap.integration.util :refer [admin-token user-token wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
|
||||
@@ -55,24 +21,24 @@
|
||||
))
|
||||
1)))
|
||||
(testing "It should filter out accounts that are not allowed for clients"
|
||||
@(d/transact conn [{:account/name "CLIENT SPECIFIC"
|
||||
:db/ident :client-specific-account
|
||||
:account/numeric-code 99999
|
||||
:account/search-terms "CLIENTSPECIFIC"
|
||||
:account/applicability :account-applicability/customized
|
||||
:account/default-allowance :allowance/allowed}])
|
||||
(dc/transact conn {:tx-data [{:account/name "CLIENT SPECIFIC"
|
||||
:db/ident :client-specific-account
|
||||
:account/numeric-code 99999
|
||||
:account/search-terms "CLIENTSPECIFIC"
|
||||
:account/applicability :account-applicability/customized
|
||||
:account/default-allowance :allowance/allowed}]})
|
||||
(is (= 0 (count (sut/search {:id (admin-token)}
|
||||
{:query "CLIENTSPECIFIC"}
|
||||
nil
|
||||
))))
|
||||
|
||||
(testing "It should show up for the client specific version"
|
||||
(let [client-id (-> @(d/transact conn [{:client/name "CLIENT"
|
||||
:db/id "client"}
|
||||
{:db/ident :client-specific-account
|
||||
:account/client-overrides [{:account-client-override/client "client"
|
||||
:account-client-override/name "HI"
|
||||
:account-client-override/search-terms "HELLOWORLD"}]}])
|
||||
(let [client-id (-> (dc/transact conn {:tx-data [{:client/name "CLIENT"
|
||||
:db/id "client"}
|
||||
{:db/ident :client-specific-account
|
||||
:account/client-overrides [{:account-client-override/client "client"
|
||||
:account-client-override/name "HI"
|
||||
:account-client-override/search-terms "HELLOWORLD"}]}]})
|
||||
:tempids
|
||||
(get "client"))]
|
||||
(is (= 1 (count (sut/search {:id (admin-token)}
|
||||
@@ -81,14 +47,14 @@
|
||||
nil))))))
|
||||
|
||||
(testing "It should hide accounts that arent applicable"
|
||||
@(d/transact conn [{:account/name "DENIED"
|
||||
:db/ident :denied-account
|
||||
:account/numeric-code 99998
|
||||
:account/search-terms "DENIED"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/denied
|
||||
:account/invoice-allowance :allowance/denied}])
|
||||
(dc/transact conn {:tx-data [{:account/name "DENIED"
|
||||
:db/ident :denied-account
|
||||
:account/numeric-code 99998
|
||||
:account/search-terms "DENIED"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/denied
|
||||
:account/invoice-allowance :allowance/denied}]})
|
||||
(is (= 0 (count (sut/search {:id (admin-token)}
|
||||
{:query "DENIED"}
|
||||
nil))))
|
||||
@@ -102,14 +68,14 @@
|
||||
nil)))))
|
||||
|
||||
(testing "It should warn when using a warn account"
|
||||
@(d/transact conn [{:account/name "WARNING"
|
||||
:db/ident :warn-account
|
||||
:account/numeric-code 99997
|
||||
:account/search-terms "WARNING"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/warn
|
||||
:account/vendor-allowance :allowance/warn
|
||||
:account/invoice-allowance :allowance/warn}])
|
||||
(dc/transact conn {:tx-data [{:account/name "WARNING"
|
||||
:db/ident :warn-account
|
||||
:account/numeric-code 99997
|
||||
:account/search-terms "WARNING"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/warn
|
||||
:account/vendor-allowance :allowance/warn
|
||||
:account/invoice-allowance :allowance/warn}]})
|
||||
(is (some? (:warning (first (sut/search {:id (admin-token)}
|
||||
{:query "WARNING"
|
||||
:allowance :global}
|
||||
@@ -123,14 +89,14 @@
|
||||
:allowance :vendor}
|
||||
nil))))))
|
||||
(testing "It should only include admin accounts for admins"
|
||||
@(d/transact conn [{:account/name "ADMINONLY"
|
||||
:db/ident :warn-account
|
||||
:account/numeric-code 99997
|
||||
:account/search-terms "ADMINONLY"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/admin-only
|
||||
:account/vendor-allowance :allowance/admin-only
|
||||
:account/invoice-allowance :allowance/admin-only}])
|
||||
(dc/transact conn {:tx-data [{:account/name "ADMINONLY"
|
||||
:db/ident :warn-account
|
||||
:account/numeric-code 99997
|
||||
:account/search-terms "ADMINONLY"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/admin-only
|
||||
:account/vendor-allowance :allowance/admin-only
|
||||
:account/invoice-allowance :allowance/admin-only}]})
|
||||
(is (= 1 (count (sut/search {:id (admin-token)}
|
||||
{:query "ADMINONLY"}
|
||||
nil))))
|
||||
@@ -139,20 +105,21 @@
|
||||
nil)))))
|
||||
|
||||
(testing "It should allow searching for vendor accounts for invoices"
|
||||
(let [vendor-id (-> @(d/transact conn [{:account/name "VENDORONLY"
|
||||
:db/id "vendor-only"
|
||||
:db/ident :vendor-only
|
||||
:account/numeric-code 99996
|
||||
:account/search-terms "VENDORONLY"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/allowed
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:account/invoice-allowance :allowance/denied}
|
||||
{:vendor/name "Allowed"
|
||||
:vendor/default-account "vendor-only"
|
||||
:db/id "vendor"}])
|
||||
:tempids
|
||||
(get "vendor"))]
|
||||
(let [vendor-id (-> (dc/transact conn {:tx-data
|
||||
[{:account/name "VENDORONLY"
|
||||
:db/id "vendor-only"
|
||||
:db/ident :vendor-only
|
||||
:account/numeric-code 99996
|
||||
:account/search-terms "VENDORONLY"
|
||||
:account/applicability :account-applicability/global
|
||||
:account/default-allowance :allowance/allowed
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:account/invoice-allowance :allowance/denied}
|
||||
{:vendor/name "Allowed"
|
||||
:vendor/default-account "vendor-only"
|
||||
:db/id "vendor"}]})
|
||||
:tempids
|
||||
(get "vendor"))]
|
||||
(is (= 0 (count (sut/search {:id (admin-token)}
|
||||
{:query "VENDORONLY"
|
||||
:allowance :invoice}
|
||||
|
||||
@@ -1,64 +1,68 @@
|
||||
(ns auto-ap.integration.graphql.clients
|
||||
(:require
|
||||
[auto-ap.time-reader]
|
||||
[auto-ap.datomic :refer [conn uri]]
|
||||
[auto-ap.datomic :refer [conn pull-attr]]
|
||||
[auto-ap.graphql.clients :as sut]
|
||||
[auto-ap.integration.util :refer [admin-token user-token wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[datomic.api :as d]))
|
||||
[auto-ap.integration.util :refer [wrap-setup user-token admin-token]]
|
||||
[datomic.client.api :as dc]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
|
||||
(deftest current-balance
|
||||
(testing "it should start with a balance of 0"
|
||||
@(d/transact (d/connect uri)
|
||||
[{:client/code "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-1"}]}])
|
||||
(dc/transact conn
|
||||
{:tx-data
|
||||
[{:client/code "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-1"}]}]})
|
||||
(sut/refresh-current-balance)
|
||||
(is (= 0.00
|
||||
(:bank-account/current-balance (d/entity (d/db conn) [:bank-account/code "TEST-1"])))))
|
||||
(pull-attr (dc/db conn) :bank-account/current-balance [:bank-account/code "TEST-1"] ))))
|
||||
|
||||
(testing "it should consider a single transaction"
|
||||
@(d/transact (d/connect uri)
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-1"
|
||||
:db/id "TEST-1"}]}
|
||||
{:journal-entry-line/account "TEST-1"
|
||||
:journal-entry-line/debit 13.50}
|
||||
(dc/transact conn
|
||||
{:tx-data
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-1"
|
||||
:db/id "TEST-1"}]}
|
||||
{:journal-entry-line/account "TEST-1"
|
||||
:journal-entry-line/debit 13.50}
|
||||
|
||||
{:journal-entry-line/account "TEST-1"
|
||||
:journal-entry-line/debit 19.50}])
|
||||
{:journal-entry-line/account "TEST-1"
|
||||
:journal-entry-line/debit 19.50}]})
|
||||
(sut/refresh-current-balance)
|
||||
(is (= -33.0
|
||||
(:bank-account/current-balance (d/entity (d/db conn) [:bank-account/code "TEST-1"])))))
|
||||
(pull-attr (dc/db conn) :bank-account/current-balance [:bank-account/code "TEST-1"]))))
|
||||
|
||||
(testing "bank accounts should start in a needing refresh state"
|
||||
(let [bank-account-id (-> @(d/transact (d/connect uri)
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-2" :db/id "TEST-2"}]}
|
||||
])
|
||||
(let [bank-account-id (-> (dc/transact conn
|
||||
{:tx-data
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-2" :db/id "TEST-2"}]}
|
||||
]})
|
||||
:tempids
|
||||
(get "TEST-2"))]
|
||||
|
||||
(is ((sut/bank-accounts-needing-refresh) bank-account-id ))))
|
||||
|
||||
(testing "bank accounts should not need a refresh if balance is up-to-date"
|
||||
(let [bank-account-id (-> @(d/transact (d/connect uri)
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-3" :db/id "TEST-3"}]}
|
||||
])
|
||||
(let [bank-account-id (-> (dc/transact conn
|
||||
{:tx-data
|
||||
[{:client/code "TEST"
|
||||
:db/id "TEST"
|
||||
:client/bank-accounts [{:bank-account/code "TEST-3" :db/id "TEST-3"}]}
|
||||
]})
|
||||
:tempids
|
||||
(get "TEST-3"))]
|
||||
(sut/refresh-bank-account-current-balance bank-account-id)
|
||||
(is (not ((sut/bank-accounts-needing-refresh) bank-account-id )))
|
||||
@(d/transact (d/connect uri)
|
||||
[{:journal-entry-line/account [:bank-account/code "TEST-3"]
|
||||
:journal-entry-line/debit -10.50}
|
||||
])
|
||||
(dc/transact conn
|
||||
{:tx-data
|
||||
[{:journal-entry-line/account [:bank-account/code "TEST-3"]
|
||||
:journal-entry-line/debit -10.50}
|
||||
]})
|
||||
(is ((sut/bank-accounts-needing-refresh) bank-account-id ))
|
||||
(sut/refresh-bank-account-current-balance bank-account-id)
|
||||
(is (not ((sut/bank-accounts-needing-refresh) bank-account-id ))))))
|
||||
|
||||
@@ -1,55 +1,26 @@
|
||||
(ns auto-ap.integration.graphql.invoices
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.time-reader]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.graphql.invoices :as sut]
|
||||
[clj-time.core :as time]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate conn)
|
||||
|
||||
(f)
|
||||
(d/release conn)
|
||||
(d/delete-database uri))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn admin-token []
|
||||
{:user "TEST ADMIN"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn user-token [client-id]
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id client-id}]})
|
||||
|
||||
[auto-ap.integration.util :refer [admin-token wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
|
||||
(deftest test-add-invoice
|
||||
(testing "It should Add an invoice"
|
||||
(let [{:strs [vendor-id client-id account-id]}
|
||||
(:tempids @(d/transact conn [{:client/code "ABC"
|
||||
:db/id "client-id"
|
||||
:client/locations ["DT"]}
|
||||
{:vendor/name "Vendy"
|
||||
:db/id "vendor-id"
|
||||
:vendor/default-account "account-id"}
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/allowed
|
||||
:db/id "account-id"}]))]
|
||||
(:tempids (dc/transact conn
|
||||
{:tx-data [{:client/code "ABC"
|
||||
:db/id "client-id"
|
||||
:client/locations ["DT"]}
|
||||
{:vendor/name "Vendy"
|
||||
:db/id "vendor-id"
|
||||
:vendor/default-account "account-id"}
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/allowed
|
||||
:db/id "account-id"}]}))]
|
||||
(is (some? (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-id
|
||||
@@ -62,11 +33,11 @@
|
||||
nil)))
|
||||
(testing "It should prevent an expense account that isn't allowed"
|
||||
(let [{:strs [denied-account-id]}
|
||||
(:tempids @(d/transact conn [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:db/id "denied-account-id"}]))]
|
||||
(:tempids (dc/transact conn
|
||||
{:tx-data [{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:db/id "denied-account-id"}]}))]
|
||||
(is (thrown? Exception (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-id
|
||||
@@ -80,15 +51,15 @@
|
||||
|
||||
(testing "It should allow an expense account that is valid for the vendor"
|
||||
(let [{:strs [vendor-account-id vendor-2]}
|
||||
(:tempids @(d/transact conn [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:db/id "vendor-account-id"}
|
||||
{:vendor/name "Testy"
|
||||
:vendor/default-account "vendor-account-id"
|
||||
:db/id "vendor-2"}]))]
|
||||
(:tempids (dc/transact conn {:tx-data [
|
||||
{:account/name "Account"
|
||||
:account/numeric-code 123
|
||||
:account/invoice-allowance :allowance/denied
|
||||
:account/vendor-allowance :allowance/allowed
|
||||
:db/id "vendor-account-id"}
|
||||
{:vendor/name "Testy"
|
||||
:vendor/default-account "vendor-account-id"
|
||||
:db/id "vendor-2"}]}))]
|
||||
(is (some? (sut/add-invoice {:id (admin-token)}
|
||||
{:invoice {:client_id client-id
|
||||
:vendor_id vendor-2
|
||||
|
||||
@@ -1,49 +1,21 @@
|
||||
(ns auto-ap.integration.graphql.vendors
|
||||
(:require [auto-ap.graphql.vendors :as sut2]
|
||||
[auto-ap.datomic :refer [uri conn]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.api :as d]
|
||||
[clj-time.core :as time]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate conn)
|
||||
(f)
|
||||
(d/release conn)
|
||||
(d/delete-database uri))))
|
||||
|
||||
(defn admin-token []
|
||||
{:user "TEST ADMIN"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "admin"
|
||||
:user/name "TEST ADMIN"})
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn user-token [client-id]
|
||||
{:user "TEST USER"
|
||||
:exp (time/plus (time/now) (time/days 1))
|
||||
:user/role "user"
|
||||
:user/name "TEST USER"
|
||||
:user/clients [{:db/id client-id}]})
|
||||
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.graphql.vendors :as sut2]
|
||||
[auto-ap.integration.util :refer [admin-token wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.client.api :as dc]))
|
||||
|
||||
(use-fixtures :each wrap-setup)
|
||||
|
||||
|
||||
(deftest vendors
|
||||
(testing "vendors"
|
||||
(let [{:strs [vendor]} (:tempids @(d/transact (d/connect uri) [{:vendor/name "Test" :db/id "vendor"}
|
||||
{:db/id "client"
|
||||
:client/code "DEF"}]))]
|
||||
(let [{:strs [vendor]} (:tempids (dc/transact conn {:tx-data [{:vendor/name "Test" :db/id "vendor"}
|
||||
{:db/id "client"
|
||||
:client/code "DEF"}]}))]
|
||||
(testing "it should find vendors"
|
||||
(let [result (sut2/get-graphql {:id (admin-token)} {} {})]
|
||||
(is ((into #{} (map :id (:vendors result))) vendor ))))
|
||||
|
||||
)))
|
||||
(is ((into #{} (map :id (:vendors result))) vendor )))))))
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
(ns auto-ap.integration.rule-matching
|
||||
(:require
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.integration.util :refer [wrap-setup]]
|
||||
[auto-ap.rule-matching :as sut]
|
||||
[clojure.test :as t]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate auto-ap.datomic/conn)
|
||||
(f)
|
||||
(d/release auto-ap.datomic/conn)
|
||||
(d/delete-database uri))))
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :each wrap-setup)
|
||||
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
(ns auto-ap.ledger-test
|
||||
(:require
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[clojure.test :as t]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate auto-ap.datomic/conn)
|
||||
(f)
|
||||
(d/release auto-ap.datomic/conn)
|
||||
(d/delete-database uri))))
|
||||
[auto-ap.integration.util :refer [wrap-setup]]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :each wrap-setup)
|
||||
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
(ns auto-ap.routes.invoice-test
|
||||
(:require
|
||||
[auto-ap.datomic :refer [uri conn]]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.integration.util :refer [user-token wrap-setup]]
|
||||
[auto-ap.routes.invoices :as sut]
|
||||
[clojure.test :as t]
|
||||
[datomic.api :as d]
|
||||
[clj-time.coerce :as coerce]))
|
||||
|
||||
(defn wrap-setup
|
||||
[f]
|
||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"]
|
||||
(d/create-database uri)
|
||||
(with-redefs [auto-ap.datomic/conn (d/connect uri)]
|
||||
(m/migrate auto-ap.datomic/conn)
|
||||
(f)
|
||||
(d/release auto-ap.datomic/conn)
|
||||
(d/delete-database uri))))
|
||||
[datomic.client.api :as dc]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :each wrap-setup)
|
||||
|
||||
(def user {:user/role "admin"
|
||||
:user/name "Bryce"})
|
||||
(def user (user-token))
|
||||
|
||||
(def client {:client/code "ABC"
|
||||
:client/name "ABC"
|
||||
@@ -35,10 +24,10 @@
|
||||
|
||||
(defn invoice-count-for-client [c]
|
||||
(or
|
||||
(first (first (d/q '[:find (count ?i)
|
||||
(first (first (dc/q '[:find (count ?i)
|
||||
:in $ ?c
|
||||
:where [?i :invoice/client ?c]]
|
||||
(d/db conn) c)))
|
||||
(dc/db conn) c)))
|
||||
0))
|
||||
|
||||
(def invoice {:customer-identifier "ABC"
|
||||
@@ -49,7 +38,7 @@
|
||||
|
||||
(t/deftest import-uploaded-invoices
|
||||
(t/testing "It should import one"
|
||||
@(d/transact conn [client expense-account vendor])
|
||||
(dc/transact conn {:tx-data [client expense-account vendor]})
|
||||
|
||||
(t/is (= 0 (invoice-count-for-client [:client/code "ABC"])))
|
||||
(sut/import-uploaded-invoice user [(assoc invoice :customer-identifier "ABC")])
|
||||
@@ -69,26 +58,28 @@
|
||||
:location-override "DE"
|
||||
:customer-identifier "ABC"
|
||||
:invoice-number "789")])
|
||||
(t/is (= ["DE"] (d/q '[:find [?l ...]
|
||||
(t/is (= [["DE"]] (dc/q '[:find ?l
|
||||
:where [?i :invoice/invoice-number "789"]
|
||||
[?i :invoice/expense-accounts ?ea]
|
||||
[?ea :invoice-expense-account/location ?l]]
|
||||
(d/db conn)))))
|
||||
(dc/db conn)))))
|
||||
|
||||
(t/testing "Should code invoice"
|
||||
(let [{{:strs [my-default-account coded-vendor]} :tempids} @(d/transact conn [{:vendor/name "Coded"
|
||||
:db/id "coded-vendor"
|
||||
:vendor/terms 12
|
||||
:vendor/default-account "my-default-account"}
|
||||
{:db/id "my-default-account"
|
||||
:account/name "My default-account"}])]
|
||||
(let [{{:strs [my-default-account coded-vendor]} :tempids} (dc/transact conn
|
||||
{:tx-data
|
||||
[{:vendor/name "Coded"
|
||||
:db/id "coded-vendor"
|
||||
:vendor/terms 12
|
||||
:vendor/default-account "my-default-account"}
|
||||
{:db/id "my-default-account"
|
||||
:account/name "My default-account"}]})]
|
||||
(sut/import-uploaded-invoice user [(assoc invoice
|
||||
:invoice-number "456"
|
||||
:customer-identifier "ABC"
|
||||
:vendor-code "Coded")])
|
||||
(let [[result] (d/q '[:find [(pull ?i [*]) ...]
|
||||
(let [[[result]] (dc/q '[:find (pull ?i [*])
|
||||
:where [?i :invoice/invoice-number "456"]]
|
||||
(d/db conn))]
|
||||
(dc/db conn))]
|
||||
(t/is (= coded-vendor (:db/id (:invoice/vendor result))))
|
||||
(t/is (= [my-default-account]
|
||||
(map (comp :db/id :invoice-expense-account/account) (:invoice/expense-accounts result))))
|
||||
|
||||
@@ -6,3 +6,9 @@ automatically rebuild search indexes
|
||||
ezcater graphql needs search index too
|
||||
make sure that temporary ids are set on all new things when using upsert-entity
|
||||
Wrap tests around every api call
|
||||
Fix tests
|
||||
Make a different solution for running balance cache
|
||||
* Store the running balance on the line
|
||||
* Make ledger changes mark as dirty
|
||||
* Recompute the cache periodically, somewhat randomly to avoid races
|
||||
* Have a background job recompute all at night.
|
||||
|
||||
Reference in New Issue
Block a user