Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
I
invoice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kb
invoice
Commits
af0b39c9
Commit
af0b39c9
authored
Apr 14, 2020
by
Patrick Kimber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If the invoices for a contact are posted 'on_account' then don't allow this to change
parent
e36952d4
Pipeline
#135893931
passed with stage
in 5 minutes and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
invoice/models.py
invoice/models.py
+9
-1
invoice/tests/test_invoice_contact.py
invoice/tests/test_invoice_contact.py
+30
-0
No files found.
invoice/models.py
View file @
af0b39c9
...
...
@@ -200,6 +200,14 @@ class InvoiceContactManager(models.Manager):
vat_number
=
None
,
on_account
=
None
,
):
"""Initialise the invoice details for the contact.
.. note:: The on account flag (``on_account``) can only be switched on.
It can't be switched off.
If we are posting to an accounts package e.g. Xero, then we
should always post on-account if we ever posted on-account.
"""
if
on_account
is
None
:
on_account
=
False
try
:
...
...
@@ -211,7 +219,7 @@ class InvoiceContactManager(models.Manager):
if
hourly_rate
:
x
.
hourly_rate
=
hourly_rate
update
=
True
if
on_account
!=
x
.
on_account
:
if
on_account
is
True
and
x
.
on_account
is
False
:
x
.
on_account
=
on_account
update
=
True
if
vat_number
:
...
...
invoice/tests/test_invoice_contact.py
View file @
af0b39c9
...
...
@@ -137,6 +137,36 @@ def test_init_invoice_contact_hourly_rate():
assert
""
==
x
.
vat_number
@
pytest
.
mark
.
parametrize
(
"init_on_account,on_account,expect"
,
[
(
True
,
True
,
True
),
(
True
,
False
,
True
),
(
False
,
False
,
False
),
(
False
,
True
,
True
),
],
)
@
pytest
.
mark
.
django_db
def
test_init_invoice_on_account
(
init_on_account
,
on_account
,
expect
):
"""Initialise the on-account status for the contact.
.. note:: The on account flag (``on_account``) can only be switched on.
It can't be switched off.
If we are posting to an accounts package e.g. Xero, then we
should always post on-account if we ever posted on-account.
"""
contact
=
ContactFactory
()
InvoiceContact
.
objects
.
init_invoice_contact
(
contact
,
on_account
=
init_on_account
,
)
x
=
InvoiceContact
.
objects
.
init_invoice_contact
(
contact
,
on_account
=
on_account
,
)
x
.
refresh_from_db
()
assert
expect
==
x
.
on_account
@
pytest
.
mark
.
django_db
def
test_init_invoice_contact_vat_number
():
contact
=
ContactFactory
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment