Skip to content

Commit

Permalink
clearing db before restoring backup to avoid invoice duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
pnalvarez committed Nov 21, 2024
1 parent 5de88e6 commit 6306366
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/data/repositories/application_backup_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ApplicationBackupRepository implements IApplicationBackupRepository {
final companyInfo = applicationData.companyInfo;
final invoiceList = applicationData.invoiceList;

await _localDataSource.clearDB();

if (clientInfo != null) {
await _localDataSource.saveClientInfo(clientInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void main() {
await sut.save(
'{"clientInfo":{"name":"Name","address":"Address"},"serviceInfo":{"description":"Description","quantity":0.0,"currencyName":"Currency","currencySymbol":"Symbol","currencyCC":"CC","price":10.0},"bankInfo":{"beneficiaryName":"Name","iban":"123","swift":"123","bankName":"123","bankAddress":"Address","intermediaryIban":null,"intermediarySwift":null,"intermediaryBankName":null,"intermediaryBankAddress":null},"companyInfo":{"name":"Name","address":{"street":"St","extraInfo":null,"neighbourhood":"Neighbourhood","city":"City","state":"State","country":"Country","zipCode":"Zip code"},"email":"email@email.com","ownerName":"Owner","cnpj":"123"},"invoiceList":[{"id":1,"issueDate":1,"dueDate":1,"createdAt":1,"updatedAt":1,"serviceInfo":{"description":"Description","quantity":0.0,"currencyName":"Currency","currencySymbol":"Symbol","currencyCC":"CC","price":10.0},"companyInfo":{"name":"Name","address":{"street":"Street","extraInfo":null,"neighbourhood":"Neighbourhood","city":"City","state":"State","country":"country","zipCode":"zipCode"},"email":"email@email.com","ownerName":"ownerName","cnpj":"cnpj"},"clientInfo":{"name":"name","address":"address"},"bankInfo":{"beneficiaryName":"beneficiaryName","iban":"iban","swift":"swift","bankName":"bankName","bankAddress":"bankAddress","intermediaryIban":null,"intermediarySwift":null,"intermediaryBankName":null,"intermediaryBankAddress":null}}]}');
// Then
verify(mockLocalDataSource.clearDB()).called(1);
verify(mockLocalDataSource.saveBankInfo(any)).called(1);
verify(mockLocalDataSource.saveClientInfo(any)).called(1);
verify(mockLocalDataSource.saveCompanyInfo(any)).called(1);
Expand Down

0 comments on commit 6306366

Please sign in to comment.