mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[report] rewrite gnc:report-template-has-unique-name?
This commit is contained in:
parent
ad51c5e00a
commit
eab53d44b3
@ -489,16 +489,12 @@ not found.")))
|
|||||||
;; to test if the new name is unique among the existting custom reports.
|
;; to test if the new name is unique among the existting custom reports.
|
||||||
;; If not the calling function can prevent the name from being updated.
|
;; If not the calling function can prevent the name from being updated.
|
||||||
(define (gnc:report-template-has-unique-name? templ-guid new-name)
|
(define (gnc:report-template-has-unique-name? templ-guid new-name)
|
||||||
(let* ((unique? #t))
|
(or (not new-name)
|
||||||
(if new-name
|
(not (any
|
||||||
(hash-for-each
|
(lambda (tmpl)
|
||||||
(lambda (id rec)
|
(and (not (equal? (car tmpl) templ-guid))
|
||||||
(if (and (not (equal? templ-guid id))
|
(equal? (gnc:report-template-name (cdr tmpl)) new-name)))
|
||||||
(gnc:report-template-is-custom/template-guid? id)
|
(gnc:custom-report-templates-list)))))
|
||||||
(equal? new-name (gnc:report-template-name rec)))
|
|
||||||
(set! unique? #f)))
|
|
||||||
*gnc:_report-templates_*))
|
|
||||||
unique?))
|
|
||||||
|
|
||||||
;; Generate a unique custom template name using the given string as a base
|
;; Generate a unique custom template name using the given string as a base
|
||||||
;; If this string already exists as a custom template name, a
|
;; If this string already exists as a custom template name, a
|
||||||
|
@ -196,6 +196,19 @@
|
|||||||
(test-equal "(gnc:is-custom-report-type report) #f"
|
(test-equal "(gnc:is-custom-report-type report) #f"
|
||||||
#f
|
#f
|
||||||
(gnc:is-custom-report-type report))
|
(gnc:is-custom-report-type report))
|
||||||
|
(test-assert "gnc:report-template-has-unique-name? #t"
|
||||||
|
(gnc:report-template-has-unique-name?
|
||||||
|
"54c2fc051af64a08ba2334c2e9179e24"
|
||||||
|
"Test Report Templatx"))
|
||||||
|
(test-assert "gnc:report-template-has-unique-name? #f"
|
||||||
|
(not
|
||||||
|
(gnc:report-template-has-unique-name?
|
||||||
|
"54c2fc051af64a08ba2334c2e9179e24"
|
||||||
|
"Test Report Template")))
|
||||||
|
(test-assert "gnc:report-template-has-unique-name? #t"
|
||||||
|
(gnc:report-template-has-unique-name?
|
||||||
|
"54c2fc051af64a08ba2334c2e9179e24"
|
||||||
|
#f))
|
||||||
(test-assert "gnc:report-serialize = string"
|
(test-assert "gnc:report-serialize = string"
|
||||||
(string?
|
(string?
|
||||||
(gnc:report-serialize report)))))
|
(gnc:report-serialize report)))))
|
||||||
|
Loading…
Reference in New Issue
Block a user